This commit is contained in:
qucchia 2022-07-27 13:31:13 +02:00
parent 7435ff4a63
commit ba30e2f018
7 changed files with 37 additions and 37 deletions

View File

@ -27,7 +27,7 @@ Improvements to Documentation are amazingly helpful, and are very rare so hugely
### Functions/Variables
If you want to change something in a [built-in function's documentation](http://www.espruino.com/Reference), look at the heading for the function on that page and there will be a right-arrow (⇒).
If you want to change something in a [built-in function's documentation](http://www.espruino.com/Reference), look at the heading for the function on that page and there will be a right-arrow (⇒).
If you click on that it will bring you to the area of Espruino's source code where the function *and the documentation for it* are stored. You can then edit the documentation in that file (above the function) on GitHub and issue a pull request - it's in Markdown format.
@ -56,7 +56,7 @@ Please [see here](http://www.espruino.com/Writing+Modules)
* Ensure that you are not contributing someone else's code, and that you are willing to add your code under Espruino's MPL Licence
* Make sure that what you do doesn't break the Espruino board or the other boards we build for. We can't check all the boards for every commit, so if you break something you'll annoy a whole bunch of people.
* Be aware that Espruino is designed for Microcontrollers - with very low amounts of flash and memory. Both are at a premium so don't statically allocate variables or do other stuff that will use up RAM.
* Don't add a whole bunch of indirection/abstraction for the sake of it - it'll probably just use of more of our precious memory.
* Don't add a whole bunch of indirection/abstraction for the sake of it - it'll probably just use more of our precious memory.
* If you add a new API, try and make it familiar to Arduino/JavaScript users.
* Please [RUN THE TESTS](tests/README.md) before and after your changes to check that there are no regressions
* Finally, please issue us a pull request to [www.github.com/espruino](https://www.github.com/espruino/Espruino) via GitHub. It's way easier for us to incorporate, give credit, and track changes that way.

View File

@ -43,7 +43,7 @@ info = {
'DEFINES+=-DCONFIG_NFCT_PINS_AS_GPIOS', # Don't use NFC - the pins are used for GPS
'DEFINES += -DNRF_USB=1 -DUSB', # USB only works if connected at startup
'DEFINES+=-DESPR_REGOUT0_1_8V=1', # Force RAK5010 nRF52 voltage regulator to 1.8v, which stops glitches in modem serial comms
'NRF_SDK15=1'
'NRF_SDK15=1',
'DEFINES+=-DBLUETOOTH_NAME_PREFIX=\'"iTracker"\'',
'DFU_PRIVATE_KEY=targets/nrf5x_dfu/dfu_private_key.pem',
'DFU_SETTINGS=--application-version 0xff --hw-version 52 --sd-req 0x8C,0x91',

View File

@ -1835,7 +1835,7 @@ Bangle.setLCDPower(1); // keep screen on
**When on full, the LCD draws roughly 40mA.** You can adjust
When brightness using `Bange.setLCDBrightness`.
When brightness using `Bangle.setLCDBrightness`.
*/
void jswrap_banglejs_setLCDPower(bool isOn) {
#ifdef ESPR_BACKLIGHT_FADE
@ -2147,7 +2147,7 @@ Set internal options used for gestures, etc...
* `wakeOnFaceUp` should the LCD turn on when the watch is turned face up? default = `false`
* `wakeOnTouch` should the LCD turn on when the touchscreen is pressed? default = `false`
* `wakeOnTwist` should the LCD turn on when the watch is twisted? default = `true`
* `twistThreshold` How much acceleration to register a twist of the watch strap? Can be negative for oppsite direction. default = `800`
* `twistThreshold` How much acceleration to register a twist of the watch strap? Can be negative for opposite direction. default = `800`
* `twistMaxY` Maximum acceleration in Y to trigger a twist (low Y means watch is facing the right way up). default = `-800`
* `twistTimeout` How little time (in ms) must a twist take from low->high acceleration? default = `1000`
* `gestureStartThresh` how big a difference before we consider a gesture started? default = `sqr(800)`
@ -2157,7 +2157,7 @@ Set internal options used for gestures, etc...
* `powerSave` after a minute of not being moved, Bangle.js will change the accelerometer poll interval down to 800ms (10x accelerometer samples).
On movement it'll be raised to the default 80ms. If `Bangle.setPollInterval` is used this is disabled, and for it to work the poll interval
must be either 80ms or 800ms. default = `true`. Setting `powerSave:false` will disable this automatic power saving, but will **not** change
the poll interval from its current value. If you desire a specific interval (eg the default 80ms) you must set it manually with `Bangle.setPollInterval(80)`
the poll interval from its current value. If you desire a specific interval (e.g. the default 80ms) you must set it manually with `Bangle.setPollInterval(80)`
after setting `powerSave:false`.
* `lockTimeout` how many milliseconds before the screen locks
* `lcdPowerTimeout` how many milliseconds before the screen turns off
@ -2275,7 +2275,7 @@ int jswrap_banglejs_isLCDOn() {
"ifdef" : "BANGLEJS"
}
This function can be used to lock or unlock Bangle.js
(eg whether buttons and touchscreen work or not)
(e.g. whether buttons and touchscreen work or not)
*/
void jswrap_banglejs_setLocked(bool isLocked) {
#if defined(TOUCH_I2C)
@ -2675,7 +2675,7 @@ void jswrap_banglejs_resetCompass() {
"#if" : "defined(DTNO1_F5) || defined(BANGLEJS_Q3) || defined(DICKENS)",
"typescript" : "setBarometerPower(isOn: boolean, appID: string): boolean;"
}
Set the power to the barometer IC. Once enbled, `Bangle.pressure` events
Set the power to the barometer IC. Once enabled, `Bangle.pressure` events
are fired each time a new barometer reading is available.
When on, the barometer draws roughly 50uA
@ -5327,7 +5327,7 @@ Currently supported interface types are:
* 'clockupdown' - called for clocks. Sets `Bangle.CLOCK=1`, allows a button to start the launcher, but also provides up/down functionality
* Bangle.js 1 BTN2 starts the launcher, BTN1/BTN3 call `cb(-1)` and `cb(1)`
* Bangle.js 2 BTN1 starts the launcher, touchscreen tap in top/bottom right hand side calls `cb(-1)` and `cb(1)`
* `{mode:"custom", ...}` allows you to specify custom handlers for different interations. See below.
* `{mode:"custom", ...}` allows you to specify custom handlers for different interactions. See below.
* `undefined` removes all user interaction code
While you could use setWatch/etc manually, the benefit here is that you don't end up with multiple `setWatch` instances, and

View File

@ -869,7 +869,7 @@ int jswrap_graphics_getBPP(JsVar *parent) {
"return" : ["JsVar","The instance of Graphics this was called on, to allow call chaining"],
"return_object" : "Graphics"
}
Reset the state of Graphics to the defaults (eg. Color, Font, etc)
Reset the state of Graphics to the defaults (e.g. Color, Font, etc)
that would have been used when Graphics was initialised.
*/
JsVar *jswrap_graphics_reset(JsVar *parent) {
@ -1503,7 +1503,7 @@ JsVarInt jswrap_graphics_getColorX(JsVar *parent, bool isForeground) {
This sets the 'clip rect' that subsequent drawing operations are clipped to
sit between.
These values are inclusive - eg `g.setClipRect(1,0,5,0)` will ensure that only
These values are inclusive - e.g. `g.setClipRect(1,0,5,0)` will ensure that only
pixel rows 1,2,3,4,5 are touched on column 0.
**Note:** For maximum flexibility on Bangle.js 1, the values here are not range checked. For normal
@ -2195,7 +2195,7 @@ Draw a string of text in the current font.
g.drawString("Hello World", 10, 10);
```
Images may also be embedded inside strings (eg to render Emoji or characters not in the current font).
Images may also be embedded inside strings (e.g. to render Emoji or characters not in the current font).
To do this, just add `0` then the image string ([about Images](http://www.espruino.com/Graphics#images-bitmaps))
For example:
@ -2467,7 +2467,7 @@ JsVar *jswrap_graphics_drawLineAA(JsVar *parent, double x1, double y1, double x2
"return" : ["JsVar","The instance of Graphics this was called on, to allow call chaining"],
"return_object" : "Graphics"
}
Draw a line from the last position of lineTo or moveTo to this position
Draw a line from the last position of `lineTo` or `moveTo` to this position
*/
JsVar *jswrap_graphics_lineTo(JsVar *parent, int x, int y) {
JsGraphics gfx; if (!graphicsGetFromVar(&gfx, parent)) return 0;
@ -3712,7 +3712,7 @@ Returns an object of the form:
bg2 : 0x0007, // accented background colour
fgH : 0xFFFF, // highlighted foreground colour
bgH : 0x02F7, // highlighted background colour
dark : true, // Is background dark (eg. foreground should be a light colour)
dark : true, // Is background dark (e.g. foreground should be a light colour)
}
```

View File

@ -176,7 +176,7 @@ bool jswrap_array_includes(JsVar *arr, JsVar *value, JsVarInt startIdx) {
"return" : ["JsVar","A String representing the Joined array"],
"typescript" : "join(separator?: string): string;"
}
Join all elements of this array together into one string, using 'separator' between them. eg. ```[1,2,3].join(' ')=='1 2 3'```
Join all elements of this array together into one string, using 'separator' between them. e.g. ```[1,2,3].join(' ')=='1 2 3'```
*/
JsVar *jswrap_array_join(JsVar *parent, JsVar *filler) {
if (!jsvIsIterable(parent)) return 0;

View File

@ -267,7 +267,7 @@ The length, in bytes, of the `ArrayBuffer`
"new(buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array;"
]
}
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (e.g. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
*/
/*JSON{
"type" : "constructor",
@ -287,7 +287,7 @@ Create a typed array based on the given input. Either an existing Array Buffer,
"new(buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray;"
]
}
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (e.g. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
Clamped arrays clamp their values to the allowed range, rather than 'wrapping'. e.g. after `a[0]=12345;`, `a[0]==255`.
*/
@ -309,7 +309,7 @@ Clamped arrays clamp their values to the allowed range, rather than 'wrapping'.
"new(buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array;"
]
}
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (e.g. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
*/
/*JSON{
"type" : "constructor",
@ -329,7 +329,7 @@ Create a typed array based on the given input. Either an existing Array Buffer,
"new(buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array;"
]
}
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (e.g. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
*/
/*JSON{
"type" : "constructor",
@ -349,7 +349,7 @@ Create a typed array based on the given input. Either an existing Array Buffer,
"new(buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array;"
]
}
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (e.g. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
*/
/*JSON{
"type" : "constructor",
@ -370,7 +370,7 @@ Create a typed array based on the given input. Either an existing Array Buffer,
"new(buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint24Array;"
]
}
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (e.g. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
*/
/*JSON{
"type" : "constructor",
@ -390,7 +390,7 @@ Create a typed array based on the given input. Either an existing Array Buffer,
"new(buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array;"
]
}
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (e.g. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
*/
/*JSON{
"type" : "constructor",
@ -410,7 +410,7 @@ Create a typed array based on the given input. Either an existing Array Buffer,
"new(buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array;"
]
}
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (e.g. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
*/
/*JSON{
"type" : "constructor",
@ -430,7 +430,7 @@ Create a typed array based on the given input. Either an existing Array Buffer,
"new(buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array;"
]
}
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (e.g. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
*/
/*JSON{
"type" : "constructor",
@ -450,7 +450,7 @@ Create a typed array based on the given input. Either an existing Array Buffer,
"new(buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array;"
]
}
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (e.g. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
*/
JsVar *jswrap_typedarray_constructor(JsVarDataArrayBufferViewType type, JsVar *arr, JsVarInt byteOffset, JsVarInt length) {
@ -558,7 +558,7 @@ void jswrap_arraybufferview_set(JsVar *parent, JsVar *arr, int offset) {
return;
}
// Copy with the case where we copy from one arraybuffer to another but they use the
// same data. If we copy forward (eg `a.set(a.subarray(),1)`) then we
// same data. If we copy forward (e.g. `a.set(a.subarray(),1)`) then we
// end up duplicating the same data, so we must copy in reverse.
if (jsvIsArrayBuffer(parent) && jsvIsArrayBuffer(arr)) {
JsVar *sa = jsvGetArrayBufferBackingString(parent, NULL);
@ -616,7 +616,7 @@ void jswrap_arraybufferview_set(JsVar *parent, JsVar *arr, int offset) {
}
Return an array which is made from the following: ```A.map(function) = [function(A[0]), function(A[1]), ...]```
**Note:** This returns an `ArrayBuffer` of the same type it was called on. To get an `Array`, use `Array.map`, eg. `[].map.call(myArray, x=>x+1)`
**Note:** This returns an `ArrayBuffer` of the same type it was called on. To get an `Array`, use `Array.map`, e.g. `[].map.call(myArray, x=>x+1)`
*/
JsVar *jswrap_arraybufferview_map(JsVar *parent, JsVar *funcVar, JsVar *thisVar) {
if (!jsvIsArrayBuffer(parent)) {
@ -761,7 +761,7 @@ Return `true` if the array includes the value, `false` otherwise
"return" : ["JsVar","A String representing the Joined array"],
"typescript" : "join(separator?: string): string;"
}
Join all elements of this array together into one string, using 'separator' between them. eg. ```[1,2,3].join(' ')=='1 2 3'```
Join all elements of this array together into one string, using 'separator' between them. e.g. ```[1,2,3].join(' ')=='1 2 3'```
*/
/*JSON{
"type" : "method",

View File

@ -197,7 +197,7 @@ int nativeCallGetCType() {
}
ADVANCED: This is a great way to crash Espruino if you're not sure what you are doing
Create a native function that executes the code at the given address. Eg. `E.nativeCall(0x08012345,'double (double,double)')(1.1, 2.2)`
Create a native function that executes the code at the given address, e.g. `E.nativeCall(0x08012345,'double (double,double)')(1.1, 2.2)`
If you're executing a thumb function, you'll almost certainly need to set the bottom bit of the address to 1.
@ -846,7 +846,7 @@ type Uint8ArrayResolvable =
This creates a Uint8Array from the given arguments. These are handled as follows:
* `Number` -> read as an integer, using the lowest 8 bits
* `String` -> use each character's numeric value (eg. `String.charCodeAt(...)`)
* `String` -> use each character's numeric value (e.g. `String.charCodeAt(...)`)
* `Array` -> Call itself on each element
* `ArrayBuffer` or Typed Array -> use the lowest 8 bits of each element
* `Object`:
@ -1021,7 +1021,7 @@ The Pico's default is `{M:8, N:336, P:4, Q:7, PCLK1:2, PCLK2:4}`, use
while keeping the peripherals running at the same speed (omitting PCLK1/2
will lead to the peripherals changing speed too).
On STM32F4 boards (eg. Espruino Pico), the USB clock needs to be kept at 48Mhz
On STM32F4 boards (e.g. Espruino Pico), the USB clock needs to be kept at 48Mhz
or USB will fail to work. You'll also experience USB instability if the processor
clock falls much below 48Mhz.
@ -1065,7 +1065,7 @@ any other *hardware* `Serial` device, or `null` to disable the console completel
```
{
force : bool // default false, force the console onto this device so it does not move
// if false, changes in connection state (eg USB/Bluetooth) can move
// if false, changes in connection state (e.g. USB/Bluetooth) can move
// the console automatically.
}
```
@ -1194,7 +1194,7 @@ Show fragmentation.
* ` ` is free space
* `#` is a normal variable
* `L` is a locked variable (address used, cannopt be moved)
* `L` is a locked variable (address used, cannot be moved)
* `=` represents data in a Flat String (must be contiguous)
*/
void jswrap_e_dumpFragmentation() {
@ -1322,7 +1322,7 @@ is taking up most of the available space.
If `depth>0` and the variable can be recursed into, an array listing all property
names (including internal Espruino names) and their sizes is returned. If
`depth>1` there is also a `more` field that inspects the objects's children's
`depth>1` there is also a `more` field that inspects the objects' children's
children.
For instance `E.getSizeOf(function(a,b) { })` returns `5`.
@ -1600,7 +1600,7 @@ Set the seed for the random number generator used by `Math.random()`.
"return" : ["int32","A random number"]
}
Unlike 'Math.random()' which uses a pseudo-random number generator, this
method reads from the internal voltage reference several times, xoring and
method reads from the internal voltage reference several times, XOR-ing and
rotating to try and make a relatively random value from the noise in the
signal.
*/
@ -1725,7 +1725,7 @@ To remove the password, call this function with no arguments.
could conceivably try every password in a dictionary.
**Note:** This password is stored in memory in plain text. If someone is able
to execute arbitrary JavaScript code on the device (eg, you use `eval` on input
to execute arbitrary JavaScript code on the device (e.g., you use `eval` on input
from unknown sources) or read the device's firmware then they may be able to
obtain it.
*/
@ -1873,7 +1873,7 @@ JsVar *jswrap_espruino_memoryMap(JsVar *baseAddress, JsVar *registers) {
"name" : "asm",
"generate" : "jswrap_espruino_asm",
"params" : [
["callspec","JsVar","The arguments this assembly takes - eg `void(int)`"],
["callspec","JsVar","The arguments this assembly takes - e.g. `void(int)`"],
["assemblycode","JsVarArray","One of more strings of assembler code"]
],
"typescript" : "asm(callspec: string, ...assemblycode: string[]): any;"