mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Merge remote-tracking branch 'ofw/dev' into mntm-dev
This commit is contained in:
@@ -19,8 +19,8 @@ let jsLogo = icon.getBuiltin("js_script_10px");
|
||||
let stopwatchWidgetElements = [
|
||||
{ element: "string", x: 67, y: 44, align: "bl", font: "big_numbers", text: "00 00" },
|
||||
{ element: "string", x: 77, y: 22, align: "bl", font: "primary", text: "Stopwatch" },
|
||||
{ element: "frame", x: 64, y: 27, w: 28, h: 20, radius: 3 },
|
||||
{ element: "frame", x: 100, y: 27, w: 28, h: 20, radius: 3 },
|
||||
{ element: "rect", x: 64, y: 27, w: 28, h: 20, radius: 3, fill: false },
|
||||
{ element: "rect", x: 100, y: 27, w: 28, h: 20, radius: 3, fill: false },
|
||||
{ element: "icon", x: 0, y: 5, iconData: cuteDolphinWithWatch },
|
||||
{ element: "icon", x: 64, y: 13, iconData: jsLogo },
|
||||
{ element: "button", button: "right", text: "Back" },
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// This script is like uart_echo, except it uses 8E1 framing (8 data bits, even
|
||||
// parity, 1 stop bit) as opposed to the default 8N1 (8 data bits, no parity,
|
||||
// 1 stop bit)
|
||||
|
||||
let serial = require("serial");
|
||||
serial.setup("usart", 230400, { dataBits: "8", parity: "even", stopBits: "1" });
|
||||
|
||||
while (1) {
|
||||
let rx_data = serial.readBytes(1, 1000);
|
||||
if (rx_data !== undefined) {
|
||||
serial.write(rx_data);
|
||||
let data_view = Uint8Array(rx_data);
|
||||
print("0x" + data_view[0].toString(16));
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,70 +0,0 @@
|
||||
// Script cannot work without widget module so check before
|
||||
checkSdkFeatures(["widget"]);
|
||||
|
||||
let widget = require("widget");
|
||||
|
||||
let demo_seconds = 30;
|
||||
|
||||
print("Loading file", __filename);
|
||||
print("From directory", __dirname);
|
||||
|
||||
// addText supports "Primary" and "Secondary" font sizes.
|
||||
widget.addText(10, 10, "Primary", "Example JS widget");
|
||||
widget.addText(10, 20, "Secondary", "Example widget from JS!");
|
||||
|
||||
// load a Xbm file from the same directory as this script.
|
||||
widget.addText(0, 30, "Secondary", __filename);
|
||||
let logo = widget.loadImageXbm(__dirname + "/widget-js.fxbm");
|
||||
|
||||
// add a line (x1, y1, x2, y2)
|
||||
widget.addLine(10, 35, 120, 35);
|
||||
|
||||
// add a circle/disc (x, y, radius)
|
||||
widget.addCircle(12, 52, 10);
|
||||
widget.addDisc(12, 52, 5);
|
||||
|
||||
// add a frame/box (x, y, width, height)
|
||||
widget.addFrame(30, 45, 10, 10);
|
||||
widget.addBox(32, 47, 6, 6);
|
||||
|
||||
// add a rounded frame/box (x, y, width, height, radius)
|
||||
widget.addRframe(50, 45, 15, 15, 3);
|
||||
widget.addRbox(53, 48, 6, 6, 2);
|
||||
|
||||
// add a dot (x, y)
|
||||
widget.addDot(100, 45);
|
||||
widget.addDot(102, 44);
|
||||
widget.addDot(104, 43);
|
||||
|
||||
// add an icon (x, y, icon)
|
||||
// not available in all firmwares, but not essential for this script's
|
||||
// functionality, so we just check at runtime and use it if it is available
|
||||
if (doesSdkSupport(["widget-addicon"])) {
|
||||
widget.addIcon(100, 50, "ButtonUp_7x4");
|
||||
widget.addIcon(100, 55, "ButtonDown_7x4");
|
||||
}
|
||||
|
||||
// add a glyph (x, y, glyph)
|
||||
widget.addGlyph(115, 50, "#".charCodeAt(0));
|
||||
|
||||
// Show the widget (drawing the layers in the orderer they were added)
|
||||
widget.show();
|
||||
|
||||
let i = 1;
|
||||
let bitmap = undefined;
|
||||
while (widget.isOpen() && i <= demo_seconds) {
|
||||
// Print statements will only show up once the widget is closed.
|
||||
print("count is at", i++);
|
||||
|
||||
// You can call remove on any added item, it does not impact the other ids.
|
||||
if (bitmap) { widget.remove(bitmap); bitmap = undefined; }
|
||||
// All of the addXXX functions return an id that can be used to remove the item.
|
||||
else { bitmap = widget.addXbm(77, 45, logo); }
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
// If user did not press the back button, close the widget.
|
||||
if (widget.isOpen()) {
|
||||
widget.close();
|
||||
}
|
||||
Reference in New Issue
Block a user