Bangle.js1: dump() now doesn't write out interpreter state as JS (saves 1.5kB Flash)

This commit is contained in:
Gordon Williams 2025-12-01 16:55:03 +00:00
parent 9feb8de86f
commit 7940729a6e
4 changed files with 7 additions and 2 deletions

View File

@ -7,6 +7,7 @@
Added ability to execute JS from an a timer with `require("timer").add({type:"EXEC",...)`
Bangle.js: Add Bangle.setOptions({stepCounterDisabled:bool}) to disable the step counter
Date: fix parsing of ISO8601 timezones (+HHMM worked, but +HH:MM and +HH added) (fix #2669)
Bangle.js1: dump() now doesn't write out interpreter state as JS (saves 1.5kB Flash)
2v28 : Add `E.internal` as a way to access the 'hidden root' containing Espruino internal variables that previously needed `global["\xff"]`
Bangle.js: Fix back handler not removed when using E.setUI with a back button but without widgets (#2636)

View File

@ -173,6 +173,7 @@ There are some specifically that are useful for cutting a few bytes out of the b
* `ESPR_LIMIT_DATE_RANGE` - limits the acceptable range for Date years (saves a few hundred bytes)
* `ESPR_NO_REGEX_OPTIMISE` - strips out some speed optimisations from the regex library
* On nRF52, `'LDFLAGS += -nostartfiles', 'ASFLAGS += -D__STARTUP_CLEAR_BSS -D__START=main',` can save ~300b by not including CRT startup code
* `ESPR_NO_DUMP_STATE` - stops `dump()` from trying to reconstruct interpreter state as JS (saves almost 1.5kB)
These are set automatically when `SAVE_ON_FLASH` is set (see `jsutils.h`)

View File

@ -49,6 +49,7 @@ info = {
'DEFINES+=-DCUSTOM_GETBATTERY=jswrap_banglejs_getBattery',
'DEFINES+=-DESPR_UNICODE_SUPPORT=1',
'DEFINES+=-DESPR_NO_SOFTWARE_SERIAL=1',
'DEFINES+=-DESPR_NO_DUMP_STATE=1', # don't let dump() output current state - saves a lot of flash
'DEFINES+=-DDUMP_IGNORE_VARIABLES=\'"g\\0"\'',
'DEFINES+=-DSAVE_ON_FLASH_MATH',
'DEFINES+=-DESPR_PACKED_SYMPTR', # Pack builtin symbols' offset into pointer to save 2 bytes/symbol

View File

@ -2699,8 +2699,10 @@ bool jsiLoop() {
/** Output current interpreter state such that it can be copied to a new device */
void jsiDumpState(vcbprintf_callback user_callback, void *user_data) {
#if defined(ESPR_NO_DUMP_STATE)
cbprintf(user_callback, user_data, "// This build can't output RAM contants as JS (ESPR_NO_DUMP_STATE=1)\n");
#else
JsvObjectIterator it;
jsvObjectIteratorNew(&it, execInfo.root);
while (jsvObjectIteratorHasValue(&it)) {
JsVar *child = jsvObjectIteratorGetKey(&it);
@ -2812,7 +2814,7 @@ void jsiDumpState(vcbprintf_callback user_callback, void *user_data) {
// and now the actual hardware
jsiDumpHardwareInitialisation(user_callback, user_data, true/*human readable*/);
#endif
JsVar *code = jsfGetBootCodeFromFlash(false);
if (code) {
cbprintf(user_callback, user_data, "// Code saved with E.setBootCode\n");