- Tue Nov 03, 2015 11:20 am
#32943
As to the page refreshing and it executing the same branch as a previous button click this is working as intended. branch this is working as intended. You can use the option to redirect to "./input?" instead of refreshing the page so that the old values are not send and a button click branch is not executed.
#0 ? If no refresh page then vars changes will not be reflected !!!!!!!
#1 I think that not resetting the condition that triggered the button click would be a bad decision!
example click to shut garage door --- clicks will continued eventually destroying garage door
click to raise temperature on a remote heater ---- temp continues to rise until unit destroys self + more?
It would be preferrable to do in FW else each user will have to some how do for all buttons........
That being said
V 1.13
added buttons EyeOpn and EyeClo and ForNext and modified Blink/TempUP/DN for better testing
Question--1--> I added a serialprintln Ipage in the Wprint stream --I never see this print, Why?
Question--2--> How do you add Remarks to code ?
#2 for next counts 1-5 and serialprintln pass x 1st click works ok , next click super slow response , which will occur -- makes no diff if I wait here or after EyeOpn
if you click again or if you don't click because of above condition !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#3 htmlvar using numerics is working so far on vars I'm using
htmlvar(Ipage) string now displays image ok, BUT still will not change displayed image
added EyeOpn and EyeClo to test
I kept playing now image changing ????
latest lines ----- looks same to me but now work.....will reboot to see if stays working
Rebooted and still works -- NO CLUE WHY code looks same to me......
wprint "<td><IMG SRC ="
wprint htmlvar(Ipage)
wprint " LEFT='1' WIDTH='120' HEIGHT='60' BORDER='1'></td>"
will need to check code to see where diff is?
#4 changed Blink code to:
Code: Select all [BLINK]
if Ipage == B_Clo then Ipage = B_Opn else Ipage = B_Clo
serialprintln "setting cnt = '1' "
cnt = "1"
if cnt == "1" then SERIALPRINTLN "1"
if cnt == "2" then SERIALPRINTLN "2"
serialprintln "cnt still = '1' why print 2 "
SERIALPRINTLN Ipage
wait
code will print both 1 and 2 , 2 should not print !!!!
Code: Select allmycommand = " "
cnt = "1"
rfctr = 0
adc_id = 0
adc_value = 512
k1 = 0.11
p00 = 'P'
apc0 = 40000
ppm0 = 1770
adj1 = 1768
adj2 = 1769
cdeg0 = 25.1
fdeg0 = 77.18
kta0 = '0.01'
lo0 = '12'
hi0 = '20'
prb = '01.0'
ph = '7.0'
sbuf = ""
B_Opn = 'http://i.imgur.com/kzt3tO8.png'
B_Clo = 'http://i.imgur.com/KS1dPa7.png'
Ipage = B_Clo
rfh = '15'
wprint "<meta http-equiv='refresh' content='15' >"
wprint "<script type = 'text/javascript'>"
wprint "var timeInSecs;"
wprint "var ticker;function startTimer(secs){"
wprint "timeInSecs = parseInt(secs)-1;"
wprint "ticker = setInterval('tick()',1000);}"
wprint "function tick() {"
wprint "var secs = timeInSecs;"
wprint "if (secs>0) {timeInSecs--;} else {clearInterval(ticker);"
wprint "startTimer(15);}document.getElementById('countdown').innerHTML = secs;} startTimer(15);"
wprint "</script><body><div>"
wprint "<table bgcolor='Lawngreen' border='1' cellpadding='5'>"
wprint "<th><h1>ESP8266 Blinker Thing!</h1></th>"
wprint "<td><IMG SRC="
wprint htlmvar(Ipage)
wprint " LEFT='1' WIDTH='120' HEIGHT='60' BORDER='1'></td>"
wprint "<th id='countdown'>15</th></table><br>"
wprint "<div><textarea name='cmd1s' cols='70' rows='14'></textarea></div><br>"
wprint "<div><textarea name='cmd2s' cols='70' rows='6'></textarea></div><br>"
wprint "<div><table bgcolor='Yellow' border='1' cellpadding='5'>"
wprint "<tr><th>Sensor</th><th>TempC</th><th>TempF</th><th>PPMcntr</th><th>PPM__</th><th>Adj__1</th><th>Adj__2</th></tr>"
wprint "<tr><td>DS18B20P</td><td>"
wprint htmlvar(cdeg0)
wprint "</td><td>"
wprint htmlvar(fdeg0)
wprint "</td><td>"
wprint htmlvar(apc0)
wprint "</td><td>"
wprint htmlvar(ppm0)
wprint "</td><td>"
wprint htmlvar(adj1)
wprint "</td><td>"
wprint htmlvar(adj2)
wprint "</td></tr>"
wprint "<tr><th>Probe-K</th><th>Pool-PH</th><th>PH-Adj</th><th>ADC Value</th></tr>"
wprint "<tr><td>01.0</td><td>7.0</td><td>7</td><td bgcolor='Red'>"
wprint htmlvar(adc_value)
wprint "</td></tr></table></div><br>"
button "BLINK" [BLINK]
button "RD_ADC" [RDA.DC]
button "TEMP_DN" [TEMP.DN]
button "TEMP_UP" [TEMP.UP]
button "F_Deg" [Fdeg]
button "ForNxt" [ForNext]
button "EyeOpn" [EyeOpen]
button "EyeClo" [EyeClose]
WPRINT "<BR>CMD:"
textbox mycommand
button "SUBMIT" [SUBMIT.BRANCH]
wprint "<br>
wait
[BLINK]
if Ipage == B_Clo then Ipage = B_Opn else Ipage = B_Clo
serialprintln "setting cnt = '1' "
cnt = "1"
if cnt == "1" then SERIALPRINTLN "1"
if cnt == "2" then SERIALPRINTLN "2"
serialprintln "cnt still = '1' why print 2 "
SERIALPRINTLN Ipage
wait
[RDA.DC]
AI adc_value
SERIALPRINTLN "you clicked rda dc"
SERIALPRINTLN adc_value
wait
[TEMP.DN]
SERIALPRINTLN "you clicked temp dn"
cdeg0 = cdeg0 - 0.1
fdeg0 = cdeg0 * 1.8
fdeg0 = fdeg0 + 32
ppm0 = ppm0 - 1
apc0 = apc0 - 1
adj1 = adj1 - 1
adj2 = adj2 - 1
wait
[TEMP.UP]
SERIALPRINTLN "you clicked temp up"
cdeg0 = cdeg0 + 0.1
fdeg0 = cdeg0 * 1.8
fdeg0 = fdeg0 + 32
ppm0 = ppm0 + 1
apc0 = apc0 + 1
adj1 = adj1 + 1
adj2 = adj2 + 1
wait
[Fdeg]
fdeg0 = cdeg0 * 1.8
fdeg0 = fdeg0 + 32
serialprintln fdeg0
wait
[ForNext]
for x = 1 to 5
if x = 1 then serialprintln "pass 1"
if x = 2 then serialprintln "pass 2"
if x = 3 then serialprintln "pass 3"
if x = 4 then serialprintln "pass 4"
if x = 5 then serialprintln "pass 5"
next x
[EyeOpen]
Ipage = 'http://i.imgur.com/kzt3tO8.png'
SERIALPRINTLN Ipage
wait
[EyeClose]
Ipage = 'http://i.imgur.com/KS1dPa7.png'
SERIALPRINTLN Ipage
wait
[SUBMIT.BRANCH]
SERIALPRINTLN mycommand
wait