-
-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'OFW/dev' into dev
- Loading branch information
Showing
17 changed files
with
423 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
# js_badusb {#js_badusb} | ||
|
||
# BadUSB module | ||
```js | ||
let badusb = require("badusb"); | ||
``` | ||
# Methods | ||
## setup | ||
Start USB HID with optional parameters. Should be called before all other methods. | ||
|
||
### Parameters | ||
Configuration object (optional): | ||
- vid, pid (number): VID and PID values, both are mandatory | ||
- mfr_name (string): Manufacturer name (32 ASCII characters max), optional | ||
- prod_name (string): Product name (32 ASCII characters max), 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, mfr_name: "Flipper Devices", prod_name: "Flipper Zero" }); | ||
``` | ||
|
||
## isConnected | ||
Returns USB connection state. | ||
|
||
### Example: | ||
```js | ||
if (badusb.isConnected()) { | ||
// Do something | ||
} else { | ||
// Show an error | ||
} | ||
``` | ||
|
||
## press | ||
Press and release a key. | ||
|
||
### Parameters | ||
Key or modifier name, key code. | ||
|
||
See a list of key names below. | ||
|
||
### Examples: | ||
```js | ||
badusb.press("a"); // Press "a" key | ||
badusb.press("A"); // SHIFT + "a" | ||
badusb.press("CTRL", "a"); // CTRL + "a" | ||
badusb.press("CTRL", "SHIFT", "ESC"); // CTRL + SHIFT + ESC combo | ||
badusb.press(98); // Press key with HID code (dec) 98 (Numpad 0 / Insert) | ||
badusb.press(0x47); // Press key with HID code (hex) 0x47 (Scroll lock) | ||
``` | ||
|
||
## hold | ||
Hold a key. Up to 5 keys (excluding modifiers) can be held simultaneously. | ||
|
||
### Parameters | ||
Same as `press` | ||
|
||
### Examples: | ||
```js | ||
badusb.hold("a"); // Press and hold "a" key | ||
badusb.hold("CTRL", "v"); // Press and hold CTRL + "v" combo | ||
``` | ||
|
||
## release | ||
Release a previously hold key. | ||
|
||
### Parameters | ||
Same as `press` | ||
|
||
Release all keys if called without parameters | ||
|
||
### Examples: | ||
```js | ||
badusb.release(); // Release all keys | ||
badusb.release("a"); // Release "a" key | ||
``` | ||
|
||
Print a string. | ||
|
||
### Parameters | ||
- A string to print | ||
- (optional) delay between key presses | ||
|
||
### Examples: | ||
```js | ||
badusb.print("Hello, world!"); // print "Hello, world!" | ||
badusb.print("Hello, world!", 100); // Add 100ms delay between key presses | ||
``` | ||
|
||
## println | ||
Same as `print` but ended with "ENTER" press. | ||
|
||
### Parameters | ||
- A string to print | ||
- (optional) delay between key presses | ||
|
||
### Examples: | ||
```js | ||
badusb.println("Hello, world!"); // print "Hello, world!" and press "ENTER" | ||
``` | ||
|
||
# Key names list | ||
|
||
## Modifier keys | ||
|
||
| Name | | ||
| ------------- | | ||
| CTRL | | ||
| SHIFT | | ||
| ALT | | ||
| GUI | | ||
|
||
## Special keys | ||
|
||
| Name | Notes | | ||
| ------------------ | ---------------- | | ||
| DOWN | Down arrow | | ||
| LEFT | Left arrow | | ||
| RIGHT | Right arrow | | ||
| UP | Up arrow | | ||
| ENTER | | | ||
| DELETE | | | ||
| BACKSPACE | | | ||
| END | | | ||
| HOME | | | ||
| ESC | | | ||
| INSERT | | | ||
| PAGEUP | | | ||
| PAGEDOWN | | | ||
| CAPSLOCK | | | ||
| NUMLOCK | | | ||
| SCROLLLOCK | | | ||
| PRINTSCREEN | | | ||
| PAUSE | Pause/Break key | | ||
| SPACE | | | ||
| TAB | | | ||
| MENU | Context menu key | | ||
| Fx | F1-F24 keys | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Built-in methods {#js_builtin} | ||
|
||
## require | ||
Load a module plugin. | ||
|
||
### Parameters | ||
- Module name | ||
|
||
### Examples: | ||
```js | ||
let serial = require("serial"); // Load "serial" module | ||
``` | ||
|
||
## delay | ||
### Parameters | ||
- Delay value in ms | ||
|
||
### Examples: | ||
```js | ||
delay(500); // Delay for 500ms | ||
``` | ||
Print a message on a screen console. | ||
|
||
### Parameters | ||
The following argument types are supported: | ||
- String | ||
- Number | ||
- Bool | ||
- undefined | ||
|
||
### Examples: | ||
```js | ||
print("string1", "string2", 123); | ||
``` | ||
|
||
## console.log | ||
## console.warn | ||
## console.error | ||
## console.debug | ||
Same as `print`, but output to serial console only, with corresponding log level. | ||
|
||
## to_string | ||
Convert a number to string. | ||
|
||
### Examples: | ||
```js | ||
to_string(123) | ||
``` | ||
## to_hex_string | ||
Convert a number to string(hex format). | ||
|
||
### Examples: | ||
```js | ||
to_hex_string(0xFF) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Data types {#js_data_types} | ||
|
||
Here is a list of common data types used by mJS. | ||
- string - sequence of single byte characters, no UTF8 support | ||
- number | ||
- boolean | ||
- foreign - C function or data pointer | ||
- undefined | ||
- null | ||
- object - a data structure with named fields | ||
- array - special type of object, all items have indexes and equal types | ||
- ArrayBuffer - raw data buffer | ||
- DataView - provides interface for accessing ArrayBuffer contents |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# js_dialog {#js_dialog} | ||
|
||
# Dialog module | ||
```js | ||
let dialog = require("dialog"); | ||
``` | ||
# Methods | ||
|
||
## message | ||
Show a simple message dialog with header, text and "OK" button. | ||
|
||
### Parameters | ||
- Dialog header text | ||
- Dialog text | ||
|
||
### Retuns | ||
true if central button was pressed, false if the dialog was closed by back key press | ||
|
||
### Examples: | ||
```js | ||
dialog.message("Dialog demo", "Press OK to start"); | ||
``` | ||
|
||
## custom | ||
More complex dialog with configurable buttons | ||
|
||
### Parameters | ||
Configuration object with the following fileds: | ||
- header: Dialog header text | ||
- text: Dialog text | ||
- button_left: (optional) left button name | ||
- button_right: (optional) right button name | ||
- button_center: (optional) central button name | ||
|
||
### Retuns | ||
Name of pressed button or empty string if the dialog was closed by back key press | ||
|
||
### Examples: | ||
```js | ||
let dialog_params = ({ | ||
header: "Dialog header", | ||
text: "Dialog text", | ||
button_left: "Left", | ||
button_right: "Right", | ||
button_center: "OK" | ||
}); | ||
|
||
dialog.custom(dialog_params); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# js_notification {#js_notification} | ||
|
||
# Notification module | ||
```js | ||
let notify = require("notification"); | ||
``` | ||
# Methods | ||
|
||
## success | ||
"Success" flipper notification message | ||
|
||
### Examples: | ||
```js | ||
notify.success(); | ||
``` | ||
|
||
## error | ||
"Error" flipper notification message | ||
|
||
### Examples: | ||
```js | ||
notify.error(); | ||
``` | ||
|
||
## blink | ||
Blink notification LED | ||
|
||
### Parameters | ||
- Blink color (blue/red/green/yellow/cyan/magenta) | ||
- Blink type (short/long) | ||
|
||
### Examples: | ||
```js | ||
notify.blink("red", "short"); // Short blink of red LED | ||
notify.blink("green", "short"); // Long blink of green LED | ||
``` |
Oops, something went wrong.