function setDisplayMode(displaymode) {
print("setDisplayMode: ", displaymode);
switch (displaymode) {
case "switchToConnected":
Pixl.menu();
break;
case "connecting":
if (timer!==-1) {clearInterval(timer); timer = -1;}
Pixl.menu();
connect();
break;
case "livedata":
print("livedata");
Pixl.menu();
if (timer==-1) {
print("Set timer");
timer = setInterval( function () {showLiveData(); }, 1000);
print("timer = ", timer);
}
break;
case "menu":
if (timer!==-1) {clearInterval(timer); timer = -1;}
m=Pixl.menu(mainmenu);
g.setFont8x12();
m.draw();
}
}
gives me this runtime error?
>setDisplayMode: menu
=undefined
setDisplayMode: connecting
Starting scan...
Uncaught SyntaxError: BREAK statement outside of SWITCH, FOR or WHILE loop
at line 119 col 12
break;
^
in function "setDisplayMode" called from line 1 col 28
setDisplayMode("connecting");
^
in function "b" called from line 1 col 48
var b=d[c[a.selected]];"function"==typeof b&&b()
^
in function "select" called from line 1 col 10
b.select()
^
in function called from system
I looked it up a hundred times, this should be correct switch/case syntax, or is it not?
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,
anyone knows why this code
gives me this runtime error?
I looked it up a hundred times, this should be correct switch/case syntax, or is it not?