Report Bugs Here

Moderator: Mmiscool

User avatar
By xtal
#32742 You are assuming I know something about Java Script . I just cut/snip/tried until I got it to work.
This code has worked on previous versions, just not consistantly.

This is implying that we are short on memory, if this is the case, I better stick with lua.

I can cut/snip and store, but don't know how to invoke from within the HTML.
User avatar
By Mmiscool
#32769 I just ran the attached code.

Had to make sure there were spaces in the variable setting code at the top. Also did a new build today. Fix non working pwm from a previous change.


I also removed all of the "form" stuff as all the gui widgets are built in to the basic commands.


Code: Select allmycommand = " "

rfctr = 0
adc_id = 0
adc_value = 512
k1 = 0.11
p00 = 'P'
apc0 = '11111'
ppm0 = '1770'
cdeg0 = '25.1'

kta0 = '0.01'
lo0 = '12'
hi0 = '20'
prb = '01.0'
ph = '7.0'
sbuf = ""

rfh = '15'
Ipage = 'http://i.imgur.com/KS1dPa7.png'


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='http://i.imgur.com/KS1dPa7.png' 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>25.9</td><td>78.6</td><td>43708</td><td>1676</td><td>1644.9</td><td>1644.2</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'>902</td></tr></table></div><br>"


button "BLINK" [BLINK]
button "RD_ADC" [RDA.DC]
button "TEMP_DN" [TEMP.DN]
button "TEMP_UP" [TEMP.UP]
WPRINT "<BR>CMD:"
textbox mycommand
button "SUBMIT" [SUBMIT.BRANCH]
wprint "<br>
wait



[BLINK]
print "you clicked blink"
wait

[RDA.DC]
print "you clicked rda dc"
wait

[TEMP.DN]
print "you clicked temp dn"
wait

[TEMP.UP]
print "you clicked temp up"
wait

[SUBMIT.BRANCH]
PRINT mycommand
wait


You do not have the required permissions to view the files attached to this post.
User avatar
By xtal
#32782 Thx for the rewrite & update

#1 I cannot SAVE the code to a desired NAME unless I try to open the NAME before SAVE else it saves as default....
#2 after save and display Wpage going to EDIT then open NAME I see code intermixed with Wpage
#3 Its taking 50+ seconds to save and open , seems like a ling time compared to nodemcu
#4 Submit.Branch does not display for me
After a reload it now works.......BUT
I only want the data to go out serial port ??????? Found SERIALPRINTLN
Added the following
Code: Select allIpage = 'http://i.imgur.com/KS1dPa7.png'
B_Opn = 'http://i.imgur.com/kzt3tO8.png'
B_Clo = 'http://i.imgur.com/KS1dPa7.png'
and changed

[BLINK]
  if Ipage == B_Clo then
    Ipage = B_Opn
  else
    Ipage = B_Clo
  endif
SERIALPRINTLN Ipage
wait
AND
wprint "<td><IMG SRC=Ipage LEFT='1' WIDTH='120' HEIGHT='60' BORDER='1'></td>"

Now my pretty picture no longer displays DO YOU HAVE ANY IDEA ON THIS ?
--I embeded wprint |Ipage| got the image back , but unable to change with blink code????

Now pressing BLINK -- Done... prints out Ipage does not! and buttons no longer work
other buttons seem ok until I click BLINK
Is the added IF done correctly? Does this code need some sort of REPEAT ??

How much memory is left I need to input serial data to alter the vars
Does this basic handle FLOAT ??
How do you Read ADC?? Tried AI adc_value ..this didn't work ??

again thx for the mod....
Last edited by xtal on Sun Nov 01, 2015 7:51 pm, edited 2 times in total.
User avatar
By Mmiscool
#32785 if then statements spanning multiple lines are not supported right now.

Also to embed a variable in the page you must use the htmvar() function. This will make it so that each time the page is refreshed the variable will paced in the page.


Code: Select allIpage = 'http://i.imgur.com/KS1dPa7.png'
B_Opn = 'http://i.imgur.com/kzt3tO8.png '
B_Clo = 'http://i.imgur.com/KS1dPa7.png'

[BLINK]
  if len(Ipage) = len(B_Clo) then  Ipage = B_Opn else Ipage = B_Clo
wait



wprint "<td><IMG SRC="
wprint htmlvar(Ipage)
wprint " LEFT='1' WIDTH='120' HEIGHT='60' BORDER='1'></td>"