Thanks for that info Mike. The attached program works perfectly in all aspects. I am trying to figure out why adding to the GUI the remmed out textboxes in the gui sub kills the winsock connect, winsock disconnect on a 4mbit esp running A65.
The only difference between a perfectly working setup where the winsock works great on several different browsers, on all different machines, including iphone, mac, etc. (only one connection to the esp though), is the addition of 6 textboxes. Does this sound like a winsock problem, or a gui buffer problem or something else?
I have tried many different ways of doing the gui, with different "wait" setups and "returngui" setups and they all do the same thing when I add the 6 additional textboxes, winsock connect and disconnect don't work and the browser window is just blank, but program is running.
Any help or ideas would be great. Thanks!
Code: Select allcls
memclear
localip = ip()
brightness = 15
relay = D1
address = 112
count = 1
col = 0
dot = 0
timer 0
dim digits(11)
digits(0) = 63
digits(1) = 6
digits(2) = 91
digits(3) = 79
digits(4) = 102
digits(5) = 109
digits(6) = 125
digits(7) = 7
digits(8) = 127
digits(9) = 111
digits(10) = 0
'************ INITIALIZE DISPLAY *************
i2c.setup(D4,D2)
i2c.begin(address)
i2c.write(33)
i2c.end()
i2c.begin(address)
i2c.write(129)
i2c.end()
i2c.begin(address)
bright = 224 + brightness
i2c.write(bright)
i2c.end()
delay 10
i2c.begin(address)
i2c.write(4)
i2c.write(0)
i2c.end()
'clear display
connum = 0
gosub [convertdig]
gosub [write4dig]
gosub [showip]
'************ CHECK IF AP MODE *************
if localip = "192.168.4.1" then
'scan wifi here
cls
wprint "Welcome to Relay Clock <br>"
wprint "Enter your WIFI info below <br>"
wprint "Hit Save and Reboot <br><br>"
wprint "WIFI Name:"
textbox wifiname
wprint "<br>"
wprint "WIFI Pass:"
textbox wifipass
wprint "<br><br>"
button "Save WIFI Settings",[wifiupdate]
wprint "<br> <br>"
button "Reboot Clock",[reboot]
wprint "<br> <br>"
wait
end if
'************ GET SAVED INFO *************
dst = read.val(DaylightSavings)
timezone = read.val(TZ)
wifiname = read(WIFIname)
wifipass = read(WIFIpass)
ontime1 = read(ontimes1)
ontime2 = read(ontimes2)
ontime3 = read(ontimes3)
ontime4 = read(ontimes4)
ontime5 = read(ontimes5)
ontime6 = read(ontimes6)
ontime7 = read(ontimes7)
ontime8 = read(ontimes8)
offtime1 = read(offtimes1)
offtime2 = read(offtimes2)
offtime3 = read(offtimes3)
offtime4 = read(offtimes4)
offtime5 = read(offtimes5)
offtime6 = read(offtimes6)
offtime7 = read(offtimes7)
offtime8 = read(offtimes8)
if dst = 1 then
tz = timezone + 1
else
tz = timezone
endif
timesetup(tz,dst)
delay 5000
gosub [drawgui]
timer 1000,[colon]
wait
'************ DRAW GUI *************
[drawgui]
wprint "<br><br>"
curtime = time("hour:min:sec")
wprint "Time Now: "
textbox curtime
wprint "<br><br>"
wprint "Timezone: "
textbox timezone
wprint "<br>"
wprint "DST 1 or 0: "
textbox dst
wprint "<br><br>"
button "Update Time Info",[timeupdate]
wprint "<br><br>"
wprint "Enter relay times in HH:MM:SS 24 hour format"
wprint "<br>"
wprint |Press "Save Relay Times" button when done|
wprint "<br><br>"
wprint "On Time 1 "
textbox ontime1
wprint "Off Time 1"
textbox offtime1
wprint "<br>"
wprint "On Time 2 "
textbox ontime2
wprint "Off Time 2"
textbox offtime2
wprint "<br>"
wprint "On Time 3 "
textbox ontime3
wprint "Off Time 3"
textbox offtime3
wprint "<br>"
wprint "On Time 4 "
textbox ontime4
wprint "Off Time 4"
textbox offtime4
wprint "<br>"
wprint "On Time 5 "
textbox ontime5
wprint "Off Time 5"
textbox offtime5
wprint "<br>"
'wprint "On Time 6 " '<<<<<<<<<<<<< UNREM this line and down and GUI won't display
'textbox ontime6
'wprint "Off Time 6"
'textbox offtime6
'wprint "<br>"
'wprint "On Time 7 "
'textbox ontime7
'wprint "Off Time 7"
'textbox offtime7
'wprint "<br>"
'wprint "On Time 8 "
'textbox ontime8
'wprint "Off Time 8"
'textbox offtime8
'wprint "<br>" '<<<<<<<<<<<<< UNREM to here
wprint "<br>"
button "Save Relay Times",[updrelay]
wprint "<br><br>"
button "Test Relay",[testrelay]
button "End Program",[exit]
returngui
return
'************ COLON 1000ms *************
[colon]
if col = 0 then dot = 0 else dot = 2
i2c.begin(address)
i2c.write(4)
i2c.write(dot)
i2c.end()
delay 10
if col = 1 then col = 0 else col = 1
curtime = time("hour:min:sec")
gosub [checkrelay]
gosub [refresh]
wait
'************ CHECK RELAY TIMES *************
[checkrelay]
if curtime = ontime1 then gosub [relayon]
if curtime = offtime1 then gosub [relayoff]
if curtime = ontime2 then gosub [relayon]
if curtime = offtime2 then gosub [relayoff]
if curtime = ontime3 then gosub [relayon]
if curtime = offtime3 then gosub [relayoff]
if curtime = ontime4 then gosub [relayon]
if curtime = offtime4 then gosub [relayoff]
if curtime = ontime5 then gosub [relayon]
if curtime = offtime5 then gosub [relayoff]
if curtime = ontime6 then gosub [relayon]
if curtime = offtime6 then gosub [relayoff]
if curtime = ontime7 then gosub [relayon]
if curtime = offtime7 then gosub [relayoff]
if curtime = ontime8 then gosub [relayon]
if curtime = offtime8 then gosub [relayoff]
return
'************ REFRESH TIME *************
[refresh]
minx = val(time("min"))
hourx = val(time("hour"))
dig4 = minx%10
dig3 = int((minx/10))
dig2 = hourx%10
dig1 = int((hourx/10))
'remove leading zeros
if dig1 = 0 then
dig1 = 10
if dig2 = 0 then
dig2 = 10
if dig3 = 0 then
dig3 = 10
if dig4 = 0 then
dig4 = 10
end if
end if
end if
end if
gosub [write4dig]
return
'************ SHOW IP ADDRESS *************
[showip]
for zz = 1 to 4
ipnumstr = word(localip,zz,".")
connum = val(ipnumstr)
gosub [convertdig]
gosub [write4dig]
delay 1000
connum = 0
gosub [convertdig]
gosub [write4dig]
delay 400
next zz
delay 500
return
'************ CONVERT DIGITS *************
[convertdig]
dig1 = int(connum/1000)
dig2 = int((connum%1000)/100)
dig3 = int((connum%100)/10)
dig4 = int(connum%10)
'remove leading zeros
if dig1 = 0 then
dig1 = 10
if dig2 = 0 then
dig2 = 10
if dig3 = 0 then
dig3 = 10
if dig4 = 0 then
dig4 = 10
end if
end if
end if
end if
return
'************ WRITE 4 DIGITS *************
[write4dig]
i2c.begin(address)
i2c.write(0)
i2c.write(digits(dig1))
i2c.end()
delay 10
i2c.begin(address)
i2c.write(2)
i2c.write(digits(dig2))
i2c.end()
delay 10
i2c.begin(address)
i2c.write(6)
i2c.write(digits(dig3))
i2c.end()
delay 10
i2c.begin(address)
i2c.write(8)
i2c.write(digits(dig4))
i2c.end()
delay 10
return
'************ TEST RELAY *************
[testrelay]
for yy = 1 to 3
gosub [relayon]
delay 750
gosub [relayoff]
delay 750
next yy
wait
'************ UPDATE RELAY ON/OFF TIMES *************
[updrelay]
write(ontimes1,ontime1)
write(offtimes1,offtime1)
write(ontimes2,ontime2)
write(offtimes2,offtime2)
write(ontimes3,ontime3)
write(offtimes3,offtime3)
write(ontimes4,ontime4)
write(offtimes4,offtime4)
write(ontimes5,ontime5)
write(offtimes5,offtime5)
write(ontimes6,ontime6)
write(offtimes6,offtime6)
write(ontimes7,ontime7)
write(offtimes7,offtime7)
write(ontimes8,ontime8)
write(offtimes8,offtime8)
wait
'************ UPDATE TIME INFO *************
[timeupdate]
write(DaylightSavings,str(dst))
write(TZ,str(timezone))
if dst = 1 then
tz = timezone + 1
else
tz = timezone
endif
timesetup(tz,dst)
delay 5000
curtime = time("hour:min:sec")
wait
'************ UPDATE WIFI INFO *************
[wifiupdate]
write(WIFIname,wifiname)
write(WIFIpass,wifipass)
wprint "WIFI info saved..."
wait
'************ REBOOT CLOCK *************
[reboot]
cls
wprint "REBOOTING..."
delay 1000
reboot
wait
'************ RELAY ON SUB *************
[relayon]
io(po,relay,1)
return
'************ RELAY OFF SUB *************
[relayoff]
io(po,relay,0)
return
'************ EXIT PROGRAM *************
[exit]
timer 0
wprint "<a href='/'>Menu</a>"
end - See more at: http://www.esp8266.com/viewtopic.php?f=45&t=13126#sthash.xpbhMYhe.dpuf