merge fix [ci skip]

with some parts from PR by Willy-JL
https://github.com/flipperdevices/flipperzero-firmware/pull/3980/files
This commit is contained in:
MX
2024-11-01 05:30:33 +03:00
parent 04c8093672
commit 3c6a621da2
15 changed files with 64 additions and 489 deletions

View File

@@ -120,6 +120,7 @@ declare function checkSdkCompatibility(expectedMajor: number, expectedMinor: num
* recognized as a baseline feature. For more info, consult the module
* documentation.
* @param features Array of named features to query
* @version Added in JS SDK 0.1
*/
declare function doesSdkSupport(features: string[]): boolean;
@@ -131,6 +132,7 @@ declare function doesSdkSupport(features: string[]): boolean;
* features that are now recognized as baseline features. For more
* info, consult the module documentation.
* @param features Array of named features to query
* @version Added in JS SDK 0.1
*/
declare function checkSdkFeatures(features: string[]): void | never;
@@ -150,15 +152,48 @@ declare function delay(ms: number): void;
declare function print(...args: any[]): void;
/**
* @brief Reads a JS value from a file
*
* Reads a file at the specified path, interprets it as a JS value and returns
* said value.
*
* @param path The path to the file
* @brief Converts a string to a number
* @param text The string to convert to a number
* @param base Integer base (`2`...`16`), default: 10
* @version Added in JS SDK 0.1
*/
declare function load(path: string): any;
declare function parseInt(text: string, base?: number): number;
/**
* @brief Path to the directory containing the current script
* @version Added in JS SDK 0.1
*/
declare const __dirname: string;
/**
* @brief Path to the current script file
* @version Added in JS SDK 0.1
*/
declare const __filename: string;
/**
* @brief Runs a JS file and returns value from it
*
* Reads a file at the specified path and runs it as JS, returning the last evaluated value.
*
* The result is cached and this filepath will not re-evaluated on future
* load() calls for this session.
*
* @param path The path to the file
* @param scope An object to use as global scope while running this file
* @version Added in JS SDK 0.1
*/
declare function load(path: string, scope?: object): any;
/**
* @brief Return 1-byte string whose ASCII code is the integer `n`
*
* If `n` is not numeric or outside of `0-255` range, `null` is returned
*
* @param n The ASCII code to convert to string
* @version Added in JS SDK 0.1
*/
declare function chr(n: number): string | null;
/**
* @brief Loads a natively implemented module

View File

@@ -30,7 +30,7 @@
* |----------------------|------------------|
* | `button_menu` | ❌ |
* | `button_panel` | ❌ |
* | `byte_input` | |
* | `byte_input` | |
* | `dialog_ex` | ✅ (as `dialog`) |
* | `empty_screen` | ✅ |
* | `file_browser` | ❌ |
@@ -122,11 +122,26 @@ import type { Contract } from "../event_loop";
type Properties = { [K: string]: any };
export declare class View<Props extends Properties> {
/**
* Assign value to property by name
* @param property Name of the property
* @param value Value to assign
* @version Added in JS SDK 0.1
*/
set<P extends keyof Props>(property: P, value: Props[P]): void;
}
export declare class ViewFactory<Props extends Properties, V extends View<Props>> {
/**
* Create view instance with default values, can be changed later with set()
* @version Added in JS SDK 0.1
*/
make(): V;
/**
* Create view instance with custom values, can be changed later with set()
* @param initial Dictionary of property names to values
* @version Added in JS SDK 0.1
*/
makeWith(initial: Partial<Props>): V;
}
@@ -144,6 +159,11 @@ declare class ViewDispatcher {
* @version Added in JS SDK 0.1
*/
navigation: Contract;
/**
* View object currently shown
* @version Added in JS SDK 0.1
*/
currentView: View<any>;
/**
* Sends a number to the custom event handler
* @param event number to send

View File

@@ -0,0 +1,31 @@
/**
* @brief Check if there is an I2C device ready on the bus
* @param address The device address to check
* @param timeout Timeout in milliseconds
*/
export declare function isDeviceReady(address: number, timeout?: number): boolean;
/**
* @brief Write data to I2C device and return success status
* @param address The device address to write to
* @param data The data to write to the device
* @param timeout Timeout in milliseconds
*/
export declare function write(address: number, data: number[] | ArrayBuffer, timeout?: number): boolean;
/**
* @brief Read data from I2C device or return undefined on failure
* @param address The device address to read from
* @param length How many bytes to read
* @param timeout Timeout in milliseconds
*/
export declare function read(address: number, length: number, timeout?: number): ArrayBuffer | undefined;
/**
* @brief Write data then read from I2C device or return undefined on failure
* @param address The device address to talk to
* @param writeData The data to write to the device
* @param readLength How many bytes to read
* @param timeout Timeout in milliseconds
*/
export declare function writeRead(address: number, writeData: number[] | ArrayBuffer, readLength: number, timeout?: number): ArrayBuffer | undefined;

View File

@@ -14,6 +14,7 @@ export declare function success(): void;
/**
* @brief Signals failure to the user via the color LED, speaker and vibration
* motor
* @version Added in JS SDK 0.1
*/
export declare function error(): void;

View File

@@ -0,0 +1,30 @@
/**
* @brief Acquire SPI bus
*/
export declare function acquire(): void;
/**
* @brief Release SPI bus
*/
export declare function release(): void;
/**
* @brief Write data to SPI bus and return success status
* @param data The data to write
* @param timeout Timeout in milliseconds
*/
export declare function write(data: number[] | ArrayBuffer, timeout?: number): boolean;
/**
* @brief Read data from SPI bus or return undefined on failure
* @param length How many bytes to read
* @param timeout Timeout in milliseconds
*/
export declare function read(length: number, timeout?: number): ArrayBuffer | undefined;
/**
* @brief Write and read data on SPI bus or return undefined on failure
* @param data The data to write, its length also indicates how many bytes will be read
* @param timeout Timeout in milliseconds
*/
export declare function writeRead(data: number[] | ArrayBuffer, timeout?: number): ArrayBuffer | undefined;