mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-11-28 19:36:36 +03:00
upd examples
This commit is contained in:
parent
79caf7bf72
commit
462ab255a1
@ -1,3 +1,6 @@
|
|||||||
|
// Script cannot work without blebeacon module so check before
|
||||||
|
checkSdkFeatures(["blebeacon"]);
|
||||||
|
|
||||||
let blebeacon = require("blebeacon");
|
let blebeacon = require("blebeacon");
|
||||||
|
|
||||||
// Stop if previous background beacon is active
|
// Stop if previous background beacon is active
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Script cannot work without i2c module so check before
|
||||||
|
checkSdkFeatures(["i2c"]);
|
||||||
|
|
||||||
// Connect an 24C32N EEPROM to the I2C bus of the board. SDA=pin 15, SCL=pin 16, VCC=pin 9, GND=pin 8.
|
// Connect an 24C32N EEPROM to the I2C bus of the board. SDA=pin 15, SCL=pin 16, VCC=pin 9, GND=pin 8.
|
||||||
let i2c = require("i2c");
|
let i2c = require("i2c");
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Script cannot work without spi module so check before
|
||||||
|
checkSdkFeatures(["spi"]);
|
||||||
|
|
||||||
// Connect a w25q32 SPI device to the Flipper Zero.
|
// Connect a w25q32 SPI device to the Flipper Zero.
|
||||||
// D1=pin 2 (MOSI), SLK=pin 5 (SCK), GND=pin 8 (GND), D0=pin 3 (MISO), CS=pin 4 (CS), VCC=pin 9 (3V3)
|
// D1=pin 2 (MOSI), SLK=pin 5 (SCK), GND=pin 8 (GND), D0=pin 3 (MISO), CS=pin 4 (CS), VCC=pin 9 (3V3)
|
||||||
let spi = require("spi");
|
let spi = require("spi");
|
||||||
@ -5,8 +8,9 @@ let spi = require("spi");
|
|||||||
// Display textbox so user can scroll to see all output.
|
// Display textbox so user can scroll to see all output.
|
||||||
let eventLoop = require("event_loop");
|
let eventLoop = require("event_loop");
|
||||||
let gui = require("gui");
|
let gui = require("gui");
|
||||||
|
let textBoxView = require("gui/text_box");
|
||||||
let text = "SPI demo\n";
|
let text = "SPI demo\n";
|
||||||
let textBox = require("gui/text_box").makeWith({
|
let textBox = textBoxView.makeWith({
|
||||||
focus: "end",
|
focus: "end",
|
||||||
font: "text",
|
font: "text",
|
||||||
text: text,
|
text: text,
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Script cannot work without subghz module so check before
|
||||||
|
checkSdkFeatures(["subghz"]);
|
||||||
|
|
||||||
let subghz = require("subghz");
|
let subghz = require("subghz");
|
||||||
subghz.setup();
|
subghz.setup();
|
||||||
|
|
||||||
|
@ -1,10 +1,39 @@
|
|||||||
|
// Script cannot work without usbdisk module so check before
|
||||||
|
checkSdkFeatures(["usbdisk"]);
|
||||||
|
|
||||||
let usbdisk = require("usbdisk");
|
let usbdisk = require("usbdisk");
|
||||||
|
let storage = require("storage");
|
||||||
|
|
||||||
|
let imagePath = "/ext/apps_data/mass_storage/128MB.img";
|
||||||
|
let imageSize = 128 * 1024 * 1024;
|
||||||
|
|
||||||
|
let imageExisted = storage.fileExists(imagePath);
|
||||||
|
if (imageExisted) {
|
||||||
|
print("Disk image '128MB' already exists");
|
||||||
|
} else {
|
||||||
|
// CreateImage isn't necessary to overall function, check when its used not at script start
|
||||||
|
if (doesSdkSupport(["usbdisk-createimage"])) {
|
||||||
|
print("Creating disk image '128MB'...");
|
||||||
|
usbdisk.createImage(imagePath, imageSize);
|
||||||
|
} else {
|
||||||
|
die("Disk image '128MB' not present, can't auto-create");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
print("Starting UsbDisk...");
|
print("Starting UsbDisk...");
|
||||||
usbdisk.start("/ext/apps_data/mass_storage/128MB.img");
|
usbdisk.start("/ext/apps_data/mass_storage/128MB.img");
|
||||||
|
|
||||||
print("Started, waiting until ejected...");
|
print("Started, waiting until ejected...");
|
||||||
while (!usbdisk.wasEjected()) {
|
while (!usbdisk.wasEjected()) {
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
print("Ejected, stopping UsbDisk...");
|
print("Ejected, stopping UsbDisk...");
|
||||||
usbdisk.stop();
|
usbdisk.stop();
|
||||||
|
|
||||||
|
if (!imageExisted) {
|
||||||
|
print("Removing disk image...");
|
||||||
|
storage.remove(imagePath);
|
||||||
|
}
|
||||||
|
|
||||||
print("Done");
|
print("Done");
|
@ -1,17 +1,20 @@
|
|||||||
|
// Script cannot work without widget module so check before
|
||||||
|
checkSdkFeatures(["widget"]);
|
||||||
|
|
||||||
let widget = require("widget");
|
let widget = require("widget");
|
||||||
|
|
||||||
let demo_seconds = 30;
|
let demo_seconds = 30;
|
||||||
|
|
||||||
print("Loading file", __filepath);
|
print("Loading file", __filename);
|
||||||
print("From directory", __dirpath);
|
print("From directory", __dirname);
|
||||||
|
|
||||||
// addText supports "Primary" and "Secondary" font sizes.
|
// addText supports "Primary" and "Secondary" font sizes.
|
||||||
widget.addText(10, 10, "Primary", "Example JS widget");
|
widget.addText(10, 10, "Primary", "Example JS widget");
|
||||||
widget.addText(10, 20, "Secondary", "Example widget from JS!");
|
widget.addText(10, 20, "Secondary", "Example widget from JS!");
|
||||||
|
|
||||||
// load a Xbm file from the same directory as this script.
|
// load a Xbm file from the same directory as this script.
|
||||||
widget.addText(0, 30, "Secondary", __filepath);
|
widget.addText(0, 30, "Secondary", __filename);
|
||||||
let logo = widget.loadImageXbm(__dirpath + "/widget-js.fxbm");
|
let logo = widget.loadImageXbm(__dirname + "/widget-js.fxbm");
|
||||||
|
|
||||||
// add a line (x1, y1, x2, y2)
|
// add a line (x1, y1, x2, y2)
|
||||||
widget.addLine(10, 35, 120, 35);
|
widget.addLine(10, 35, 120, 35);
|
||||||
|
Loading…
Reference in New Issue
Block a user