Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ESP2866

Status
Not open for further replies.

be80be

Well-Known Member
Maybe some one on here knows a little about HTML and LUA . I been playing with this thing for weeks now and learn somethings about this but for some reason I can't get this part figured out. I figured how Lua loads the web page and made a slider that outputs the value of 0 to 100 in 10 steps 0 10 20 so on.
using the debug window in chrome I can see where the value is changing in code but can't for the life of me figure how to cast it to a variable that I can read back to the esp2866 server. Here the code it makes a nice slider on my little server.
Code:
-- create a server
    -- 30s time out for a inactive client
    sv=net.createServer(net.TCP, 30)  

    -- server listen on 80,
    -- if data received, print data to console,
    -- then send "hello world" to remote.
    sv:listen(80,function(c)
      c:on("receive", function(c,result)
         print(result)
      end)
     
c:send('<!DOCTYPE html>\n')
c:send('<html xmlns="http://www.w3.org/1999/xhtml">\n')
c:send('<head>\n')
c:send('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n')
c:send('<title> HTML5 Slider </title>\n')
c:send('<script type="text/javascript">\n')
  c:send('function showValue(num){\n')
  c:send('var result = document.getElementById("result");\n')    
  c:send('result.innerHTML = num;\n')
  c:send('}\n')
  c:send('</script>\n')
  c:send('</head>\n')
  c:send('<body>\n')
  c:send('<input type="range" id="sliderBar" min="0" max="100" step="10" value="0" onChange="showValue(this.value);"/>\n')
  c:send('<div id="result" style="height:20px;width:30px;border:1px solid #999">\n') --this is where it shows the value on chrome
  c:send('</div>\n')
  c:send('</body>\n')
  c:send('</html>\n')
 
    end)
Where value showing a change
Code:
c:send('<div id="result" style="height:20px;width:30px;border:1px solid #999">\n') --this is where it shows the value on chrome
 
I've look about everything the problem is I don't know everything LOL just enough to get me in to trouble. I read lua and then I look at lua code for the esp2866 and it's not the same val::(XXX) and val:(XXX) lots to learn then you use html and write a function that uses {vav=this.value} and lua thinks your using lua code and lua you cant use stuff with this.value because of the period is not allowed and there god match strings function goes crazy. when you tell it holds the value you want sent back.
 
Ah man, I've recently done quite a bit with the ESP8266, but not with Lua so I can't help.

Definitely a smart little device though.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top