### Navigate and Start Flipper Zero App Source: https://github.com/next-flip/momentum-firmware/blob/dev/applications/system/js_app/packages/create-fz-app/README.md After creating your application, navigate into the project directory and use this command to start the development server or build the application. You can use npm, pnpm, or yarn. ```shell cd my-flip-app npm start ``` -------------------------------- ### macOS qFlipper Installation Script Source: https://github.com/next-flip/momentum-firmware/blob/dev/applications/main/bad_usb/resources/badusb/Demos/Install_qFlipper_macOS.txt This script automates the installation of qFlipper on macOS. It downloads the DMG, attaches it, copies the application to /Applications, detaches the DMG, cleans up, and launches qFlipper. It is recommended to run this script only once per target to bypass the macOS keyboard setup assistant. ```BadUSB DELAY 3000 F4 DELAY 2500 STRING Terminal DELAY 2500 ENTER DELAY 1500 STRING (cd /tmp && curl -L -o qFlipper.dmg https://update.flipperzero.one/qFlipper/release/macos-amd64/dmg && hdiutil attach qFlipper.dmg && app_volume=$(ls /Volumes | grep -i "qFlipper") && (test -e /Applications/qFlipper.app && rm -rf /Applications/qFlipper.app ); cp -R "/Volumes/$app_volume/qFlipper.app" /Applications/ && hdiutil detach "/Volumes/$app_volume" && rm qFlipper.dmg && open /Applications/qFlipper.app) DELAY 1000 ENTER ``` -------------------------------- ### Flipper SubGhz Key File Example (Standard Preset) Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/file_formats/SubGhzFileFormats.md This example shows a standard Flipper SubGhz Key File configuration using the Princeton protocol with a standard preset. ```text Filetype: Flipper SubGhz Key File Version: 1 Frequency: 433920000 Preset: FuriHalSubGhzPresetOok650Async Protocol: Princeton Bit: 24 Key: 00 00 00 00 00 95 D5 D4 TE: 400 ``` -------------------------------- ### Flipper SubGhz RAW File Example (Custom Preset) Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/file_formats/SubGhzFileFormats.md This example demonstrates a Flipper SubGhz RAW File configuration with a custom preset, including multiple RAW_Data lines. ```text Filetype: Flipper SubGhz RAW File Version: 1 Frequency: 433920000 Preset: FuriHalSubGhzPresetCustom Custom_preset_module: CC1101 Custom_preset_data: 02 0D 03 07 08 32 0B 06 14 00 13 00 12 30 11 32 10 17 18 18 19 18 1D 91 1C 00 1B 07 20 FB 22 11 21 B6 00 00 00 C0 00 00 00 00 00 00 Protocol: RAW RAW_Data: 29262 361 -68 2635 -66 24113 -66 11 ... RAW_Data: -424 205 -412 159 -412 381 -240 181 ... RAW_Data: -1448 361 -17056 131 -134 233 -1462 131 -166 953 -100 ... ``` -------------------------------- ### Install qFlipper on Linux/Gnome Source: https://github.com/next-flip/momentum-firmware/blob/dev/applications/main/bad_usb/resources/badusb/Demos/Install_qFlipper_gnome.txt This script automates the installation of qFlipper on Linux/Gnome. It opens a terminal, downloads the latest AppImage, makes it executable, and configures desktop entries. Ensure you have `curl` and `sed` installed. ```bash ALT F2 DELAY 1000 STRINGLN gnome-terminal --maximize DELAY 1000 STRINGLN mkdir -p $HOME/.local/bin STRINGLN curl -fsSL "https://update.flipperzero.one/qFlipper/release/linux-amd64/AppImage" -o "$HOME/.local/bin/qFlipper" DELAY 1000 STRINGLN chmod +x $HOME/.local/bin/qFlipper STRINGLN cd /tmp STRINGLN $HOME/.local/bin/qFlipper --appimage-extract > /dev/null STRINGLN sed "s@Exec=qFlipper@Exec=$HOME/.local/bin/qFlipper@" squashfs-root/usr/share/applications/qFlipper.desktop > $HOME/.local/share/applications/qFlipper.desktop STRINGLN mkdir -p $HOME/.local/share/icons/hicolor/512x512/apps STRINGLN cp squashfs-root/usr/share/icons/hicolor/512x512/apps/qFlipper.png $HOME/.local/share/icons/hicolor/512x512/apps/qFlipper.png STRINGLN rm -rf squashfs-root STRINGLN cd STRINGLN xdg-desktop-menu forceupdate || true STRINGLN update-desktop-database ~/.local/share/applications || true STRINGLN echo " ENTER REPEAT 60 STRINGLN ========================================================================================== STRINGLN qFlipper has been installed to $HOME/.local/bin/ STRINGLN It should appear in your Applications menu. STRINGLN If it does not, you might want to log out and log in again. ENTER STRINGLN If you prefer to run qFlipper from your terminal, either use the absolute path STRINGLN or make sure $HOME/.local/bin/ is included in your PATH environment variable. ENTER STRINGLN Additional configurations might be required by your Linux distribution such as STRINGLN group membership, udev rules or else. STRINGLN ========================================================================================== STRINGLN " ENTER ``` -------------------------------- ### Flipper SubGhz RAW File Example (Standard Preset) Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/file_formats/SubGhzFileFormats.md This example shows a Flipper SubGhz RAW File configuration with a standard preset, including multiple RAW_Data lines. ```text Filetype: Flipper SubGhz RAW File Version: 1 Frequency: 433920000 Preset: FuriHalSubGhzPresetOok650Async Protocol: RAW RAW_Data: 29262 361 -68 2635 -66 24113 -66 11 ... RAW_Data: -424 205 -412 159 -412 381 -240 181 ... RAW_Data: -1448 361 -17056 131 -134 233 -1462 131 -166 953 -100 ... ``` -------------------------------- ### Automated qFlipper Installation Script Source: https://github.com/next-flip/momentum-firmware/blob/dev/applications/main/bad_usb/resources/badusb/Demos/Install_qFlipper_windows.txt This script automates the download, extraction, and setup of qFlipper on Windows. It handles driver installation and creates a desktop shortcut. Ensure PowerShell execution policy allows script execution. ```powershell REM Written by @dexv DELAY 2000 GUI r DELAY 500 STRING powershell ENTER DELAY 1000 STRING $url = "https://update.flipperzero.one/qFlipper/release/windows-amd64/portable" ENTER STRING $output = "$env:USERPROFILE\\Documents\\qFlipper.zip" ENTER STRING $destination = "$env:USERPROFILE\\Documents\\qFlipper" ENTER STRING $shortcutPath = "$env:USERPROFILE\\Desktop\\qFlipper.lnk" ENTER STRING $scriptPath = "$env:USERPROFILE\\Documents\\qFlipperInstall.ps1" ENTER STRING $driverPath = "$destination\\STM32 Driver" ENTER STRING $installBat = "$driverPath\\install.bat" ENTER STRING (New-Object System.Net.WebClient).DownloadFile($url, $output) ENTER STRING Expand-Archive -Path $output -DestinationPath $destination -Force ENTER STRING Set-Location -Path $destination ENTER STRING Start-Process -FilePath ".\\qFlipper.exe" ENTER STRING Start-Process -Wait -FilePath "cmd.exe" -ArgumentList "/c $installBat" ENTER STRING $shell = New-Object -ComObject WScript.Shell ENTER STRING $shortcut = $shell.CreateShortcut($shortcutPath) ENTER STRING $shortcut.TargetPath = "$destination\\qFlipper.exe" ENTER STRING $shortcut.Save() ENTER DELAY 500 STRING "powershell -ExecutionPolicy Bypass -File $scriptPath" ENTER ``` -------------------------------- ### Example connection to Developer Board on macOS Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/devboard/Reading logs via the Dev Board.md An example command to connect to the Flipper Zero Developer Board on macOS using minicom, specifying a common port name. ```bash minicom -D /dev/cu.usbmodemblackmagic3 -b 230400 ``` -------------------------------- ### Flipper SubGhz Key File Example (Custom Preset) Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/file_formats/SubGhzFileFormats.md This example demonstrates a Flipper SubGhz Key File configuration with a custom preset, specifying the CC1101 module and custom preset data. ```text Filetype: Flipper SubGhz Key File Version: 1 Frequency: 433920000 Preset: FuriHalSubGhzPresetCustom Custom_preset_module: CC1101 Custom_preset_data: 02 0D 03 07 08 32 0B 06 14 00 13 00 12 30 11 32 10 17 18 18 19 18 1D 91 1C 00 1B 07 20 FB 22 11 21 B6 00 00 00 C0 00 00 00 00 00 00 Protocol: Princeton Bit: 24 Key: 00 00 00 00 00 95 D5 D4 TE: 400 ``` -------------------------------- ### Sub-GHz Remote Map File Configuration Example Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/SubGHzRemotePlugin.md This is an example of how to configure the `example.txt` map file. It shows the mapping of directional inputs (UP, DOWN, LEFT, RIGHT, OK) to specific Sub-GHz capture files and assigns corresponding labels (ULABEL, DLABEL, LLABEL, RLABEL, OKLABEL) for display. ```text UP: /ext/subghz/Up.sub DOWN: /ext/subghz/Down.sub LEFT: /ext/subghz/Left.sub RIGHT: /ext/subghz/Right.sub OK: /ext/subghz/Ok.sub ULABEL: Up Label DLABEL: Down Label LLABEL: Left Label RLABEL: Right Label OKLABEL: Ok Label ``` -------------------------------- ### Install micro Flipper Build Tool (uFBT) on Windows Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/devboard/Firmware update on Developer Board.md Installs the micro Flipper Build Tool (uFBT) using pipx on Windows. Requires Python and pipx to be installed and added to PATH. ```powershell py -m pip install --user pipx ``` ```powershell py -m pipx ensurepath ``` ```powershell pipx install ufbt ``` -------------------------------- ### Install Python Packages Source: https://github.com/next-flip/momentum-firmware/blob/dev/applications/system/findmy/README.md Install all required Python packages listed in the 'requirements.txt' file. This command should be run after activating the virtual environment. ```bash pip3 install -r requirements.txt ``` -------------------------------- ### Install micro Flipper Build Tool (uFBT) on Linux/macOS Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/devboard/Firmware update on Developer Board.md Installs the micro Flipper Build Tool (uFBT) using pipx on Linux and macOS systems. Ensure pipx is installed first. ```bash pipx install ufbt ``` -------------------------------- ### iButton Key File Example Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/file_formats/iButtonFileFormat.md This is an example of the Flipper iButton key file format, version 2, using the DS1992 protocol. It includes Rom Data and Sram Data. ```text Filetype: Flipper iButton key Version: 2 Protocol: DS1992 Rom Data: 08 DE AD BE EF FA CE 4E Sram Data: 4E 65 76 65 72 47 6F 6E 6E 61 47 69 76 65 59 6F 75 55 70 4E 65 76 65 72 47 6F 6E 6E 61 4C 65 74 59 6F 75 44 6F 77 6E 4E 65 76 65 72 47 6F 6E 6E 61 52 75 6E 41 72 6F 75 6E 64 41 6E 64 44 65 73 65 72 74 59 6F 75 4E 65 76 65 72 47 6F 6E 6E 61 4D 61 6B 65 59 6F 75 43 72 79 4E 65 76 65 72 47 6F 6E 6E 61 53 61 79 47 6F 6F 64 62 79 65 4E 65 76 65 72 47 6F 6E 6E 61 54 65 6C 6C 41 4C 69 65 ``` -------------------------------- ### Control an LED with GPIO Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_gpio.md Example of initializing a pin as an output and controlling an LED. Ensure the 'event_loop' module is imported before 'gpio'. ```js let eventLoop = require("event_loop"); let gpio = require("gpio"); let led = gpio.get("pc3"); led.init({ direction: "out", outMode: "push_pull" }); led.write(true); delay(1000); led.write(false); delay(1000); ``` -------------------------------- ### Infrared Remote File Format Example Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/file_formats/InfraredFileFormats.md This example demonstrates the structure of an infrared remote file, showing how to define buttons with either parsed protocol data or raw signal timings. Use this format to store custom remote configurations. ```text Filetype: IR signals file Version: 1 # name: Button_1 type: parsed protocol: NECext address: EE 87 00 00 command: 5D A0 00 00 # name: Button_2 type: raw frequency: 38000 duty_cycle: 0.330000 data: 504 3432 502 483 500 484 510 502 502 482 501 485 509 1452 504 1458 509 1452 504 481 501 474 509 3420 503 # name: Button_3 type: parsed protocol: SIRC address: 01 00 00 00 command: 15 00 00 00 ``` -------------------------------- ### setTimeout Equivalent Example Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_event_loop.md This example demonstrates how to achieve functionality similar to `setTimeout` using the event loop module. ```javascript setTimeout(function() { console.log("Hello, World!") }, 1000); ``` -------------------------------- ### Sub-GHz Remote Map File Usage Example Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/SubGHzRemotePlugin.md This example demonstrates a practical application of the Sub-GHz Remote map file, assigning specific actions like 'Fan ON', 'Fan OFF', 'Doorbell', 'Garage OPEN', and 'Garage CLOSE' to corresponding Sub-GHz files. ```text UP: /ext/subghz/Fan1.sub DOWN: /ext/subghz/Fan2.sub LEFT: /ext/subghz/Door.sub RIGHT: /ext/subghz/Garage3.sub OK: /ext/subghz/Garage3l.sub ULABEL: Fan ON DLABEL: Fan OFF LLABEL: Doorbell RLABEL: Garage OPEN OKLABEL: Garage CLOSE ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/next-flip/momentum-firmware/wiki/Assets/Asset-Packs Before creating standalone asset packs, install the necessary Python libraries: Pillow for image manipulation and heatshrink2 for compression. ```bash pip3 install Pillow heatshrink2 ``` -------------------------------- ### Example .sub File Key Data Block (Princeton) Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/file_formats/SubGhzFileFormats.md This example shows the structure of a key data block within a .sub file for the Princeton protocol. It includes fields like Bit, Key, and TE, which are specific to this protocol. ```text Protocol: Princeton Bit: 24 Key: 00 00 00 00 00 95 D5 D4 TE: 400 ``` -------------------------------- ### ViewDispatcher Example with Multiple Views Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_gui.md Demonstrates how to set up and manage multiple views (loading, submenu, empty) using the ViewDispatcher. It subscribes to view chosen and navigation events to switch between screens and exit the application. ```javascript let eventLoop = require("event_loop"); let gui = require("gui"); let loadingView = require("gui/loading"); let submenuView = require("gui/submenu"); let emptyView = require("gui/empty_screen"); // Common pattern: declare all the views in an object. This is absolutely not // required, but adds clarity to the script. let views = { // the view dispatcher auto-✨magically✨ remembers views as they are created loading: loadingView.make(), empty: emptyView.make(), demos: submenuView.makeWith({ items: [ "Hourglass screen", "Empty screen", "Exit app", ], }), }; // go to different screens depending on what was selected eventLoop.subscribe(views.demos.chosen, function (_sub, index, gui, eventLoop, views) { if (index === 0) { gui.viewDispatcher.switchTo(views.loading); } else if (index === 1) { gui.viewDispatcher.switchTo(views.empty); } else if (index === 2) { eventLoop.stop(); } }, gui, eventLoop, views); // go to the demo chooser screen when the back key is pressed eventLoop.subscribe(gui.viewDispatcher.navigation, function (_sub, _, gui, views) { gui.viewDispatcher.switchTo(views.demos); }, gui, views); // run UI gui.viewDispatcher.switchTo(views.demos); eventLoop.run(); ``` -------------------------------- ### Start Anisette Server with Docker Source: https://github.com/next-flip/momentum-firmware/blob/dev/applications/system/findmy/README.md Run the anisette-v3 server using Docker to emulate Apple's authentication servers for AirTag key generation. This command starts the server in detached mode, ensures it restarts automatically, and maps port 6969. ```bash docker run -d --restart always --name anisette-v3 -p 6969:6969 dadoum/anisette-v3-server:latest ``` -------------------------------- ### LF RFID Key File Example Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/file_formats/LfRfidFileFormat.md This is an example of the LF RFID key file format. It specifies the file type, version, key type, and the actual key data in hexadecimal format. ```text Filetype: Flipper RFID key Version: 1 Key type: EM4100 Data: 01 23 45 67 89 ``` -------------------------------- ### External Build Configuration Example Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/AppManifests.md Configure external build tools for app sources, such as Rust. Uses fbt variables for build directories and manifest paths. ```python sources=["target/thumbv7em-none-eabihf/release/libhello_rust.a"], fap_extbuild=( ExtFile( path="${FAP_WORK_DIR}/target/thumbv7em-none-eabihf/release/libhello_rust.a", command="cargo build --release --verbose --target thumbv7em-none-eabihf --target-dir ${FAP_WORK_DIR}/target --manifest-path ${FAP_SRC_DIR}/Cargo.toml", ), ), ``` -------------------------------- ### Nice Flor S with CounterMode 1 Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/SubGHzCounterMode.md Example configuration for a Nice Flor S protocol using CounterMode 1. Ensure the protocol and mode number are compatible. ```text Filetype: Flipper SubGhz Key File Version: 1 Frequency: 433920000 Preset: FuriHalSubGhzPresetOok650Async Protocol: Nice FloR-S Bit: 52 Key: 01 23 45 67 89 AB CD CounterMode: 1 ``` -------------------------------- ### Install Flipper Udev Rules Source: https://github.com/next-flip/momentum-firmware/blob/dev/scripts/debug/README.md Copy the udev rules file to the system directory and reload the rules to enable debugging and CLI access. This ensures the system recognizes the Flipper device correctly. ```bash sudo cp 41-flipper.rules /etc/udev/rules.d/ sudo udevadm control --reload-rules sudo udevadm trigger ``` -------------------------------- ### One-Shot Timer Example Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_event_loop.md Demonstrates creating a one-shot timer that fires after a specified interval and then stops the event loop. ```javascript // import module let eventLoop = require("event_loop"); // create an event source that will fire once 1 second after it has been created let timer = eventLoop.timer("oneshot", 1000); // subscribe a callback to the event source eventLoop.subscribe(timer, function(_subscription, _item, eventLoop) { print("Hello, World!"); eventLoop.stop(); }, eventLoop); // notice this extra argument. we'll come back to this later // run the loop until it is stopped eventLoop.run(); // the previous line will only finish executing once `.stop()` is called, hence // the following line will execute only after "Hello, World!" is printed print("Stopped"); ``` -------------------------------- ### KeeLoq with CounterMode 2 Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/SubGHzCounterMode.md Example configuration for a KeeLoq protocol with Doorhan manufacture, using CounterMode 2. Verify protocol and mode number compatibility. ```text Filetype: Flipper SubGhz Key File Version: 1 Frequency: 433920000 Preset: FuriHalSubGhzPresetOok650Async Protocol: KeeLoq Bit: 64 Key: DE AD BE EF CA FE BA BE Manufacture: Doorhan CounterMode: 2 ``` -------------------------------- ### firmwareVendor Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_flipper.md String representing the firmware installed on the device. Original firmware reports "flipperdevices". ```APIDOC ## Values ### firmwareVendor String representing the firmware installed on the device. Original firmware reports `"flipperdevices"`. ``` -------------------------------- ### Compile Firmware Assets Source: https://github.com/next-flip/momentum-firmware/blob/dev/assets/ReadMe.md Use this command to compile various firmware assets including icons, protobuf definitions, and resources. Ensure you have the necessary Python packages installed. ```bash ./fbt icons proto dolphin_internal dolphin_blocking dolphin_ext resources ``` -------------------------------- ### RAW File Format Example Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/file_formats/SubGhzFileFormats.md RAW files contain unprocessed signal data. The Protocol must be RAW, and RAW_Data is an array of non-zero, interleaved timings in microseconds. Up to 512 values per line are supported. ```text Protocol: RAW RAW_Data: 29262 361 -68 2635 -66 24113 -66 11 ... ``` -------------------------------- ### Animation Frame Indexing Example Source: https://github.com/next-flip/momentum-firmware/blob/dev/assets/dolphin/ReadMe.md Illustrates how frame indexes are calculated based on passive frames, active frames, frame order, and active cycles. This helps in understanding the timing and sequence of animation playback. ```text Passive frames: 6 Active frames: 2 Frames order: 0 1 2 3 4 5 6 7 Active cycles: 4 ``` ```text passive(6) active (2 * 4) Real frames order: 0 1 2 3 4 5 6 7 6 7 6 7 6 7 Frames indexes: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 ``` -------------------------------- ### Get Device Name Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_flipper.md Retrieve the name assigned to the virtual dolphin. Example output is 'Fur1pp44'. ```javascript flipper.getName(); // "Fur1pp44" ``` -------------------------------- ### badusb.setup() Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_badusb.md Initializes the USB HID interface. This method should be called before any other BadUSB methods. It can be configured with custom VID, PID, manufacturer name, product name, and keyboard layout path. ```APIDOC ## setup() ### Description Start USB HID with optional parameters. Should be called before all other methods. Automatically unlocks USB profile, so qFlipper connection will be interrupted. ### Parameters Configuration object *(optional)*: - vid (number): VID value, mandatory - pid (number): PID value, mandatory - mfrName (string): Manufacturer name (32 ASCII characters max), optional - prodName (string): Product name (32 ASCII characters max), optional - layoutPath (string): Path to keyboard layout file, optional ### Examples ```js // Start USB HID with default parameters badusb.setup(); // Start USB HID with custom vid:pid = AAAA:BBBB, manufacturer and product strings not defined badusb.setup({ vid: 0xAAAA, pid: 0xBBBB }); // Start USB HID with custom vid:pid = AAAA:BBBB, manufacturer string = "Flipper Devices", product string = "Flipper Zero" badusb.setup({ vid: 0xAAAA, pid: 0xBBBB, mfrName: "Flipper Devices", prodName: "Flipper Zero" }); ``` ``` -------------------------------- ### Get Device Model Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_flipper.md Retrieve the model name of the Flipper device. Example output is 'Flipper Zero'. ```javascript flipper.getModel(); // "Flipper Zero" ``` -------------------------------- ### Install Homebrew on macOS Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/devboard/Reading logs via the Dev Board.md Install Homebrew package manager on macOS. This is a prerequisite for installing other command-line tools like minicom. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` -------------------------------- ### Get File Size Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_storage.md Gets the total size of the file in bytes. ```javascript let size = file.size(); ``` -------------------------------- ### Build and Launch Single App Source: https://github.com/next-flip/momentum-firmware/blob/dev/ReadMe.md Build and launch a single application from the firmware source. Replace 'your_appid' with the actual application ID. ```bash ./fbt launch APPSRC=your_appid ``` -------------------------------- ### Get Current File Position Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_storage.md Gets the absolute position of the read/write pointer in bytes. ```javascript let position = file.tell(); ``` -------------------------------- ### Display "Hello World" and ASCII Art on macOS Source: https://github.com/next-flip/momentum-firmware/blob/dev/applications/main/bad_usb/resources/badusb/Demos/demo_macos.txt This script demonstrates writing to /dev/null and then displays "Hello World!" followed by ASCII art. It also includes information about Flipper Zero's BadUSB compatibility and script syntax. ```BadUSB Script STRING cat > /dev/null << EOF ENTER STRING Hello World! ENTER DEFAULT_DELAY 50 STRING = REPEAT 59 ENTER ENTER STRING _.-------.._ -, ENTER HOME STRING .-"'''"--..,,_/ /'-, -, \ ENTER HOME STRING .:" /:/ /'\ \ ,_..., '. | | ENTER HOME STRING / ,----/:/ /'\ _\~'-"" _; ENTER HOME STRING ' / /'"""'\ \ \.~'_-' ,-"'/ ENTER HOME STRING | | | 0 | | .-' ,/' / ENTER HOME STRING | ,..,\ \ ,.-'" ,/' / ENTER HOME STRING ; : '/'"\' ,/--==,/-----, ENTER HOME STRING | '-...| -.___-Z:_______J...---; ENTER HOME STRING : ' _-' ENTER HOME STRING _L_ _ ___ ___ ___ ___ ____--"' ENTER HOME STRING | __|| | |_ _|| _ \| _ \| __|| _ \ ENTER HOME STRING | _| | |__ | | | _/| _/| _| | / ENTER HOME STRING |_| |____||___||_| |_| |___||_|_ ENTER HOME ENTER STRING Flipper Zero BadUSB feature is compatible with USB Rubber Ducky script format ENTER STRING More information about script syntax can be found here: ENTER STRING https://github.com/flipperdevices/flipperzero-firmware/blob/dev/documentation/file_formats/BadUsbScriptFormat.md ENTER STRING EOF ENTER ``` -------------------------------- ### virtualInit(path) Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_storage.md Initialize virtual mount API with disk image at the given path. ```APIDOC ## virtualInit(path) ### Description Initialize virtual mount API with disk image at given path. ### Parameters - path (string): Path to disk image file. ### Returns - Nothing on success, error on failure. ``` -------------------------------- ### serial.setup() Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_serial.md Configures the serial port. This method should be called before any other serial methods. It automatically disables the Expansion module service to prevent interference. ```APIDOC ## setup() ### Description Configure serial port. Should be called before all other methods. Automatically disables Expansion module service to prevent interference. ### Parameters - Serial port name (`"usart"`, `"lpuart"`) - Baudrate - Optional framing configuration object (e.g. `{ dataBits: "8", parity: "even", stopBits: "1" }`): - `dataBits`: `"6"`, `"7"`, `"8"`, `"9"` - 6 data bits can only be selected when parity is enabled (even or odd) - 9 data bits can only be selected when parity is disabled (none) - `parity`: `"none"`, `"even"`, `"odd"` - `stopBits`: `"0.5"`, `"1"`, `"1.5"`, `"2"` - LPUART only supports whole stop bit lengths (i.e. 1 and 2 but not 0.5 and 1.5) ### Example ```js // Configure LPUART port with baudrate = 115200 serial.setup("lpuart", 115200); ``` ``` -------------------------------- ### Install minicom on macOS Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/devboard/Reading logs via the Dev Board.md Install the minicom serial communication program using Homebrew on macOS. This tool is used to connect to the Developer Board and view logs. ```bash brew install minicom ``` -------------------------------- ### Windows Notepad Automation Source: https://github.com/next-flip/momentum-firmware/blob/dev/applications/main/bad_usb/resources/badusb/Demos/demo_windows.txt Opens Notepad and types 'Hello World!' with a slight delay for reliable input. ```badusb REM set slightly slower delay to ensure notepad picks up input without skipping characters DEFAULT_STRING_DELAY 10 REM Open windows notepad DELAY 1000 GUI r DELAY 500 STRING notepad DELAY 500 ENTER DELAY 750 STRING Hello World! ENTER DEFAULT_DELAY 50 ``` -------------------------------- ### Create Flipper Zero App with Momentum SDK Source: https://github.com/next-flip/momentum-firmware/blob/dev/applications/system/js_app/packages/create-fz-app/README.md Use this command to initiate the interactive wizard for creating a new application. It scaffolds a project structure and sets up the necessary configurations for the Momentum Firmware JS SDK. ```shell npx @next-flip/create-fz-app-mntm@latest ``` -------------------------------- ### Install minicom on Linux Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/devboard/Reading logs via the Dev Board.md Install the minicom serial communication program on Linux, using apt for Debian-based systems like Ubuntu. This tool is used to connect to the Developer Board and view logs. ```bash sudo apt install minicom ``` -------------------------------- ### List Available Peripherals Source: https://github.com/next-flip/momentum-firmware/blob/dev/scripts/debug/PyCortexMDebug/README.md After loading an SVD file, use the 'svd' command to list all available peripherals and their descriptions. ```gdb svd ``` -------------------------------- ### Setup BadUSB Module Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_badusb.md Initialize the USB HID interface. This should be called before any other BadUSB methods. It automatically unlocks the USB profile, which may interrupt the qFlipper connection. Custom VID/PID, manufacturer, and product names can be provided. ```javascript // Start USB HID with default parameters badusb.setup(); ``` ```javascript // Start USB HID with custom vid:pid = AAAA:BBBB, manufacturer and product strings not defined badusb.setup({ vid: 0xAAAA, pid: 0xBBBB }); ``` ```javascript // Start USB HID with custom vid:pid = AAAA:BBBB, manufacturer string = "Flipper Devices", product string = "Flipper Zero" badusb.setup({ vid: 0xAAAA, pid: 0xBBBB, mfrName: "Flipper Devices", prodName: "Flipper Zero" }); ``` -------------------------------- ### Flash Firmware with Packed Assets Source: https://github.com/next-flip/momentum-firmware/wiki/Assets/Asset-Packs When building the firmware directly, use the `fbt` tool to compile the firmware and pack your asset packs simultaneously. This command flashes the entire firmware, including your custom assets, to the device. ```bash ./fbt flash_usb_full ``` -------------------------------- ### run() Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_event_loop.md Starts the event loop. It will continue to process events until the stop() method is called. ```APIDOC ## run() Runs the event loop until it is stopped with `stop`. ``` -------------------------------- ### getBuiltin Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_gui__icon.md Gets a built-in firmware icon by its name. All known icons bundled with firmware are supported. ```APIDOC ## getBuiltin() ### Description Gets a built-in firmware icon by its name. All known icons bundled with firmware are supported. ### Parameters #### Path Parameters - **icon** (string) - Required - name of the icon ### Returns An `IconData` object. ``` -------------------------------- ### Extract substring with String.slice() Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_builtin.md Obtain a portion of a string between specified start and optional end indices. ```javascript "Example".slice(2) // "ample" ``` -------------------------------- ### Build Firmware with FBT Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/fbt.md Invoke FBT to build firmware, specifying configuration options and targets. Use the -c option for cleanup. ```bash ./fbt COMPACT=1 DEBUG=0 VERBOSE=1 updater_package copro_dist ``` ```bash ./fbt -c updater_package ``` -------------------------------- ### Deliver Assets with storage.py Source: https://github.com/next-flip/momentum-firmware/blob/dev/scripts/ReadMe.md This script delivers built firmware assets to the Flipper's internal storage. Replace `` with your device's serial port. ```bash python scripts/storage.py -p send build/latest/resources /ext ``` -------------------------------- ### Get character code with String.charCodeAt() Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_builtin.md Retrieve the Unicode character code at a specific index within a string. ```javascript "A".charCodeAt(0) // 65 ``` -------------------------------- ### String.slice() Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_builtin.md Extracts a section of a string and returns it as a new string, based on start and optional end indices. ```APIDOC ### String.slice() Return a substring between two indices. **Parameters** - The index to start the new string at - An optional non-inclusive index of where to stop the new string **Examples** ```js "Example".slice(2) // "ample" ``` ``` -------------------------------- ### Array.splice() Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_builtin.md Removes elements from an array starting at a specified index and returns the removed elements as a new array. ```APIDOC ### Array.splice() Removes elements from the array and returns them in a new array. **Parameters** - The index to start taking elements from - An optional count of how many elements to take **Examples** ```js let arr = [1, 2, 3]; arr.splice(1); // [2, 3] arr; // [1] ``` ``` -------------------------------- ### Build Full OTA Update Package Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/OTA.md Use this command to build a full update package that includes firmware, radio stack, and SD card resources. Ensure COMPACT is set to 1 and DEBUG to 0. ```shell ./fbt COMPACT=1 DEBUG=0 updater_package ``` -------------------------------- ### Get Filesystem Information Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_storage.md Fetches information about a filesystem, such as free space. Returns an fsInfo structure or undefined on failure. ```javascript let fsinfo = storage.fsInfo("/ext"); if (fsinfo === undefined) { print("Filesystem access error"); } else { print("Free space on the /ext filesystem:", fsinfo.freeSpace); } ``` -------------------------------- ### Get Absolute Value in JavaScript Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_math.md Return the absolute value of a number. If the input is negative, its sign is flipped to positive. ```javascript math.abs(-5); // 5 ``` -------------------------------- ### Download and Clone Repository Source: https://github.com/next-flip/momentum-firmware/blob/dev/ReadMe.md Use git to clone the repository. Ensure the --recursive flag is used to also clone submodules. ```bash git clone --recursive --jobs 8 https://github.com/Next-Flip/Momentum-Firmware.git cd Momentum-Firmware/ ``` -------------------------------- ### Get Battery Charge Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_flipper.md Retrieve the current battery charge percentage of the device. Returns a number between 0 and 100. ```javascript flipper.getBatteryCharge(); // 100 ``` -------------------------------- ### Build Flipper Zero Firmware Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/devboard/Debugging via the Devboard.md Build the Flipper Zero firmware using the Flipper Build Tool (FBT). This command should be run from the root of the cloned firmware repository. ```bash ./fbt ``` -------------------------------- ### makeDirectory(path) Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_storage.md Creates an empty directory. ```APIDOC ## makeDirectory(path) ### Description Creates an empty directory. ### Parameters - path (string): The path to the new directory. ### Returns - boolean: `true` on success, `false` on failure. ``` -------------------------------- ### ArrayBuffer.slice() Source: https://github.com/next-flip/momentum-firmware/blob/dev/documentation/js/js_builtin.md Creates a new ArrayBuffer containing a portion of the original buffer, specified by start and optional end indices. ```APIDOC ## ArrayBuffer object **Fields** - byteLength: The length of the buffer in bytes
### ArrayBuffer.slice() Creates an `ArrayBuffer` that contains a sub-part of the buffer. **Parameters** - The index to start the new buffer at - An optional non-inclusive index of where to stop the new buffer **Examples** ```js Uint8Array([1, 2, 3]).buffer.slice(0, 1) // ArrayBuffer([1]) ``` ``` -------------------------------- ### Create Slideshow with slideshow.py Source: https://github.com/next-flip/momentum-firmware/blob/dev/scripts/ReadMe.md Generates a slideshow file from a sequence of PNG frames. Place frames in `assets/slideshow/my_show/` named `frame_xx.png` and upload the generated `.slideshow` file to the Flipper. ```bash python scripts/slideshow.py -i assets/slideshow/my_show/ -o assets/slideshow/my_show/.slideshow ```