mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-25 03:29:58 -07:00
js modules updates
by Willy-JL and Sil333033
This commit is contained in:
@@ -7,13 +7,16 @@ let dialog_params = ({
|
||||
header: "Test_header",
|
||||
text: "Test_text",
|
||||
button_left: "Left",
|
||||
button_right: "Right",
|
||||
button_right: "Files",
|
||||
button_center: "OK"
|
||||
});
|
||||
|
||||
let result2 = dialog.custom(dialog_params);
|
||||
if (result2 === "") {
|
||||
print("Back is pressed");
|
||||
} else if (result2 === "Files") {
|
||||
let result3 = dialog.pickFile("/ext", "*");
|
||||
print("Selected", result3);
|
||||
} else {
|
||||
print(result2, "is pressed");
|
||||
}
|
||||
|
||||
62
applications/system/js_app/examples/apps/Scripts/gpio.js
Normal file
62
applications/system/js_app/examples/apps/Scripts/gpio.js
Normal file
@@ -0,0 +1,62 @@
|
||||
let gpio = require("gpio");
|
||||
|
||||
// initialize pins
|
||||
gpio.init("PC3", "outputPushPull", "up"); // pin, mode, pull
|
||||
print("PC3 is initialized as outputPushPull with pull-up");
|
||||
|
||||
gpio.init("PC1", "input", "down"); // pin, mode, pull
|
||||
print("PC1 is initialized as input with pull-down");
|
||||
|
||||
// let led on PC3 blink
|
||||
gpio.write("PC3", true); // high
|
||||
delay(1000);
|
||||
gpio.write("PC3", false); // low
|
||||
delay(1000);
|
||||
gpio.write("PC3", true); // high
|
||||
delay(1000);
|
||||
gpio.write("PC3", false); // low
|
||||
|
||||
// read value from PC1 and write it to PC3
|
||||
while (true) {
|
||||
let value = gpio.read("PC1");
|
||||
gpio.write("PC3", value);
|
||||
|
||||
value ? print("PC1 is high") : print("PC1 is low");
|
||||
|
||||
delay(100);
|
||||
}
|
||||
|
||||
|
||||
// possible pins https://docs.flipper.net/gpio-and-modules#miFsS
|
||||
// "PA7" aka 2
|
||||
// "PA6" aka 3
|
||||
// "PA4" aka 4
|
||||
// "PB3" aka 5
|
||||
// "PB2" aka 6
|
||||
// "PC3" aka 7
|
||||
// "PA14" aka 10
|
||||
// "PA13" aka 12
|
||||
// "PB6" aka 13
|
||||
// "PB7" aka 14
|
||||
// "PC1" aka 15
|
||||
// "PC0" aka 16
|
||||
// "PB14" aka 17
|
||||
|
||||
// possible modes
|
||||
// "input"
|
||||
// "outputPushPull"
|
||||
// "outputOpenDrain"
|
||||
// "altFunctionPushPull"
|
||||
// "altFunctionOpenDrain"
|
||||
// "analog"
|
||||
// "interruptRise"
|
||||
// "interruptFall"
|
||||
// "interruptRiseFall"
|
||||
// "eventRise"
|
||||
// "eventFall"
|
||||
// "eventRiseFall"
|
||||
|
||||
// possible pull
|
||||
// "no"
|
||||
// "up"
|
||||
// "down"
|
||||
Reference in New Issue
Block a user