Skip to content

Commit

Permalink
JS: Add typedocs for all extra modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Nov 3, 2024
1 parent 6e45458 commit c537092
Show file tree
Hide file tree
Showing 6 changed files with 310 additions and 1 deletion.
2 changes: 1 addition & 1 deletion applications/system/js_app/modules/js_subghz/js_subghz.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static void js_subghz_transmit_file(struct mjs* mjs) {
// - "repeat" as variable and loop in this code applies to RAW files only
// parsed files handle repeat in protocol layer instead
// We keep 0 as default, or literal value if specified by user
// If user did not specify, -1 is detected below, and we use:
// If user did not specify, 0 is detected below, and we use:
// - 1 repeat for RAW
// - 10 repeats for parsed, which is passed to protocol, and we loop once here
uint32_t repeat = 0;
Expand Down
41 changes: 41 additions & 0 deletions applications/system/js_app/packages/fz-sdk/blebeacon/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Module for using the BLE extra beacon
* @version Available with JS feature `blebeacon`
* @module
*/

/**
* @brief Check if the BLE beacon is active
*/
export declare function isActive(): boolean;

/**
* @brief Set BLE beacon configuration
* @param mac The MAC address to use
* @param power The power level to use, in GapAdvPowerLevel scale: 0x00 (-40dBm) to 0x1F (+6dBm)
* @param minInterval Minimum advertisement interval
* @param maxInterval Maximum advertisement interval
*/
export declare function setConfig(mac: Uint8Array, power?: number, minInterval?: number, maxInterval?: number): void;

/**
* @brief Set BLE beacon advertisement data
* @param data The advertisement data to use
*/
export declare function setData(data: Uint8Array): void;

/**
* @brief Start BLE beacon
*/
export declare function start(): void;

/**
* @brief Stop BLE beacon
*/
export declare function stop(): void;

/**
* @brief Set whether the BLE beacon will remain active after the script exits
* @param keep True if BLE beacon should remain active after script exit
*/
export declare function keepAlive(keep: boolean): void;
64 changes: 64 additions & 0 deletions applications/system/js_app/packages/fz-sdk/subghz/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Module for using Sub-GHz transciever
* @version Available with JS feature `subghz`
* @module
*/

/**
* @brief Initialize Sub-GHz module
*/
export declare function setup(): void;

/**
* @brief Deinitialize Sub-GHz module
*/
export declare function end(): void;

/**
* @brief Set radio to receive mode
*/
export declare function setRx(): void;

/**
* @brief Set radio to idle mode
*/
export declare function setIdle(): void;

/**
* @brief Return current RSSI on current frequency, or undefined if radio is not in receive mode
*/
export declare function getRssi(): number | undefined;

type RadioState = "RX" | "TX" | "IDLE" | "";

/**
* @brief Get current radio mode/state
*/
export declare function getState(): RadioState;

/**
* @brief Get currently selected frequency
*/
export declare function getFrequency(): number;

/**
* @brief Change current frequency, radio must be in idle mode
*
* Returns the effective frequency, since radio module cant use all precise
* values and instead chooses closest one available
*
* @param frequency What frequency to use
*/
export declare function setFrequency(frequency: number): number;

/**
* @brief Check whether the radio module in use is internal or external
*/
export declare function isExternal(): boolean;

/**
* @brief Transmit a .sub file, return true on success or error on failure
* @param path What .sub file to transmit
* @param repeat How many times to repeat the signal
*/
export declare function transmitFile(path: string, repeat?: number): true;
32 changes: 32 additions & 0 deletions applications/system/js_app/packages/fz-sdk/usbdisk/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Module for USB mass storage emulation
* @version Available with JS feature `usbdisk`
* @module
*/

/**
* @brief Create a disk image and format it as FatFs, error on failure
* @param path Where to create the disk image
* @param size How big the disk image should be
* @version Available with JS feature `usbdisk-createimage`
*/
export declare function createImage(path: string, size: number): void;

/**
* @brief Start emulating mass storage device
* @param path The disk image to emulate
*/
export declare function start(path: string): void;

/**
* @brief Stop emulating mass storage device
*/
export declare function stop(): void;

/**
* @brief Check if the mass storage device was exected
*
* Useful as a loop condition with a delay, so UsbDisk keeps running until ejected
*
*/
export declare function wasEjected(): boolean;
32 changes: 32 additions & 0 deletions applications/system/js_app/packages/fz-sdk/vgm/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Module for interactive with Flipper Video Game Module (VGM)
* @version Available with JS feature `vgm`
* @module
*/

/**
* @brief Get current VGM pitch, or undefined if VGM not present
*/
export declare function getPitch(): number | undefined;

/**
* @brief Get current VGM roll, or undefined if VGM not present
*/
export declare function getRoll(): number | undefined;

/**
* @brief Get current VGM yaw, or undefined if VGM not present
*/
export declare function getYaw(): number | undefined;

/**
* @brief Wait until yaw changed by specified amount
*
* Returns how much the yaw changed from initial value if it exceeded the
* specified yaw angle, or returns 0 if it was not exceeded within the timeout
* Or returns undefined if VGM is not present
*
* @param angle How much the yaw needs to change
* @param timeout Maximum time in milliseconds to wait for specified yaw change, default 3000ms
*/
export declare function deltaYaw(angle: number, timeout?: number): number | undefined;
140 changes: 140 additions & 0 deletions applications/system/js_app/packages/fz-sdk/widget/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/**
* Displays a customizable Widget on screen
* @version Available with JS feature `widget`
* @module
*/

type ComponentId = number;

/**
* @brief Add a box component
* @param x Horizontal position
* @param y Vertical position
* @param w Width
* @param h Height
*/
export declare function addBox(x: number, y: number, w: number, h: number): ComponentId;

/**
* @brief Add a circle component
* @param x Horizontal position
* @param y Vertical position
* @param r Radius
*/
export declare function addCircle(x: number, y: number, r: number): ComponentId;

/**
* @brief Add a disc component
* @param x Horizontal position
* @param y Vertical position
* @param r Radius
*/
export declare function addDisc(x: number, y: number, r: number): ComponentId;

/**
* @brief Add a dot component
* @param x Horizontal position
* @param y Vertical position
*/
export declare function addDot(x: number, y: number): ComponentId;

/**
* @brief Add a frame component
* @param x Horizontal position
* @param y Vertical position
* @param w Width
* @param h Height
*/
export declare function addFrame(x: number, y: number, w: number, h: number): ComponentId;

/**
* @brief Add a glyph component
* @param x Horizontal position
* @param y Vertical position
* @param ch ASCII character code (eg. `"C".charCodeAt(0)`)
*/
export declare function addGlyph(x: number, y: number, ch: number): ComponentId;

/**
* @brief Add an icon component
* @param x Horizontal position
* @param y Vertical position
* @param icon Name of the icon (eg. `"ButtonUp_7x4"`)
* @version Available with JS feature `widget-addicon`
*/
export declare function addIcon(x: number, y: number, icon: string): ComponentId;

/**
* @brief Add a line component
* @param x1 Horizontal position 1
* @param y1 Vertical position 1
* @param x2 Horizontal position 2
* @param y2 Vertical position 2
*/
export declare function addLine(x1: number, y1: number, x2: number, y2: number): ComponentId;

/**
* @brief Add a rounded box component
* @param x Horizontal position
* @param y Vertical position
* @param w Width
* @param h Height
* @param r Radius
*/
export declare function addRbox(x: number, y: number, w: number, h: number, r: number): ComponentId;

/**
* @brief Add a rounded frame component
* @param x Horizontal position
* @param y Vertical position
* @param w Width
* @param h Height
* @param r Radius
*/
export declare function addRframe(x: number, y: number, w: number, h: number, r: number): ComponentId;

/**
* @brief Add a text component
* @param x Horizontal position
* @param y Vertical position
* @param font What font to use, Primary or Secondary
* @param text Text to display
*/
export declare function addText(x: number, y: number, font: "Primary" | "Secondary", text: string): ComponentId;

type XbmId = number;

/**
* @brief Add an xbm image component
* @param x Horizontal position
* @param y Vertical position
* @param index Loaded xbm id to use
*/
export declare function addXbm(x: number, y: number, index: XbmId): ComponentId;

/**
* @brief Load an xbm image sprite
* @param path Xbm file to load
*/
export declare function loadImageXbm(path: string): XbmId;

/**
* @brief Remove a component
* @param id Component id to remove
*/
export declare function remove(id: ComponentId): boolean;

/**
* @brief Check if the widget view is shown
*/
export declare function isOpen(): boolean;

/**
* @brief Show the widget view
*/
export declare function show(): void;

/**
* @brief Close the widget view
*/
export declare function close(): void;

0 comments on commit c537092

Please sign in to comment.