mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 20:49:49 +04:00
Merge remote-tracking branch 'OFW/dev' into dev
This commit is contained in:
@@ -4,12 +4,12 @@ let flipper = require("flipper");
|
|||||||
tests.assert_eq(1337, 1337);
|
tests.assert_eq(1337, 1337);
|
||||||
tests.assert_eq("hello", "hello");
|
tests.assert_eq("hello", "hello");
|
||||||
|
|
||||||
tests.assert_eq("compatible", sdkCompatibilityStatus(0, 1));
|
tests.assert_eq("compatible", sdkCompatibilityStatus(1, 0));
|
||||||
tests.assert_eq("firmwareTooOld", sdkCompatibilityStatus(100500, 0));
|
tests.assert_eq("firmwareTooOld", sdkCompatibilityStatus(100500, 0));
|
||||||
tests.assert_eq("firmwareTooNew", sdkCompatibilityStatus(-100500, 0));
|
tests.assert_eq("firmwareTooNew", sdkCompatibilityStatus(-100500, 0));
|
||||||
tests.assert_eq(true, doesSdkSupport(["baseline"]));
|
tests.assert_eq(true, doesSdkSupport(["baseline"]));
|
||||||
tests.assert_eq(false, doesSdkSupport(["abobus", "other-nonexistent-feature"]));
|
tests.assert_eq(false, doesSdkSupport(["abobus", "other-nonexistent-feature"]));
|
||||||
|
|
||||||
tests.assert_eq("flipperdevices", flipper.firmwareVendor);
|
tests.assert_eq("flipperdevices", flipper.firmwareVendor);
|
||||||
tests.assert_eq(0, flipper.jsSdkVersion[0]);
|
tests.assert_eq(1, flipper.jsSdkVersion[0]);
|
||||||
tests.assert_eq(3, flipper.jsSdkVersion[1]);
|
tests.assert_eq(0, flipper.jsSdkVersion[1]);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ let filePicker = require("gui/file_picker");
|
|||||||
let widget = require("gui/widget");
|
let widget = require("gui/widget");
|
||||||
let icon = require("gui/icon");
|
let icon = require("gui/icon");
|
||||||
let flipper = require("flipper");
|
let flipper = require("flipper");
|
||||||
|
let math = require("math");
|
||||||
|
|
||||||
// declare clock widget children
|
// declare clock widget children
|
||||||
let cuteDolphinWithWatch = icon.getBuiltin("DolphinWait_59x54");
|
let cuteDolphinWithWatch = icon.getBuiltin("DolphinWait_59x54");
|
||||||
@@ -144,7 +145,7 @@ eventLoop.subscribe(views.stopwatchWidget.button, function (_sub, buttonEvent, g
|
|||||||
|
|
||||||
// count time
|
// count time
|
||||||
eventLoop.subscribe(eventLoop.timer("periodic", 500), function (_sub, _item, views, stopwatchWidgetElements, halfSeconds) {
|
eventLoop.subscribe(eventLoop.timer("periodic", 500), function (_sub, _item, views, stopwatchWidgetElements, halfSeconds) {
|
||||||
let text = (halfSeconds / 2 / 60).toString();
|
let text = math.floor(halfSeconds / 2 / 60).toString();
|
||||||
if (halfSeconds < 10 * 60 * 2)
|
if (halfSeconds < 10 * 60 * 2)
|
||||||
text = "0" + text;
|
text = "0" + text;
|
||||||
|
|
||||||
@@ -152,7 +153,7 @@ eventLoop.subscribe(eventLoop.timer("periodic", 500), function (_sub, _item, vie
|
|||||||
|
|
||||||
if (((halfSeconds / 2) % 60) < 10)
|
if (((halfSeconds / 2) % 60) < 10)
|
||||||
text += "0";
|
text += "0";
|
||||||
text += ((halfSeconds / 2) % 60).toString();
|
text += (math.floor(halfSeconds / 2) % 60).toString();
|
||||||
|
|
||||||
stopwatchWidgetElements[0].text = text;
|
stopwatchWidgetElements[0].text = text;
|
||||||
views.stopwatchWidget.setChildren(stopwatchWidgetElements);
|
views.stopwatchWidget.setChildren(stopwatchWidgetElements);
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define JS_SDK_VENDOR_FIRMWARE "unleashed"
|
#define JS_SDK_VENDOR_FIRMWARE "unleashed"
|
||||||
#define JS_SDK_VENDOR "flipperdevices"
|
#define JS_SDK_VENDOR "flipperdevices"
|
||||||
#define JS_SDK_MAJOR 0
|
#define JS_SDK_MAJOR 1
|
||||||
#define JS_SDK_MINOR 3
|
#define JS_SDK_MINOR 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the foreign pointer in `obj["_"]`
|
* @brief Returns the foreign pointer in `obj["_"]`
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@darkflippers/create-fz-app-ul",
|
"name": "@darkflippers/create-fz-app-ul",
|
||||||
"version": "0.1.1",
|
"version": "0.1.2",
|
||||||
"description": "Template package for JS apps for Flipper Zero using Unleashed Firmware JS SDK",
|
"description": "Template package for JS apps for Flipper Zero using Unleashed Firmware JS SDK",
|
||||||
"bin": "index.js",
|
"bin": "index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"start": "npm run build && node node_modules/@darkflippers/fz-sdk-ul/sdk.js upload"
|
"start": "npm run build && node node_modules/@darkflippers/fz-sdk-ul/sdk.js upload"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@darkflippers/fz-sdk-ul": "^0.3",
|
"@darkflippers/fz-sdk-ul": "^1.0",
|
||||||
"typescript": "^5.6.3"
|
"typescript": "^5.6.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
* @brief Checks compatibility between the script and the JS SDK that the
|
* @brief Checks compatibility between the script and the JS SDK that the
|
||||||
* firmware provides
|
* firmware provides
|
||||||
*
|
*
|
||||||
* @note You're looking at JS SDK v0.3
|
* @note You're looking at JS SDK v1.0
|
||||||
*
|
*
|
||||||
* @param expectedMajor JS SDK major version expected by the script
|
* @param expectedMajor JS SDK major version expected by the script
|
||||||
* @param expectedMinor JS SDK minor version expected by the script
|
* @param expectedMinor JS SDK minor version expected by the script
|
||||||
@@ -92,7 +92,7 @@ declare function sdkCompatibilityStatus(expectedMajor: number, expectedMinor: nu
|
|||||||
* @brief Checks compatibility between the script and the JS SDK that the
|
* @brief Checks compatibility between the script and the JS SDK that the
|
||||||
* firmware provides in a boolean fashion
|
* firmware provides in a boolean fashion
|
||||||
*
|
*
|
||||||
* @note You're looking at JS SDK v0.3
|
* @note You're looking at JS SDK v1.0
|
||||||
*
|
*
|
||||||
* @param expectedMajor JS SDK major version expected by the script
|
* @param expectedMajor JS SDK major version expected by the script
|
||||||
* @param expectedMinor JS SDK minor version expected by the script
|
* @param expectedMinor JS SDK minor version expected by the script
|
||||||
@@ -105,7 +105,7 @@ declare function isSdkCompatible(expectedMajor: number, expectedMinor: number):
|
|||||||
* @brief Asks the user whether to continue executing the script if the versions
|
* @brief Asks the user whether to continue executing the script if the versions
|
||||||
* are not compatible. Does nothing if they are.
|
* are not compatible. Does nothing if they are.
|
||||||
*
|
*
|
||||||
* @note You're looking at JS SDK v0.3
|
* @note You're looking at JS SDK v1.0
|
||||||
*
|
*
|
||||||
* @param expectedMajor JS SDK major version expected by the script
|
* @param expectedMajor JS SDK major version expected by the script
|
||||||
* @param expectedMinor JS SDK minor version expected by the script
|
* @param expectedMinor JS SDK minor version expected by the script
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ export interface Pin {
|
|||||||
* PWM-related methods on this pin will throw an error when called.
|
* PWM-related methods on this pin will throw an error when called.
|
||||||
* @note On Flipper Zero only pins PA4 and PA7 support PWM
|
* @note On Flipper Zero only pins PA4 and PA7 support PWM
|
||||||
* @version Added in JS SDK 0.2, extra feature `"gpio-pwm"`
|
* @version Added in JS SDK 0.2, extra feature `"gpio-pwm"`
|
||||||
|
* @version Baseline since JS SDK 1.0
|
||||||
*/
|
*/
|
||||||
isPwmSupported(): boolean;
|
isPwmSupported(): boolean;
|
||||||
/**
|
/**
|
||||||
@@ -89,18 +90,21 @@ export interface Pin {
|
|||||||
* @param freq Frequency in Hz
|
* @param freq Frequency in Hz
|
||||||
* @param duty Duty cycle in %
|
* @param duty Duty cycle in %
|
||||||
* @version Added in JS SDK 0.2, extra feature `"gpio-pwm"`
|
* @version Added in JS SDK 0.2, extra feature `"gpio-pwm"`
|
||||||
|
* @version Baseline since JS SDK 1.0
|
||||||
*/
|
*/
|
||||||
pwmWrite(freq: number, duty: number): void;
|
pwmWrite(freq: number, duty: number): void;
|
||||||
/**
|
/**
|
||||||
* Determines whether PWM is running. Throws an error if PWM is not
|
* Determines whether PWM is running. Throws an error if PWM is not
|
||||||
* supported on this pin.
|
* supported on this pin.
|
||||||
* @version Added in JS SDK 0.2, extra feature `"gpio-pwm"`
|
* @version Added in JS SDK 0.2, extra feature `"gpio-pwm"`
|
||||||
|
* @version Baseline since JS SDK 1.0
|
||||||
*/
|
*/
|
||||||
isPwmRunning(): boolean;
|
isPwmRunning(): boolean;
|
||||||
/**
|
/**
|
||||||
* Stops PWM. Does not restore previous pin configuration. Throws an error
|
* Stops PWM. Does not restore previous pin configuration. Throws an error
|
||||||
* if PWM is not supported on this pin.
|
* if PWM is not supported on this pin.
|
||||||
* @version Added in JS SDK 0.2, extra feature `"gpio-pwm"`
|
* @version Added in JS SDK 0.2, extra feature `"gpio-pwm"`
|
||||||
|
* @version Baseline since JS SDK 1.0
|
||||||
*/
|
*/
|
||||||
pwmStop(): void;
|
pwmStop(): void;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export type IconData = symbol & { "__tag__": "icon" };
|
|||||||
* Gets a built-in firmware icon for use in GUI
|
* Gets a built-in firmware icon for use in GUI
|
||||||
* @param icon Name of the icon
|
* @param icon Name of the icon
|
||||||
* @version Added in JS SDK 0.2, extra feature `"gui-widget"`
|
* @version Added in JS SDK 0.2, extra feature `"gui-widget"`
|
||||||
|
* @version Baseline since JS SDK 1.0
|
||||||
*/
|
*/
|
||||||
export declare function getBuiltin(icon: BuiltinIcon): IconData;
|
export declare function getBuiltin(icon: BuiltinIcon): IconData;
|
||||||
|
|
||||||
@@ -14,5 +15,6 @@ export declare function getBuiltin(icon: BuiltinIcon): IconData;
|
|||||||
* Loads a .fxbm icon (XBM Flipper sprite, from flipperzero-game-engine) for use in GUI
|
* Loads a .fxbm icon (XBM Flipper sprite, from flipperzero-game-engine) for use in GUI
|
||||||
* @param path Path to the .fxbm file
|
* @param path Path to the .fxbm file
|
||||||
* @version Added in JS SDK 0.3, extra feature `"gui-widget-extras"`
|
* @version Added in JS SDK 0.3, extra feature `"gui-widget-extras"`
|
||||||
|
* @version Baseline since JS SDK 1.0
|
||||||
*/
|
*/
|
||||||
export declare function loadFxbm(path: string): IconData;
|
export declare function loadFxbm(path: string): IconData;
|
||||||
|
|||||||
@@ -133,17 +133,20 @@ export declare class View<Props extends Properties, Child> {
|
|||||||
* Adds a child to the View
|
* Adds a child to the View
|
||||||
* @param child Child to add
|
* @param child Child to add
|
||||||
* @version Added in JS SDK 0.2, extra feature `"gui-widget"`
|
* @version Added in JS SDK 0.2, extra feature `"gui-widget"`
|
||||||
|
* @version Baseline since JS SDK 1.0
|
||||||
*/
|
*/
|
||||||
addChild<C extends Child>(child: C): void;
|
addChild<C extends Child>(child: C): void;
|
||||||
/**
|
/**
|
||||||
* Removes all children from the View
|
* Removes all children from the View
|
||||||
* @version Added in JS SDK 0.2, extra feature `"gui-widget"`
|
* @version Added in JS SDK 0.2, extra feature `"gui-widget"`
|
||||||
|
* @version Baseline since JS SDK 1.0
|
||||||
*/
|
*/
|
||||||
resetChildren(): void;
|
resetChildren(): void;
|
||||||
/**
|
/**
|
||||||
* Removes all previous children from the View and assigns new children
|
* Removes all previous children from the View and assigns new children
|
||||||
* @param children The list of children to assign
|
* @param children The list of children to assign
|
||||||
* @version Added in JS SDK 0.2, extra feature `"gui-widget"`
|
* @version Added in JS SDK 0.2, extra feature `"gui-widget"`
|
||||||
|
* @version Baseline since JS SDK 1.0
|
||||||
*/
|
*/
|
||||||
setChildren(children: Child[]): void;
|
setChildren(children: Child[]): void;
|
||||||
}
|
}
|
||||||
@@ -158,7 +161,9 @@ export declare class ViewFactory<Props extends Properties, Child, V extends View
|
|||||||
* Create view instance with custom values, can be changed later with set()
|
* Create view instance with custom values, can be changed later with set()
|
||||||
* @param initial Dictionary of property names to values
|
* @param initial Dictionary of property names to values
|
||||||
* @param children Optional list of children to add to the view
|
* @param children Optional list of children to add to the view
|
||||||
* @version Added in JS SDK 0.1; amended in JS SDK 0.2, extra feature `"gui-widget"`
|
* @version Added in JS SDK 0.1
|
||||||
|
* @version Amended in JS SDK 0.2, extra feature `"gui-widget"`
|
||||||
|
* @version Baseline since JS SDK 1.0
|
||||||
*/
|
*/
|
||||||
makeWith(initial: Partial<Props>, children?: Child[]): V;
|
makeWith(initial: Partial<Props>, children?: Child[]): V;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
* This view has the elements as its children.
|
* This view has the elements as its children.
|
||||||
*
|
*
|
||||||
* @version Added in JS SDK 0.2, extra feature `"gui-widget"`
|
* @version Added in JS SDK 0.2, extra feature `"gui-widget"`
|
||||||
|
* @version Baseline since JS SDK 1.0
|
||||||
* @module
|
* @module
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -42,9 +43,21 @@ type TextBoxElement = { element: "text_box", stripToDots: boolean } & Position &
|
|||||||
type TextScrollElement = { element: "text_scroll" } & Position & Size & Text;
|
type TextScrollElement = { element: "text_scroll" } & Position & Size & Text;
|
||||||
type ButtonElement = { element: "button", button: "left" | "center" | "right" } & Text;
|
type ButtonElement = { element: "button", button: "left" | "center" | "right" } & Text;
|
||||||
type IconElement = { element: "icon", iconData: IconData } & Position;
|
type IconElement = { element: "icon", iconData: IconData } & Position;
|
||||||
type RectElement = { element: "rect", radius: number, fill: boolean } & Position & Size; /** @version Amended in JS SDK 0.3, extra feature `"gui-widget-extras"` */
|
/**
|
||||||
type CircleElement = { element: "circle", radius: number, fill: boolean } & Position; /** @version Added in JS SDK 0.3, extra feature `"gui-widget-extras"` */
|
* @version Amended in JS SDK 0.3, extra feature `"gui-widget-extras"`
|
||||||
type LineElement = { element: "line", x1: number, y1: number, x2: number, y2: number }; /** @version Added in JS SDK 0.3, extra feature `"gui-widget-extras"` */
|
* @version Baseline since JS SDK 1.0
|
||||||
|
* */
|
||||||
|
type RectElement = { element: "rect", radius: number, fill: boolean } & Position & Size;
|
||||||
|
/**
|
||||||
|
* @version Added in JS SDK 0.3, extra feature `"gui-widget-extras"`
|
||||||
|
* @version Baseline since JS SDK 1.0
|
||||||
|
* */
|
||||||
|
type CircleElement = { element: "circle", radius: number, fill: boolean } & Position;
|
||||||
|
/**
|
||||||
|
* @version Added in JS SDK 0.3, extra feature `"gui-widget-extras"`
|
||||||
|
* @version Baseline since JS SDK 1.0
|
||||||
|
* */
|
||||||
|
type LineElement = { element: "line", x1: number, y1: number, x2: number, y2: number };
|
||||||
|
|
||||||
type Element = StringMultilineElement
|
type Element = StringMultilineElement
|
||||||
| StringElement
|
| StringElement
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@darkflippers/fz-sdk-ul",
|
"name": "@darkflippers/fz-sdk-ul",
|
||||||
"version": "0.3.0",
|
"version": "1.0.0",
|
||||||
"description": "Type declarations and documentation for native JS modules available on Unleashed Custom Firmware for Flipper Zero",
|
"description": "Type declarations and documentation for native JS modules available on Unleashed Custom Firmware for Flipper Zero",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"unleashed",
|
"unleashed",
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export interface Framing {
|
|||||||
* @param framing See `Framing` type
|
* @param framing See `Framing` type
|
||||||
* @version Added in JS SDK 0.1
|
* @version Added in JS SDK 0.1
|
||||||
* @version Added `framing` parameter in JS SDK 0.3, extra feature `"serial-framing"`
|
* @version Added `framing` parameter in JS SDK 0.3, extra feature `"serial-framing"`
|
||||||
|
* @version Baseline since JS SDK 1.0
|
||||||
*/
|
*/
|
||||||
export declare function setup(port: "lpuart" | "usart", baudRate: number, framing?: Framing): void;
|
export declare function setup(port: "lpuart" | "usart", baudRate: number, framing?: Framing): void;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user