A little example with Neopixel leds
Posted: Sat Mar 05, 2016 10:20 am
]Hi all,
this is not really a project but more as an example of what can be done with ESP Basic.
This example is a simply web page that permit to control the color of a WS2812B stripline.
Nothing complicated, I know, but the example is more for how is done.
In fact is a combination of css, javascript and basic permitting to control the mix of colors.
This is the basic code :
[start]
cls
css "display.css"
wprint |<title>NeoPixel Text</title>|
wprint |<form>|
wprint |<head>|
wprint |<script type="text/javascript" src="/file?file=neo.js">"></script>|
wprint |</head>|
wprint |<script> initme(); WritePage(); </script>|
wprint |</form>|
msgbranch [messaggio]
wait
[messaggio]
msgget "color" mess
if mess == "@EX_IT@" then end
'serialprintln mess
let red = mid(mess,8,3)
let green = mid(mess,12,3)
let blue = mid(mess,16,3)
neostripcolor(0,29,red,green,blue)
wait
There is a javascript code (attached) and a css file (attached too).
As you can see the basic code is very "basic", only few lines.
The web page is created into the javascript and styled with the .css .
In fact all the communication is based on AJAX.
Don't be scared, nothing complicated.
What happens is that, each time a slider is moved or the button "Set Color" is pressed, the javascript make a direct "ajax" request to the basic sending the color; this is achieved with the command "msgbranch [messaggio]" that "jumps" to the label [messaggio].
After that, you can recover the value sent by the javascript with the command 'msgget "color" mess'.
Sorry, I forgot to say that this page is optimized for the I-phone 6 and Google Chrome.
Regards,
Cicciocb
this is not really a project but more as an example of what can be done with ESP Basic.
This example is a simply web page that permit to control the color of a WS2812B stripline.
Nothing complicated, I know, but the example is more for how is done.
In fact is a combination of css, javascript and basic permitting to control the mix of colors.
This is the basic code :
[start]
cls
css "display.css"
wprint |<title>NeoPixel Text</title>|
wprint |<form>|
wprint |<head>|
wprint |<script type="text/javascript" src="/file?file=neo.js">"></script>|
wprint |</head>|
wprint |<script> initme(); WritePage(); </script>|
wprint |</form>|
msgbranch [messaggio]
wait
[messaggio]
msgget "color" mess
if mess == "@EX_IT@" then end
'serialprintln mess
let red = mid(mess,8,3)
let green = mid(mess,12,3)
let blue = mid(mess,16,3)
neostripcolor(0,29,red,green,blue)
wait
There is a javascript code (attached) and a css file (attached too).
As you can see the basic code is very "basic", only few lines.
The web page is created into the javascript and styled with the .css .
In fact all the communication is based on AJAX.
Don't be scared, nothing complicated.
What happens is that, each time a slider is moved or the button "Set Color" is pressed, the javascript make a direct "ajax" request to the basic sending the color; this is achieved with the command "msgbranch [messaggio]" that "jumps" to the label [messaggio].
After that, you can recover the value sent by the javascript with the command 'msgget "color" mess'.
Sorry, I forgot to say that this page is optimized for the I-phone 6 and Google Chrome.
Regards,
Cicciocb