Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams authored Dec 4, 2024
2 parents f103d6d + 610a0a9 commit bc4f671
Show file tree
Hide file tree
Showing 26 changed files with 195 additions and 39 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
STM32F4: Add SDIO support
STM32: Ensure we kick the WDT if auto kicking is enabled and in deep sleep (avoids having to to it manually and wait 30ms for USB to wake up/shut down)
Allow a 'file receive' packet which can request Espruino sends a file as binary packets (also fix files not being closed if transmission fails)
Fix parsing of semicolons in DO with a statement: `do print(a);while(a--);`
In SAVE_ON_FLASH builds (Microbit 1) remove getSerial, Math.LN*/LOG*SQRT* constants, passwords, Serial/I2C/SPI.find, Date.toUTCString
ESP32: add setIP and setAPIP

2v24 : Bangle.js2: Add 'Bangle.touchRd()', 'Bangle.touchWr()'
Expand Down
1 change: 1 addition & 0 deletions README_BuildProcess.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ These are set automatically when `SAVE_ON_FLASH` is set (see `jsutils.h`)
* `ESPR_NO_LET_SCOPING` - don't create scopes for `let` (treat it like `var`, which was the 2v13 and earlier behaviour)
* `ESPR_NO_PROMISES` - Don't include promise-handling functions
* `ESPR_NO_PRETOKENISE` - Don't include code to pretokenise functions marked with `"ram"` - code pretokenised in the IDE can still be executed
* `ESPR_NO_PASSWORD` - Disable password protection on the console (E.setPassword/E.lockConsole)


### chip
Expand Down
1 change: 1 addition & 0 deletions libs/bluetooth/jswrap_bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -2365,6 +2365,7 @@ void jswrap_ble_setTxPower(JsVarInt pwr) {
"type" : "staticmethod",
"class" : "NRF",
"name" : "setLowPowerConnection",
"deprecated" : true,
"generate" : "jswrap_ble_setLowPowerConnection",
"params" : [
["lowPower","bool","Whether the connection is low power or not"]
Expand Down
29 changes: 16 additions & 13 deletions libs/graphics/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,20 @@ JsGraphicsSetPixelFn graphicsGetSetPixelUnclippedFn(JsGraphics *gfx, int x1, int
return gfx->setPixel; // fast
}

/// Merge one color into another based RGB565(amt is 0..256)
uint16_t graphicsBlendColorRGB565(uint16_t f, uint16_t b, int amt) {
unsigned int br = (b>>11)&0x1F;
unsigned int bg = (b>>5)&0x3F;
unsigned int bb = b&0x1F;
unsigned int fr = (f>>11)&0x1F;
unsigned int fg = (f>>5)&0x3F;
unsigned int fb = f&0x1F;
unsigned int ri = (br*(256-amt) + fr*amt) >> 8;
unsigned int gi = (bg*(256-amt) + fg*amt) >> 8;
unsigned int bi = (bb*(256-amt) + fb*amt) >> 8;
return (bi | gi<<5 | ri<<11);
}

/// Merge one color into another based on current bit depth (amt is 0..256)
uint32_t graphicsBlendColor(JsGraphics *gfx, unsigned int fg, unsigned int bg, int iamt) {
unsigned int amt = (iamt>0) ? (unsigned)iamt : 0;
Expand All @@ -374,18 +388,7 @@ uint32_t graphicsBlendColor(JsGraphics *gfx, unsigned int fg, unsigned int bg, i
// TODO: if our graphics instance is paletted this isn't correct!
return (bg*(256-amt) + fg*amt + 127) >> 8;
} else if (gfx->data.bpp==16) { // Blend from bg to fg
unsigned int b = bg;
unsigned int br = (b>>11)&0x1F;
unsigned int bg = (b>>5)&0x3F;
unsigned int bb = b&0x1F;
unsigned int f = fg;
unsigned int fr = (f>>11)&0x1F;
unsigned int fg = (f>>5)&0x3F;
unsigned int fb = f&0x1F;
unsigned int ri = (br*(256-amt) + fr*amt) >> 8;
unsigned int gi = (bg*(256-amt) + fg*amt) >> 8;
unsigned int bi = (bb*(256-amt) + fb*amt) >> 8;
return (bi | gi<<5 | ri<<11);
return graphicsBlendColorRGB565(fg,bg,iamt);
#ifdef ESPR_GRAPHICS_12BIT
} else if (gfx->data.bpp==12) { // Blend from bg to fg
unsigned int b = bg;
Expand Down Expand Up @@ -911,7 +914,7 @@ void graphicsScroll(JsGraphics *gfx, int xdir, int ydir) {
static void graphicsDrawString(JsGraphics *gfx, int x1, int y1, const char *str) {
// no need to modify coordinates as setPixel does that
while (*str) {
#ifdef USE_FONT_6X8
#ifdef USE_FONT_6X8
graphicsDrawChar6x8(gfx,x1,y1,*(str++),1,1,false);
x1 = (int)(x1 + 6);
#else
Expand Down
2 changes: 2 additions & 0 deletions libs/graphics/graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ void graphicsSetModified(JsGraphics *gfx, int x1, int y1, int x2, int y2);
JsGraphicsSetPixelFn graphicsGetSetPixelFn(JsGraphics *gfx);
/// Get a setPixel function and set modified area (assuming no clipping) (inclusive of x2,y2) - if all is ok it can choose a faster draw function
JsGraphicsSetPixelFn graphicsGetSetPixelUnclippedFn(JsGraphics *gfx, int x1, int y1, int x2, int y2, bool coordsRotatedAlready);
/// Merge one color into another based RGB565(amt is 0..256)
uint16_t graphicsBlendColorRGB565(uint16_t fg, uint16_t bg, int iamt);
/// Merge one color into another based on current bit depth (amt is 0..256)
uint32_t graphicsBlendColor(JsGraphics *gfx, unsigned int fg, unsigned int bg, int iamt);
/// Merge one color into another based on current bit depth (amt is 0..256)
Expand Down
4 changes: 2 additions & 2 deletions libs/graphics/jswrap_graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -1720,7 +1720,7 @@ It is recommended that you use `Graphics.setFont("4x6")` for more flexibility.
"type" : "method",
"class" : "Graphics",
"name" : "setFontVector",
"ifndef" : "SAVE_ON_FLASH",
"#if" : "!defined(SAVE_ON_FLASH) && !defined(NO_VECTOR_FONT)",
"generate_full" : "jswrap_graphics_setFontSizeX(parent, size, true)",
"params" : [
["size","int32","The height of the font, as an integer"]
Expand Down Expand Up @@ -2807,7 +2807,7 @@ void jswrap_graphics_drawCString(JsGraphics *gfx, int x, int y, char *str) {
"type" : "method",
"class" : "Graphics",
"name" : "getVectorFontPolys",
"#if" : "!defined(SAVE_ON_FLASH) || !defined(NO_VECTOR_FONT)",
"#if" : "!defined(SAVE_ON_FLASH) && !defined(NO_VECTOR_FONT)",
"generate" : "jswrap_graphics_getVectorFontPolys",
"params" : [
["str","JsVar","The string"],
Expand Down
1 change: 1 addition & 0 deletions libs/hexbadge/jswrap_hexbadge.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ int jswrap_badge_capSense(int corner) {
"type" : "staticmethod",
"class" : "Badge",
"name" : "getBatteryPercentage",
"deprecated" : true,
"generate" : "jswrap_badge_getBatteryPercentage",
"return" : ["int", "A percentage between 0 and 100" ]
}
Expand Down
1 change: 1 addition & 0 deletions libs/network/esp8266/jswrap_esp8266_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,7 @@ void jswrap_ESP8266_wifi_soft_init() {
"class" : "ESP8266",
"ifdef" : "ESP8266",
"name" : "ping",
"deprecated" : true,
"generate" : "jswrap_wifi_ping",
"params" : [
["ipAddr", "JsVar", "A string representation of an IP address."],
Expand Down
130 changes: 111 additions & 19 deletions libs/pipboy/jswrap_pipboy.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ uint8_t streamBuffer[STREAM_BUFFER_SIZE+4] __attribute__ ((aligned (8))); // we
// Can't go in 64k CCM RAM because no DMA is allowed to CCM!
// Maybe if we modified DMA to read to a buffer first?

/** Palette for scanlines
0: even (bright line)
1: odd (dark line)
0: even scan effect
1: odd scan effect
*/
uint16_t palette[4][16];

typedef enum {
ST_NONE,
ST_AVI,
Expand Down Expand Up @@ -201,6 +209,19 @@ void jswrap_pb_videoStart(JsVar *fn, JsVar *options) {
f_lseek(&streamFile, (uint32_t)(videoInfo.streamOffset+8)); // go back to start of video data
videoFrameTime = jshGetTimeFromMilliseconds(videoInfo.usPerFrame/1000.0);
videoNextFrameTime = jshGetSystemTime() + videoFrameTime;
// set palette
for (int i=0;i<256;i++) {
uint16_t c = videoInfo.palette[i];
uint16_t br = (c>>11)&0x1F;
uint16_t bg = (c>>6)&0x1F;
uint16_t bb = c&0x1F;
uint16_t lum = br; // lum = 0..31
if (bg>lum) lum=bg;
if (bb>lum) lum=bb;
// We use the non-scan-effect palette here (not idx 2) as it's too bright otherwise
videoInfo.palette[i] = palette[0][lum>>1]; // Should blend so we don't lose 1 bit accuracy?
}

#ifndef LINUX
// Set up Audio
if (videoInfo.audioBufferSize <= I2S_RING_BUFFER_SIZE*2) { // IF we have audio
Expand Down Expand Up @@ -1095,27 +1116,36 @@ void jswrap_pb_wake() {
If `height` isn't specified the image height is used, otherwise only part of the image can be rendered.
*/
int scanlinePos = 0;
void getPaletteForLine2bpp(int y, uint16_t *palette) {
void getPaletteForLine2bpp(int y, uint16_t *pal) {
int distfromScaline = y-scanlinePos;
if (distfromScaline<0) distfromScaline=-distfromScaline;
int brightness = 220 + ((distfromScaline>64)?0:(63-distfromScaline));
if (brightness>255) brightness=255;
if (y&1) brightness = (brightness*3) >> 2;
palette[3] = (uint16_t)(brightness>>2)<<5;
brightness = (brightness*2)/3;
palette[2] = (uint16_t)(brightness>>2)<<5;
brightness = brightness >> 1;
palette[1] = (uint16_t)(brightness>>2)<<5;
}
void getPaletteForLine4bpp(int y, uint16_t *palette) {
int n = y&1;
if (distfromScaline>64) {
// no overscan effect - too far away
pal[0] = palette[n][0];
pal[1] = palette[n][5];
pal[2] = palette[n][10];
pal[3] = palette[n][15];
} else {
int a = distfromScaline<<2; // 0..255
pal[0] = graphicsBlendColorRGB565(palette[n][0],palette[n+2][0],a);
pal[1] = graphicsBlendColorRGB565(palette[n][5],palette[n+2][5],a);
pal[2] = graphicsBlendColorRGB565(palette[n][10],palette[n+2][10],a);
pal[3] = graphicsBlendColorRGB565(palette[n][15],palette[n+2][15],a);
}
}
void getPaletteForLine4bpp(int y, uint16_t *pal) {
int distfromScaline = y-scanlinePos;
if (distfromScaline<0) distfromScaline=-distfromScaline;
int brightness = 220 + ((distfromScaline>64)?0:(63-distfromScaline));
if (brightness>255) brightness=255;
if (y&1) brightness = (brightness*3) >> 2;
for (int i=1;i<16;i++) {
int b = (brightness*i)>>4;
palette[i] = (uint16_t)(b>>2)<<5;
int n = y&1;
if (distfromScaline>64) {
// no overscan effect - too far away
for (int i=0;i<16;i++)
pal[i] = palette[n][i];
} else {
int a = distfromScaline<<2; // 0..255
for (int i=0;i<16;i++)
pal[i] = graphicsBlendColorRGB565(palette[n][i],palette[n+2][i],a);
}
}
void jswrap_pb_blitImage(JsVar *image, int x, int y, JsVar *options) {
Expand Down Expand Up @@ -1214,6 +1244,58 @@ JsVar *jswrap_pb_streamPlaying() {
return 0;
}

/*JSON{
"type" : "staticmethod",
"class" : "Pip",
"name" : "setPalette",
"generate" : "jswrap_pb_setPalette",
"params" : [
["palette","JsVar","A 4 element array of 16 element arrays"]
]
}
Set the colour palette used for rendering everything on PipBoy
eg:
```
var pal = [
new Uint16Array(16),
new Uint16Array(16),
new Uint16Array(16),
new Uint16Array(16)
];
// Orangey
for (var i=0;i<16;i++) {
pal[0][i] = g.toColor(i/15,i/30,0); // 0: even (bright line)
pal[1][i] = g.toColor(i/30,i/60,0); // 1: odd (dark line)
pal[2][i] = g.toColor(i/10,i/20,0); // 0: even scan effect
pal[3][i] = g.toColor(i/20,i/40,0); // 1: odd scan effect
}
Pip.setPalette(pal);
```
*/
void jswrap_pb_setPalette(JsVar *pal) {
if (!jsvIsArray(pal)) {
jsExceptionHere(JSET_ERROR, "Expecting array of arrays");
return;
}
for (int i=0;i<4;i++) {
JsVar *a = jsvGetArrayItem(pal, i);
if (!jsvIsIterable(a)) {
jsExceptionHere(JSET_ERROR, "Expecting array of arrays, pal[%d] is %t", i, a);
jsvUnLock(a);
return;
}
JsvIterator it;
jsvIteratorNew(&it, a, JSIF_EVERY_ARRAY_ELEMENT);
for (int c=0;c<16;c++) {
palette[i][c] = (uint16_t)jsvIteratorGetIntegerValue(&it);
jsvIteratorNext(&it);
}
jsvIteratorFree(&it);
jsvUnLock(a);
}
}

/*JSON{
"type" : "init",
Expand All @@ -1222,11 +1304,21 @@ JsVar *jswrap_pb_streamPlaying() {
void jswrap_pb_init() {
// Enable watchdog
jswrap_espruino_enableWatchdog(15, NULL); // init watchdog, auto mode
// Set up colour palette
for (uint16_t i=0;i<16;i++) {
// normally we're a bit more dim
uint16_t b = (i*220) >> 6; // 0..63
palette[0][i] = b << 5; // even
palette[1][i] = ((b*3)>>2) << 5; // odd
// overscan - full range
palette[2][i] = i << 7;
palette[3][i] = (i*3) << 5;
}
// splash screen
const unsigned char img_raw[] = {199, 17, 2, 0, 0, 31, 255, 255, 255, 255, 255, 255, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 255, 255, 255, 255, 255, 255, 233, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 255, 255, 255, 255, 255, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 91, 255, 213, 85, 85, 111, 255, 192, 11, 255, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 86, 255, 249, 85, 85, 85, 255, 252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191, 253, 0, 0, 0, 191, 253, 0, 127, 255, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 255, 128, 0, 0, 7, 255, 208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 255, 224, 0, 0, 7, 255, 224, 127, 255, 224, 2, 255, 255, 255, 255, 255, 233, 0, 0, 0, 0, 0, 0, 0, 0, 255, 248, 0, 0, 0, 63, 254, 0, 107, 255, 255, 255, 232, 0, 191, 255, 255, 224, 127, 255, 255, 248, 0, 0, 63, 255, 255, 255, 255, 255, 254, 7, 255, 255, 192, 47, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 255, 224, 127, 255, 255, 255, 255, 253, 91, 255, 255, 255, 131, 255, 255, 255, 224, 0, 3, 255, 255, 255, 255, 255, 255, 224, 26, 255, 252, 0, 107, 255, 250, 170, 170, 255, 248, 0, 170, 170, 170, 170, 168, 0, 191, 255, 255, 255, 255, 255, 248, 7, 255, 250, 170, 171, 255, 255, 255, 255, 255, 252, 47, 255, 255, 254, 0, 0, 47, 255, 191, 255, 255, 234, 80, 0, 7, 255, 192, 0, 47, 255, 0, 0, 11, 255, 192, 11, 255, 255, 255, 255, 224, 11, 255, 234, 170, 170, 171, 255, 240, 63, 253, 0, 0, 31, 255, 255, 253, 191, 255, 0, 127, 255, 208, 0, 0, 2, 255, 244, 0, 0, 0, 0, 0, 0, 127, 253, 0, 1, 255, 244, 0, 0, 191, 252, 0, 21, 85, 85, 85, 85, 0, 127, 254, 0, 0, 0, 31, 255, 67, 255, 224, 0, 0, 255, 245, 85, 64, 255, 253, 31, 255, 244, 0, 0, 0, 31, 255, 128, 0, 0, 0, 0, 0, 3, 255, 208, 0, 31, 255, 64, 0, 7, 255, 208, 0, 0, 0, 0, 0, 0, 7, 255, 224, 0, 0, 0, 255, 248, 47, 255, 0, 0, 15, 255, 128, 0, 1, 255, 255, 255, 248, 0, 0, 0, 85, 255, 248, 0, 0, 0, 0, 0, 0, 127, 254, 81, 20, 255, 249, 64, 5, 127, 255, 213, 64, 0, 0, 0, 0, 17, 127, 255, 64, 0, 5, 95, 255, 130, 255, 245, 85, 85, 255, 248, 0, 0, 2, 255, 255, 254, 0, 0, 0, 15, 255, 255, 192, 0, 0, 0, 0, 1, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 64, 0, 0, 0, 3, 255, 255, 255, 255, 255, 255, 255, 248, 15, 255, 255, 255, 255, 255, 128, 0, 0, 3, 255, 255, 128, 0, 0, 0, 127, 255, 252, 0, 0, 0, 0, 0, 11, 255, 255, 255, 255, 255, 255, 255, 255, 255, 250, 255, 224, 0, 0, 0, 0, 31, 255, 255, 255, 255, 255, 255, 249, 0, 11, 255, 255, 255, 255, 144, 0, 0, 0, 127, 255, 208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 255, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 255, 244, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 255, 253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 255, 253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 255, 255, 208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 255, 254, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 170, 128, 0, 0, 0, 0, 0, 0};
JsVar *img = jsvNewNativeString((char*)&img_raw[0], sizeof(img_raw));
JsVar *g = jsvNewObject(); // fake object for rendering
graphicsInternal.data.fgColor = 63<<5;
graphicsInternal.data.fgColor = palette[0][15];
jsvUnLock(jswrap_graphics_clear(g, 0));
jsvUnLock(jswrap_graphics_drawImage(g, img, (LCD_WIDTH-200)/2, LCD_HEIGHT/2-16, NULL));
graphicsInternal.data.fontSize = JSGRAPHICS_FONTSIZE_6X8+1;
Expand Down Expand Up @@ -1303,7 +1395,7 @@ void jswrap_pb_init() {
if (res == FR_NO_FILE) msg = jsvNewFromString("NO VERSION FILE");
else if (res == FR_NOT_ENABLED) msg = jsvNewFromString("NO SD CARD");
else msg = jsvVarPrintf("SD CARD ERROR %d", res);
graphicsInternal.data.fgColor = 63<<5; // green
graphicsInternal.data.fgColor = palette[0][15]; // green
graphicsInternal.data.fontSize = JSGRAPHICS_FONTSIZE_6X8+1;
graphicsInternal.data.fontAlignX = 0;
jsvUnLock(jswrap_graphics_drawString(g, msg, (LCD_WIDTH/2), LCD_HEIGHT/2+14, 0));
Expand Down
1 change: 1 addition & 0 deletions libs/pipboy/jswrap_pipboy.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void jswrap_pb_blitImage(JsVar *image, int x, int y, JsVar *options);
void jswrap_pb_getAudioWaveform(JsVar *dst, int y1, int y2);
bool jswrap_pb_audioIsPlaying();
JsVar *jswrap_pb_streamPlaying();
void jswrap_pb_setPalette(JsVar *pal);

void jswrap_pb_init();
void jswrap_pb_kill();
Expand Down
4 changes: 3 additions & 1 deletion libs/pixljs/jswrap_pixljs.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Class containing utility functions for
"type" : "staticmethod",
"class" : "Pixl",
"name" : "getBatteryPercentage",
"deprecated" : true,
"generate" : "jswrap_espruino_getBattery",
"return" : ["int", "A percentage between 0 and 100" ]
}
Expand Down Expand Up @@ -519,6 +520,7 @@ type MenuNumberItem = {
type MenuOptions = {
title?: string;
back?: () => void;
remove?: () => void;
selected?: number;
fontHeight?: number;
scroll?: number;
Expand Down Expand Up @@ -733,4 +735,4 @@ To remove the window, call `E.showAlert()` with no arguments.
}*/
void jswrap_pixljs_powerusage(JsVar *devices) {
jsvObjectSetChildAndUnLock(devices, "LCD", jsvNewFromInteger(lcdIsOn ? 170 : 20));
}
}
1 change: 1 addition & 0 deletions libs/puckjs/jswrap_puck.c
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,7 @@ JsVarFloat jswrap_puck_light() {
"class" : "Puck",
"ifdef" : "PUCKJS",
"name" : "getBatteryPercentage",
"deprecated" : true,
"generate" : "jswrap_espruino_getBattery",
"return" : ["int", "A percentage between 0 and 100" ]
}
Expand Down
8 changes: 7 additions & 1 deletion scripts/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def f(*popenargs, **kwargs):
# // EV_CUSTOM = Called whenever an event of type EV_CUSTOM is received (jswOnCustomEvent(event))
# // EV_xxx = Something to be called with a character in an IRQ when it is received (eg. EV_SERIAL1) (jswOnCharEvent)
# // powerusage = fn(JsVar*) called with an object, and should insert fields for deviec names and estimated power usage in uA (jswGetPowerUsage)
# "class" : "Double", "name" : "doubleToIntBits",
# "class" : "Double",
# "name" : "doubleToIntBits",
# "deprecated" : "2v24", // mark that this may be removed in the future (version=when it was deprecated). Adds a comment to description
# "needs_parentName":true, // optional - if for a method, this makes the first 2 args parent+parentName (not just parent)
# "generate_full|generate|wrap" : "*(JsVarInt*)&x", // if generate=false, it'll only be used for docs
# "generate_js" : "full/file/path.js", // you can supply a JS file instead of 'generate' above. Should be of the form '(function(args) { ... })'
Expand Down Expand Up @@ -206,11 +208,15 @@ def get_jsondata(is_for_document, parseArgs = True, boardObject = False):
try:
jsondata = json.loads(jsonstring)
if len(description): jsondata["description"] = description;
else: jsondata["description"] = ""
jsondata["filename"] = jswrap
if jswrap[-2:]==".c":
jsondata["include"] = jswrap[:-2]+".h"
jsondata["githublink"] = "https://github.com/espruino/Espruino/blob/"+githash+"/"+jswrap+"#L"+str(linenumber)

if "deprecated" in jsondata and not "deprecated" in jsondata["description"].lower():
jsondata["description"] = "**DEPRECATED** - this will be removed in subsequent versions of Espruino\n\n" + jsondata["description"];

dropped_prefix = "Dropped "
if "name" in jsondata: dropped_prefix += jsondata["name"]+" "
elif "class" in jsondata: dropped_prefix += jsondata["class"]+" "
Expand Down
Loading

0 comments on commit bc4f671

Please sign in to comment.