Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
Private waterwifi As ESP8266WiFi
Private D2pin As D1Pins
Private D1 As Pin
Private counter As UInt
Private set= False As Boolean
Private totalCounter As uInt
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
D1.Initialize(D2pin.D1,D1.MODE_INPUT_PULLUP)
D1.AddListener("pin2_StateChanged")
waterwifi.Connect2("xxxx","xxxx")
If waterwifi.IsConnected Then
Log("Router Connected Successfully!!!")
Else
Log("Router Not able to connect!!!")
Return
End If
HttpJob.Initialize("Test")
HttpJob.Download("http://mytestpage.com")
End Sub
Sub jobdone(Job As JobResult)
End Sub
Private Sub flowcalc()
'This procedure will calculate the total counter before sending to Webpage.
If counter=0 Then
Return 'Do nothing when counter is 0
Else
Do While counter>0
totalCounter=(totalCounter+counter)
'Log("TotalCounter inside loop:",totalCounter)
counter=0 'Resetting he counter
set=False
Loop
End If
Log("TotalCounter outside loop:",totalCounter)
End Sub
Private Sub pin2_StateChanged(state As Boolean)
Select state
Case True
counter=counter+1
Case False
End Select
End Sub