Skip to content

Commit

Permalink
more doc changes to encourage linking
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Oct 25, 2024
1 parent dd9d49c commit 87a4376
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 87 deletions.
6 changes: 3 additions & 3 deletions libs/compression/jswrap_heatshrink.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ If you'd like a way to perform compression/decompression on desktop, check out h
"params" : [
["data","JsVar","The data to compress"]
],
"return" : ["JsVar","Returns the result as an ArrayBuffer"],
"return" : ["JsVar","Returns the result as an `ArrayBuffer`"],
"return_object" : "ArrayBuffer",
"ifndef" : "SAVE_ON_FLASH"
}
Compress the data supplied as input, and return heatshrink encoded data as an ArrayBuffer.
Compress the data supplied as input, and return heatshrink encoded data as an `ArrayBuffer`.
No type information is stored, and the `data` argument is treated as an array of bytes
(whether it is a `String`/`Uint8Array` or even `Uint16Array`), so the result of
decompressing any compressed data will always be an ArrayBuffer.
decompressing any compressed data will always be an `ArrayBuffer`.
If you'd like a way to perform compression/decompression on desktop, check out https://github.com/espruino/EspruinoWebTools#heatshrinkjs
*/
Expand Down
10 changes: 5 additions & 5 deletions libs/crypto/jswrap_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ Performs a SHA512 hash and returns the result as a 64 byte ArrayBuffer
["salt","JsVar","Salt for turning passphrase into a key"],
["options","JsVar","Object of Options, `{ keySize: 8 (in 32 bit words), iterations: 10, hasher: 'SHA1'/'SHA224'/'SHA256'/'SHA384'/'SHA512' }`"]
],
"return" : ["JsVar","Returns an ArrayBuffer"],
"return" : ["JsVar","Returns an `ArrayBuffer`"],
"return_object" : "ArrayBuffer",
"ifdef" : "USE_TLS"
}
Expand Down Expand Up @@ -454,10 +454,10 @@ static NO_INLINE JsVar *jswrap_crypto_AEScrypt(JsVar *message, JsVar *key, JsVar
"generate" : "jswrap_crypto_AES_encrypt",
"params" : [
["passphrase","JsVar","Message to encrypt"],
["key","JsVar","Key to encrypt message - must be an ArrayBuffer of 128, 192, or 256 BITS"],
["key","JsVar","Key to encrypt message - must be an `ArrayBuffer` of 128, 192, or 256 BITS"],
["options","JsVar","[optional] An object, may specify `{ iv : new Uint8Array(16), mode : 'CBC|CFB|CTR|OFB|ECB' }`"]
],
"return" : ["JsVar","Returns an ArrayBuffer"],
"return" : ["JsVar","Returns an `ArrayBuffer`"],
"return_object" : "ArrayBuffer",
"ifdef" : "USE_AES"
}
Expand All @@ -473,10 +473,10 @@ JsVar *jswrap_crypto_AES_encrypt(JsVar *message, JsVar *key, JsVar *options) {
"generate" : "jswrap_crypto_AES_decrypt",
"params" : [
["passphrase","JsVar","Message to decrypt"],
["key","JsVar","Key to encrypt message - must be an ArrayBuffer of 128, 192, or 256 BITS"],
["key","JsVar","Key to encrypt message - must be an `ArrayBuffer` of 128, 192, or 256 BITS"],
["options","JsVar","[optional] An object, may specify `{ iv : new Uint8Array(16), mode : 'CBC|CFB|CTR|OFB|ECB' }`"]
],
"return" : ["JsVar","Returns an ArrayBuffer"],
"return" : ["JsVar","Returns an `ArrayBuffer`"],
"return_object" : "ArrayBuffer",
"ifdef" : "USE_AES"
}
Expand Down
56 changes: 28 additions & 28 deletions libs/graphics/jswrap_graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,10 @@ force a full update of the screen.
"type" : "property",
"class" : "Graphics",
"name" : "buffer",
"return" : ["JsVar","An ArrayBuffer (or not defined on Graphics instances not created with `Graphics.createArrayBuffer`)"],
"return" : ["JsVar","An ArrayBuffer (or not defined on `Graphics` instances not created with `Graphics.createArrayBuffer`)"],
"typescript" : "buffer: IsBuffer extends true ? ArrayBuffer : undefined"
}
On Graphics instances with an offscreen buffer, this is an `ArrayBuffer` that
On `Graphics` instances with an offscreen buffer, this is an `ArrayBuffer` that
provides access to the underlying pixel data.
```
Expand Down Expand Up @@ -607,12 +607,12 @@ static bool isValidBPP(int bpp) {
"`buffer` = if specified, createArrayBuffer won't create a new buffer but will use the given one"
]]
],
"return" : ["JsVar","The new Graphics object"],
"return" : ["JsVar","The new `Graphics` object"],
"return_object" : "Graphics",
"typescript" : "createArrayBuffer(width: number, height: number, bpp: number, options?: { zigzag?: boolean, vertical_byte?: boolean, msb?: boolean, color_order?: \"rgb\" | \"rbg\" | \"brg\" | \"bgr\" | \"grb\" | \"gbr\" }): Graphics<true>;"
}
Create a Graphics object that renders to an Array Buffer. This will have a field
called 'buffer' that can get used to get at the buffer itself
Create a `Graphics` object that renders to an `ArrayBuffer`. This will have a field
called `'buffer'` that can get used to get at the buffer itself
*/
JsVar *jswrap_graphics_createArrayBuffer(int width, int height, int bpp, JsVar *options) {
if (width<=0 || height<=0 || width>32767 || height>32767) {
Expand Down Expand Up @@ -699,11 +699,11 @@ JsVar *jswrap_graphics_createArrayBuffer(int width, int height, int bpp, JsVar *
["bpp","int32","Number of bits per pixel"],
["callback","JsVar","A function of the form ```function(x,y,col)``` that is called whenever a pixel needs to be drawn, or an object with: ```{setPixel:function(x,y,col),fillRect:function(x1,y1,x2,y2,col)}```. All arguments are already bounds checked."]
],
"return" : ["JsVar","The new Graphics object"],
"return" : ["JsVar","The new `Graphics` object"],
"return_object" : "Graphics",
"typescript" : "createCallback(width: number, height: number, bpp: number, callback: ((x: number, y: number, col: number) => void) | { setPixel: (x: number, y: number, col: number) => void; fillRect: (x1: number, y1: number, x2: number, y2: number, col: number) => void }): Graphics<false>;"
}
Create a Graphics object that renders by calling a JavaScript callback function
Create a `Graphics` object that renders by calling a JavaScript callback function
to draw pixels
*/
JsVar *jswrap_graphics_createCallback(int width, int height, int bpp, JsVar *callback) {
Expand Down Expand Up @@ -759,10 +759,10 @@ JsVar *jswrap_graphics_createCallback(int width, int height, int bpp, JsVar *cal
["height","int32","Pixels high"],
["bpp","int32","Bits per pixel (8,16,24 or 32 supported)"]
],
"return" : ["JsVar","The new Graphics object"],
"return" : ["JsVar","The new `Graphics` object"],
"return_object" : "Graphics"
}
Create a Graphics object that renders to SDL window (Linux-based devices only)
Create a `Graphics` object that renders to SDL window (Linux-based devices only)
*/
JsVar *jswrap_graphics_createSDL(int width, int height, int bpp) {
if (width<=0 || height<=0 || width>32767 || height>32767) {
Expand Down Expand Up @@ -905,18 +905,18 @@ JsVar *jswrap_graphics_createImage(JsVar *data) {
"class" : "Graphics",
"name" : "getWidth",
"generate_full" : "jswrap_graphics_getWidthOrHeight(parent, false)",
"return" : ["int","The width of this Graphics instance"]
"return" : ["int","The width of this `Graphics` instance"]
}
The width of this Graphics instance
The width of this `Graphics` instance
*/
/*JSON{
"type" : "method",
"class" : "Graphics",
"name" : "getHeight",
"generate_full" : "jswrap_graphics_getWidthOrHeight(parent, true)",
"return" : ["int","The height of this Graphics instance"]
"return" : ["int","The height of this `Graphics` instance"]
}
The height of this Graphics instance
The height of this `Graphics` instance
*/
int jswrap_graphics_getWidthOrHeight(JsVar *parent, bool height) {
JsGraphics gfx; if (!graphicsGetFromVar(&gfx, parent)) return 0;
Expand All @@ -927,9 +927,9 @@ int jswrap_graphics_getWidthOrHeight(JsVar *parent, bool height) {
"class" : "Graphics",
"name" : "getBPP",
"generate" : "jswrap_graphics_getBPP",
"return" : ["int","The bits per pixel of this Graphics instance"]
"return" : ["int","The bits per pixel of this `Graphics` instance"]
}
The number of bits per pixel of this Graphics instance
The number of bits per pixel of this `Graphics` instance
**Note:** Bangle.js 2 behaves a little differently here. The display is 3 bit,
so `getBPP` returns 3 and `asBMP`/`asImage`/etc return 3 bit images. However in
Expand Down Expand Up @@ -3328,8 +3328,8 @@ Image can be:
* A String where the the first few bytes are:
`width,height,bpp,[transparent,]image_bytes...`. If a transparent colour is
specified the top bit of `bpp` should be set.
* An ArrayBuffer Graphics object (if `bpp<8`, `msb:true` must be set) - this is
disabled on devices without much flash memory available. If a Graphics object
* An ArrayBuffer `Graphics` object (if `bpp<8`, `msb:true` must be set) - this is
disabled on devices without much flash memory available. If a `Graphics` object
is supplied, it can also contain transparent/palette fields as if it were
an image.
Expand Down Expand Up @@ -3768,7 +3768,7 @@ JsVar *jswrap_graphics_drawImages(JsVar *parent, JsVar *layersVar, JsVar *option
"asImage(type: \"string\"): string;"
]
}
Return this Graphics object as an Image that can be used with
Return this `Graphics` object as an Image that can be used with
`Graphics.drawImage`. Check out [the Graphics reference
page](http://www.espruino.com/Graphics#images-bitmaps) for more information on
images.
Expand All @@ -3778,7 +3778,7 @@ Will return undefined if data can't be allocated for the image.
The image data itself will be referenced rather than copied if:
* An image `object` was requested (not `string`)
* The Graphics instance was created with `Graphics.createArrayBuffer`
* The `Graphics` instance was created with `Graphics.createArrayBuffer`
* Is 8 bpp *OR* the `{msb:true}` option was given
* No other format options (zigzag/etc) were given
Expand Down Expand Up @@ -4080,7 +4080,7 @@ JsVar *jswrap_graphics_blit(JsVar *parent, JsVar *options) {
"return" : ["JsVar","A String representing the Graphics as a Windows BMP file (or 'undefined' if not possible)"],
"typescript" : "asBMP(): string;"
}
Create a Windows BMP file from this Graphics instance, and return it as a
Create a Windows BMP file from this `Graphics` instance, and return it as a
String.
*/
JsVar *jswrap_graphics_asBMP_X(JsVar *parent, bool printBase64) {
Expand Down Expand Up @@ -4263,10 +4263,10 @@ inline automatically.
This is identical to `console.log(g.asURL())` - it is just a convenient function
for easy debugging and producing screenshots of what is currently in the
Graphics instance.
`Graphics` instance.
**Note:** This may not work on some bit depths of Graphics instances. It will
also not work for the main Graphics instance of Bangle.js 1 as the graphics on
**Note:** This may not work on some bit depths of `Graphics` instances. It will
also not work for the main `Graphics` instance of Bangle.js 1 as the graphics on
Bangle.js 1 are stored in write-only memory.
*/
void jswrap_graphics_dump(JsVar *parent) {
Expand Down Expand Up @@ -4478,9 +4478,9 @@ JsVar *jswrap_graphics_transformVertices(JsVar *parent, JsVar *verts, JsVar *tra
"return" : ["JsVar","The instance of Graphics this was called on, to allow call chaining"],
"return_object" : "Graphics"
}
Flood fills the given Graphics instance out from a particular point.
Flood fills the given `Graphics` instance out from a particular point.
**Note:** This only works on Graphics instances that support readback with `getPixel`. It
**Note:** This only works on `Graphics` instances that support readback with `getPixel`. It
is also not capable of filling over dithered patterns (eg non-solid colours on Bangle.js 2)
*/
static bool _jswrap_graphics_floodFill_inside(JsGraphics *gfx, int x, int y, unsigned int col) {
Expand Down Expand Up @@ -4576,7 +4576,7 @@ Returns an object of the form:
```
These values can then be passed to `g.setColor`/`g.setBgColor` for example
`g.setColor(g.theme.fg2)`. When the Graphics instance is reset, the background
`g.setColor(g.theme.fg2)`. When the `Graphics` instance is reset, the background
color is automatically set to `g.theme.bg` and foreground is set to
`g.theme.fg`.
Expand Down Expand Up @@ -4679,8 +4679,8 @@ JsVar *jswrap_graphics_setTheme(JsVar *parent, JsVar *theme) {
"return" : ["JsVar","The instance of Graphics this was called on, to allow call chaining"],
"return_object" : "Graphics"
}
Perform a filter on the current Graphics instance. Requires the Graphics
instance to support readback (eg `getPixel` should work), and only uses
Perform a filter on the current `Graphics` instance. Requires the Graphics
instance to support readback (eg `.getPixel` should work), and only uses
8 bit values for buffer and filter.
```
Expand Down
40 changes: 20 additions & 20 deletions libs/graphics/lcd_spi_unbuf.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
* This file is part of Espruino, a JavaScript interpreter for Microcontrollers
*
* Copyright (C) 2020 Gordon Williams <[email protected]>, atc1441, MaBecker, Jeffmer
* Copyright (C) 2020 Gordon Williams <[email protected]>, atc1441, MaBecker, Jeffmer
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* ----------------------------------------------------------------------------
* Graphics Backend for drawing to SPI displays in unbuffered mode
* Graphics Backend for drawing to SPI displays in unbuffered mode
* ----------------------------------------------------------------------------
*/

Expand Down Expand Up @@ -36,14 +36,14 @@ static uint16_t _chunk_buffer[LCD_SPI_UNBUF_LEN];
static int _chunk_index = 0;
IOEventFlags _device;

static void spi_cmd(const uint8_t cmd)
static void spi_cmd(const uint8_t cmd)
{
jshPinSetValue(_pin_dc, 0);
jshSPISend(_device, cmd);
jshPinSetValue(_pin_dc, 1);
}

static inline void spi_data(const uint8_t *data, int len)
static inline void spi_data(const uint8_t *data, int len)
{
jshSPISendMany(_device, data, NULL, len, NULL);
}
Expand Down Expand Up @@ -89,8 +89,8 @@ bool jsspiPopulateOptionsInfo( JshLCD_SPI_UNBUFInfo *inf, JsVar *options){
{"height", JSV_INTEGER , &inf->height},
{"colstart", JSV_INTEGER , &inf->colstart},
{"rowstart", JSV_INTEGER , &inf->rowstart},
};
};

return jsvReadConfigObject(options, configs, sizeof(configs) / sizeof(jsvConfigObject))
&& inf->pinDC != PIN_UNDEFINED;
}
Expand All @@ -113,14 +113,14 @@ bool jswrap_lcd_spi_unbuf_idle() {
["device","JsVar","The used SPI device"],
["options","JsVar","An Object containing extra information"]
],
"return" : ["JsVar","The new Graphics object"],
"return" : ["JsVar","The new `Graphics` object"],
"return_object" : "Graphics"
}*/
JsVar *jswrap_lcd_spi_unbuf_connect(JsVar *device, JsVar *options) {
JsVar *jswrap_lcd_spi_unbuf_connect(JsVar *device, JsVar *options) {
JsVar *parent = jspNewObject(0, "Graphics");
if (!parent) {
jsExceptionHere(JSET_ERROR,"creating new object Graphics");
return NULL;
return NULL;
}

JshLCD_SPI_UNBUFInfo inf;
Expand All @@ -136,7 +136,7 @@ JsVar *jswrap_lcd_spi_unbuf_connect(JsVar *device, JsVar *options) {
_rowstart = inf.rowstart;
_device = jsiGetDeviceFromClass(device);

if (!DEVICE_IS_SPI(_device)) {
if (!DEVICE_IS_SPI(_device)) {
jsExceptionHere(JSET_ERROR,"Software SPI is not supported for now");
jsvUnLock(parent);
return NULL;
Expand All @@ -146,15 +146,15 @@ JsVar *jswrap_lcd_spi_unbuf_connect(JsVar *device, JsVar *options) {
graphicsStructInit(&gfx,inf.width,inf.height,16);
gfx.data.type = JSGRAPHICSTYPE_LCD_SPI_UNBUF;
gfx.graphicsVar = parent;

jshPinOutput(_pin_dc, 1);
jshPinSetValue(_pin_dc, 1);

jshPinOutput(_pin_cs, 1);
jshPinSetValue(_pin_cs, 1);

lcd_spi_unbuf_setCallbacks(&gfx);
graphicsSetVarInitial(&gfx);
graphicsSetVarInitial(&gfx);

// Create 'flip' fn
JsVar *fn;
Expand Down Expand Up @@ -187,29 +187,29 @@ void disp_spi_transfer_addrwin(int x1, int y1, int x2, int y2) {
}

void lcd_spi_unbuf_setPixel(JsGraphics *gfx, int x, int y, unsigned int col) {
uint16_t color = (col>>8) | (col<<8);
uint16_t color = (col>>8) | (col<<8);
if (x!=_lastx+1 || y!=_lasty) {
jshPinSetValue(_pin_cs, 0);
disp_spi_transfer_addrwin(x, y, gfx->data.width, y+1);
jshPinSetValue(_pin_cs, 1); //will never flush after
disp_spi_transfer_addrwin(x, y, gfx->data.width, y+1);
jshPinSetValue(_pin_cs, 1); //will never flush after
_put_pixel(color);
_lastx = x;
_lasty = y;
} else {
_lastx++;
_lastx++;
if (willFlush()){
jshPinSetValue(_pin_cs, 0);
_put_pixel(color);
jshPinSetValue(_pin_cs, 1);
} else {
_put_pixel(color);
}
}
}
}

void lcd_spi_unbuf_fillRect(JsGraphics *gfx, int x1, int y1, int x2, int y2, unsigned int col) {
int pixels = (1+x2-x1)*(1+y2-y1);
uint16_t color = (col>>8) | (col<<8);
int pixels = (1+x2-x1)*(1+y2-y1);
uint16_t color = (col>>8) | (col<<8);
jshPinSetValue(_pin_cs, 0);
disp_spi_transfer_addrwin(x1, y1, x2, y2);
for (int i=0; i<pixels; i++) _put_pixel(color);
Expand Down
Loading

0 comments on commit 87a4376

Please sign in to comment.