1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-13 13:09:49 +04:00

js modules updates 2

by Willy-JL
This commit is contained in:
MX
2024-03-23 23:48:55 +03:00
parent 385c3c1c01
commit aaa7c81f99
5 changed files with 133 additions and 19 deletions

View File

@@ -1,11 +1,15 @@
let textbox = require("textbox");
// Set config before setting text
// You should set config before adding text
// Focus (start / end), Font (text / hex)
textbox.setConfig("end", "text");
let text = "Example dynamic updating textbox\n";
textbox.setText(text);
// Can make sure it's empty before showing, in case of reusing in same script
// (Closing textbox already empties the text, but maybe you added more in a loop for example)
textbox.emptyText();
// Add default text
textbox.addText("Example dynamic updating textbox\n");
// Non-blocking, can keep updating text after, can close in JS or in GUI
textbox.show();
@@ -13,8 +17,10 @@ textbox.show();
let i = 0;
while (textbox.isOpen() && i < 20) {
print("console", i++);
text += "textbox " + to_string(i) + "\n";
textbox.setText(text);
// Add text to textbox buffer
textbox.addText("textbox " + to_string(i) + "\n");
delay(500);
}

View File

@@ -8,4 +8,7 @@ while (1) {
let data_view = Uint8Array(rx_data);
print("0x" + to_hex_string(data_view[0]));
}
}
}
// There's also serial.end(), so you can serial.setup() again in same script
// You can also use serial.readAny(timeout), will avoid starving your loop with single byte reads