Hi! You should be able to specify a callback for onchange, like you had done in Line 23:
onchange
b:TD.button({x:10,y:290,width:200,height:100,label:"Press Me",value:0,name:"button",onchange:function(e){o.log.log("Pressed!");}}),
If you change that to:
onchange:function(e){ws.send("Button press");}
and also ensure that you remove the other var ws to make ws global with:
var ws
ws
var ws; setTimeout(function() { ws = new WebSocket('ws://192.168.25.4:8000',"protocolOne");
Then you should be able to get something running :)
Also, not all the examples use it yet, but template strings are a really nice way of inlining HTML code in JS:
var page = `<html> <body> ..... ... </html>`;
@Gordon started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi! You should be able to specify a callback for
onchange
, like you had done in Line 23:If you change that to:
and also ensure that you remove the other
var ws
to makews
global with:Then you should be able to get something running :)
Also, not all the examples use it yet, but template strings are a really nice way of inlining HTML code in JS: