1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-13 05:06:30 +04:00

JS: Update and fix docs, fix Number.toString() with decimals (#4168)

* Update and fix JS docs

This could really use some automation, atleast for API reference
There are TypeScript definitions and typedocs, we don't need to be monkeys copying and reformatting this to API reference by hand

* Fix bugged character

* JS: Fix Number.toString() with decimals

* Fix

* Forgot this one

* docs: mention per-view child format

* Added @portasynthinca3 to docs' codeowners

* Updated CODEOWNERS

---------

Co-authored-by: Anna Antonenko <portasynthinca3@gmail.com>
Co-authored-by: hedger <hedger@nanode.su>
Co-authored-by: hedger <hedger@users.noreply.github.com>
This commit is contained in:
WillyJL
2025-04-01 11:02:12 +00:00
committed by GitHub
parent 933134ed94
commit d34ff3310d
19 changed files with 675 additions and 45 deletions

View File

@@ -10,8 +10,15 @@ Configure serial port. Should be called before all other methods.
**Parameters**
- Serial port name (usart, lpuart)
- 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**
@@ -69,7 +76,7 @@ Read from serial port until line break character.
**Parameters**
*(optional)* Timeout value in ms.
- *(optional)* Timeout value in ms.
**Returns**
@@ -84,6 +91,26 @@ serial.readln(5000); // Read with 5s timeout
<br>
## readAny()
Read any available amount of data from serial port, can help avoid starving your loop with small reads.
**Parameters**
- *(optional)* Timeout value in ms
**Returns**
A sting of received characters or undefined if nothing was received before timeout.
**Example**
```js
serial.readAny(); // Read without timeout
serial.readAny(5000); // Read with 5s timeout
```
<br>
## readBytes()
Read from serial port until line break character.
@@ -125,8 +152,21 @@ Index of matched pattern in input patterns list, undefined if nothing was found.
```js
// Wait for root shell prompt with 1s timeout, returns 0 if it was received before timeout, undefined if not
serial.expect("# ", 1000);
serial.expect("# ", 1000);
// Infinitely wait for one of two strings, should return 0 if the first string got matched, 1 if the second one
serial.expect([": not found", "Usage: "]);
```
<br>
## end()
Deinitializes serial port, allowing multiple initializations per script run.
**Example**
```js
serial.end();
// Configure LPUART port with baudrate = 115200
serial.setup("lpuart", 115200);
```