Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Added JS API Documentation #38

Merged
merged 1 commit into from
Mar 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 148 additions & 0 deletions documentation/JavaScript.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@

# JavaScript scripting API (WIP)
## Note: This documentation is still work in progress!
Todo:
- Add missing parameters
- Add missing returns
- Add examples

## Description
Momentum supports JavaScript scripting using [mjs](https://github.com/cesanta/mjs).
**Note: Read about mjs's limitations in the link above! You will experience alot of missing js features (e.g. createTimeout).**

## API
### SubGHZ
`const subghz = require("subghz");`
#### Methods
- setup(): void
- setRx(): void
- setIdle(): void
- getRssi(): number
- getState(): string
- getFrequency(): number
- setFrequency(freq: number): number | undefined
- isExternal(): bool
- transmitFile(file: string): bool | undefined

### Usbdisk
`const usbdisk = require("usbdisk");`
#### Methods
- createImage(file: string, size: number): undefined
- start(file: string): undefined
- stop(): undefined
- wasEjected(): bool | undefined

### BadUsb
`const badusb = require("badusb");`
#### Methods
- setup
- quit
- isConnected
- press
- hold
- release
- print
- println
-
### BleBeacon
`const blebeacon = require("blebeacon");`
#### Methods
- isActive
- setConfig
- setData
- start
- stop
- keepAlive

### Dialog
`const dialog = require("dialog");`
#### Methods
- message
- custom
- pickFile

### Flipper
`const flipper= require("flipper");`
#### Methods
- getModel
- getName
- getBatteryCharge

### Gpio
`const gpio = require("gpio");`
#### Methods
- init
- write
- read

### Keyboard
`const keyboard = require("keyboard");`
#### Methods
- setHeader
- text
- byte

### Math
`const math = require("math");`
#### Methods
- abs
- acos
- acosh
- asin
- asinh
- atan
- atan2
- atanh
- cbrt
- ceil
- clz32
- cos
- exp
- floor
- log
- max
- min
- pow
- random
- sign
- sin
- sqrt
- trunc
- PI
- E

### Notification
`const notify = require("notification");`
#### Methods
- success
- error
- blink

### Serial
`const serial = require("serial");`
#### Methods
- setup
- write
- read
- readln
- readBytes
- expect

### Storage
`const storage = require("storage");`
#### Methods
- read
- write
- append
- exists
- remove
- virtualInit
- virtualMount
- virtualQuit

### Submenu
`const submenu = require("submenu");`
#### Methods
- addItem
- setHeader
- show
Loading