mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-25 03:29:58 -07:00
Merge branch 'dev' of https://github.com/Next-Flip/Momentum-Firmware into dev
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
let blebeacon = require("blebeacon");
|
||||
|
||||
// Stop if previous background beacon is active
|
||||
if (blebeacon.isActive()) {
|
||||
blebeacon.stop();
|
||||
}
|
||||
|
||||
// Make sure it resets at script exit, true will keep advertising in background
|
||||
// This is false by default, can be omitted
|
||||
blebeacon.keepAlive(false);
|
||||
|
||||
|
||||
let math = require("math");
|
||||
|
||||
let currentIndex = 0;
|
||||
let watchValues = [
|
||||
0x1A, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
|
||||
0x09, 0x0A, 0x0B, 0x0C, 0x11, 0x12, 0x13, 0x14, 0x15,
|
||||
0x16, 0x17, 0x18, 0xE4, 0xE5, 0x1B, 0x1C, 0x1D, 0x1E,
|
||||
0x20, 0xEC, 0xEF
|
||||
];
|
||||
|
||||
function generateRandomMac() {
|
||||
let mac = [];
|
||||
for (let i = 0; i < 6; i++) {
|
||||
mac.push(math.floor(math.random() * 256));
|
||||
}
|
||||
return Uint8Array(mac);
|
||||
}
|
||||
|
||||
function sendRandomModelAdvertisement() {
|
||||
let model = watchValues[currentIndex];
|
||||
|
||||
let packet = [
|
||||
14, 0xFF, 0x75, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0xFF, 0x00, 0x00, 0x43,
|
||||
model
|
||||
];
|
||||
|
||||
let intervalMs = 50;
|
||||
|
||||
// Power level, min interval and max interval are optional
|
||||
blebeacon.setConfig(generateRandomMac(), 0x1F, intervalMs, intervalMs * 3);
|
||||
|
||||
blebeacon.setData(Uint8Array(packet));
|
||||
|
||||
blebeacon.start();
|
||||
|
||||
print("Sent data for model ID " + to_string(model));
|
||||
|
||||
currentIndex = (currentIndex + 1) % watchValues.length;
|
||||
|
||||
delay(intervalMs);
|
||||
|
||||
blebeacon.stop();
|
||||
}
|
||||
|
||||
while (true) {
|
||||
sendRandomModelAdvertisement();
|
||||
}
|
||||
19
applications/system/js_app/examples/apps/Scripts/keyboard.js
Normal file
19
applications/system/js_app/examples/apps/Scripts/keyboard.js
Normal file
@@ -0,0 +1,19 @@
|
||||
let keyboard = require("keyboard");
|
||||
|
||||
keyboard.setHeader("Example Text Input");
|
||||
|
||||
// Default text is optional
|
||||
let text = keyboard.text(100, "Default text", true);
|
||||
print("Got text:", text);
|
||||
|
||||
keyboard.setHeader("Example Byte Input");
|
||||
|
||||
// Default data is optional
|
||||
let data = keyboard.byte(6, Uint8Array([1, 2, 3, 4, 5, 6]));
|
||||
data = Uint8Array(data);
|
||||
let result = "0x";
|
||||
for (let i = 0; i < data.byteLength; i++) {
|
||||
if (data[i] < 0x10) result += "0";
|
||||
result += to_hex_string(data[i]);
|
||||
}
|
||||
print("Got data:", result);
|
||||
47
applications/system/js_app/examples/apps/Scripts/math.js
Normal file
47
applications/system/js_app/examples/apps/Scripts/math.js
Normal file
@@ -0,0 +1,47 @@
|
||||
let math = require("math");
|
||||
|
||||
let absResult = math.abs(-5);
|
||||
let acosResult = math.acos(0.5);
|
||||
let acoshResult = math.acosh(2);
|
||||
let asinResult = math.asin(0.5);
|
||||
let asinhResult = math.asinh(2);
|
||||
let atanResult = math.atan(1);
|
||||
let atan2Result = math.atan2(1, 1);
|
||||
let atanhResult = math.atanh(0.5);
|
||||
let cbrtResult = math.cbrt(27);
|
||||
let ceilResult = math.ceil(5.3);
|
||||
let clz32Result = math.clz32(1);
|
||||
let cosResult = math.cos(math.PI);
|
||||
let expResult = math.exp(1);
|
||||
let floorResult = math.floor(5.7);
|
||||
let maxResult = math.max(3, 5);
|
||||
let minResult = math.min(3, 5);
|
||||
let powResult = math.pow(2, 3);
|
||||
let randomResult = math.random();
|
||||
let signResult = math.sign(-5);
|
||||
let sinResult = math.sin(math.PI / 2);
|
||||
let sqrtResult = math.sqrt(25);
|
||||
let truncResult = math.trunc(5.7);
|
||||
|
||||
print("math.abs(-5):", absResult);
|
||||
print("math.acos(0.5):", acosResult);
|
||||
print("math.acosh(2):", acoshResult);
|
||||
print("math.asin(0.5):", asinResult);
|
||||
print("math.asinh(2):", asinhResult);
|
||||
print("math.atan(1):", atanResult);
|
||||
print("math.atan2(1, 1):", atan2Result);
|
||||
print("math.atanh(0.5):", atanhResult);
|
||||
print("math.cbrt(27):", cbrtResult);
|
||||
print("math.ceil(5.3):", ceilResult);
|
||||
print("math.clz32(1):", clz32Result);
|
||||
print("math.cos(math.PI):", cosResult);
|
||||
print("math.exp(1):", expResult);
|
||||
print("math.floor(5.7):", floorResult);
|
||||
print("math.max(3, 5):", maxResult);
|
||||
print("math.min(3, 5):", minResult);
|
||||
print("math.pow(2, 3):", powResult);
|
||||
print("math.random():", randomResult);
|
||||
print("math.sign(-5):", signResult);
|
||||
print("math.sin(math.PI/2):", sinResult);
|
||||
print("math.sqrt(25):", sqrtResult);
|
||||
print("math.trunc(5.7):", truncResult);
|
||||
@@ -8,4 +8,4 @@ submenu.setHeader("Select an option:");
|
||||
|
||||
let result = submenu.show();
|
||||
|
||||
print("Result: ", result);
|
||||
print("Result:", result);
|
||||
|
||||
Reference in New Issue
Block a user