### Example Source: https://developer.flipper.net/flipperzero/doxygen/js_gpio.html This example demonstrates how to get a GPIO pin, initialize it as an output, write a high signal, and then a low signal. ```javascript 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); ``` -------------------------------- ### Setup USB HID Source: https://developer.flipper.net/flipperzero/doxygen/js_badusb.html Examples of how to set up the USB HID with default and custom parameters. ```javascript let badusb = require("badusb"); // 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" }); ``` -------------------------------- ### Application assets example Source: https://developer.flipper.net/flipperzero/doxygen/example__apps__assets_8c.html Application assets example. ```c #include #include #include #include ``` -------------------------------- ### Example Application Source: https://developer.flipper.net/flipperzero/doxygen/example__view__holder_8c.html This is the main function for the example application demonstrating the ViewHolder library. ```C #include #include #include #include int32_t example_view_holder_app(void *arg) ``` -------------------------------- ### Source code Source: https://developer.flipper.net/flipperzero/doxygen/example_app_data.html Source code for this example can be found here. ```c #define APP_DATA_PATH(path)IDE_PATH(path) ``` -------------------------------- ### Application data example. Source: https://developer.flipper.net/flipperzero/doxygen/example__apps__data_8c.html This snippet shows the basic includes and defines for the application data example. ```c #include #include ``` -------------------------------- ### Source code Source: https://developer.flipper.net/flipperzero/doxygen/example_app_assets.html Source code for this example can be found here. ```text Source code for this example can be found here. ``` -------------------------------- ### Build Partial Update Packages Source: https://developer.flipper.net/flipperzero/doxygen/ota_updates.html Example command to build a package for installing the BLE FULL stack using the update.py script. ```bash scripts/update.py generate \ -t f7 -d r13.3_full -v "BLE FULL 13.3" \ --stage dist/f7/flipper-z-f7-updater-*.bin \ --radio lib/stm32wb_copro/firmware/stm32wb5x_BLE_Stack_full_fw.bin \ --radiotype ble_full ``` -------------------------------- ### Plugin host application example Source: https://developer.flipper.net/flipperzero/doxygen/example__plugins_8c.html Loads a single plugin and calls its methods. ```c #include "plugin_interface.h" #include #include #include #include ## Macros --- #define | **TAG** "ExamplePlugins" ## Functions --- int32_t | **example_plugins_app** (void *p) ``` -------------------------------- ### Get Start Level Source: https://developer.flipper.net/flipperzero/doxygen/digital__signal_8h.html Get the current start level contained in the DigitalSignal instance. ```c bool digital_signal_get_start_level(const DigitalSignal *signal); ``` -------------------------------- ### Macros Source: https://developer.flipper.net/flipperzero/doxygen/example__plugins__multi_8c.html TAG macro definition for logging. ```c #define TAG "ExamplePlugins" ``` -------------------------------- ### Get Device Model Source: https://developer.flipper.net/flipperzero/doxygen/js_flipper.html Example of how to get the device model using the getModel() method. ```javascript flipper.getModel(); // "Flipper Zero" ``` -------------------------------- ### Includes Source: https://developer.flipper.net/flipperzero/doxygen/example__view__dispatcher_8c.html Required header files for the ViewDispatcher example. ```c #include #include #include #include ``` -------------------------------- ### Get Battery Charge Source: https://developer.flipper.net/flipperzero/doxygen/js_flipper.html Example of how to get the battery charge percentage using the getBatteryCharge() method. ```javascript flipper.getBatteryCharge(); // 100 ``` -------------------------------- ### Get Virtual Dolphin Name Source: https://developer.flipper.net/flipperzero/doxygen/js_flipper.html Example of how to get the name of the virtual dolphin using the getName() method. ```javascript flipper.getName(); // "Fur1pp44" ``` -------------------------------- ### Functions Source: https://developer.flipper.net/flipperzero/doxygen/example__plugins__multi_8c.html Main application function for the multi-plugin example. ```c int32_t example_plugins_multi_app(void *p); ``` -------------------------------- ### Array.splice() Example Source: https://developer.flipper.net/flipperzero/doxygen/js_builtin.html Removes elements from an array starting at a specified index and returns them in a new array. ```javascript let arr = [1, 2, 3]; arr.splice(1); // [2, 3] arr; // [1] ``` -------------------------------- ### Example Usage Source: https://developer.flipper.net/flipperzero/doxygen/js_gui__loading.html Demonstrates how to import and use the loading view module. ```javascript let eventLoop = require("event_loop"); let gui = require("gui"); let loadingView = require("gui/loading"); ``` -------------------------------- ### bit_buffer_get_byte_from_bit Source: https://developer.flipper.net/flipperzero/doxygen/bit__buffer_8h_source.html Get a byte value starting from the specified bit index in a BitBuffer instance. ```c uint8_t bit_buffer_get_byte_from_bit(const BitBuffer *buf, size_t index_bits) ``` -------------------------------- ### Serial Setup Example Source: https://developer.flipper.net/flipperzero/doxygen/js_serial.html Configures the LPUART port with a baudrate of 115200. ```javascript serial.setup("lpuart", 115200); ``` -------------------------------- ### end() and setup() Example Source: https://developer.flipper.net/flipperzero/doxygen/js_serial.html Deinitializes the serial port and configures it with a specified baudrate. ```javascript serial.end(); // Configure LPUART port with baudrate = 115200 serial.setup("lpuart", 115200); ``` -------------------------------- ### Example for building an app from Rust sources Source: https://developer.flipper.net/flipperzero/doxygen/app_manifests.html Demonstrates how to use `fap_extbuild` to compile Rust code for a FAP. ```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", ), ) ``` -------------------------------- ### Key File Example Source: https://developer.flipper.net/flipperzero/doxygen/subghz_file_format.html Example of a standard preset Key file in Flipper SubGhz format. ```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 ``` -------------------------------- ### Getting and Setting Start Level Source: https://developer.flipper.net/flipperzero/doxygen/digital__signal_8h_source.html Functions to retrieve and set the initial signal level of a DigitalSignal instance. ```c bool digital_signal_get_start_level(const DigitalSignal* signal); void digital_signal_set_start_level(DigitalSignal* signal, bool level); ``` -------------------------------- ### Mifare Classic Key Dictionary Example Source: https://developer.flipper.net/flipperzero/doxygen/nfc_file_format.html Example of a Mifare Classic key dictionary file, listing common and mfoc-derived keys as hex strings. Lines starting with '#' are comments and blank lines are ignored. ```Mifare Classic Key Dictionary # Key dictionary from https://github.com/ikarus23/MifareClassicTool.git # More well known keys! # Standard keys FFFFFFFFFFFF A0A1A2A3A4A5 D3F7D3F7D3F7 000000000000 # Keys from mfoc B0B1B2B3B4B5 4D3A99C351DD 1A982C7E459A AABBCCDDEEFF 714C5C886E97 587EE5F9350F A0478CC39091 533CB6C723F6 8FD0A4F256E9 ... ``` -------------------------------- ### Mifare Ultralight C Key Dictionary Example Source: https://developer.flipper.net/flipperzero/doxygen/nfc_file_format.html Example of a Mifare Ultralight C key dictionary file, showing various sample keys as hex strings. Lines starting with '#' are comments and blank lines are ignored. ```Mifare Ultralight C Key Dictionary # Hexadecimal-Reversed Sample Key 12E4143455F495649454D4B414542524 # Byte-Reversed Sample Key (!NACUOYFIEMKAERB) 214E4143554F594649454D4B41455242 # Sample Key (BREAKMEIFYOUCAN!) 425245414B4D454946594F5543414E21 # Semnox Key (IEMKAERB!NACUOY ) 49454D4B41455242214E4143554F5900 # Modified Semnox Key (IEMKAERB!NACUOYF) 49454D4B41455242214E4143554F5946 ... ``` -------------------------------- ### Example using ViewDispatcher Source: https://developer.flipper.net/flipperzero/doxygen/js_gui.html An example demonstrating the use of the ViewDispatcher with multiple views. ```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(); ```