miércoles, 5 de enero de 2022

Commands and developing for Espruino

 

 IDE commands

reset();  //most common command when you find problems

after any freeze

require("Storage").eraseAll();

Removes all files, including apps that can't be removed from apps loader 

E.setTimeZone(2);

peek16(0x300c).toString(16);   //TO see the espruino SDK

//0x8C or 0x91 is SDK12

//0x81 or 0x88 is SDK11


Memory usage per app

print(require("Storage").list().map(f=>require("Storage").read(f).length.toString().padStart(7)+" - "+f).sort());

It'll list all files sorted by size and you can see what's taking up the space


Status

process.env; 

process.memory();

require("Storage").getStats();

(total, free,...storage bytes)

E.getBattery() ;

print(require("Storage").list().map(f=>require("Storage").read(f).length.toString().padStart(7)+" - "+f).sort());


 Device name (useful for Gadgetbridge)

bangle.js , puck.js , espruino, espruino-dev 

NRF.setAdvertising({},{name:"espruino"});

 

Testing notifications

 GB({t:"notify", id:5, src:"gadget",title:"Test",body:"message for testing notifications "});

 


Basics of developing

 Logging:

console.log("Debug mode enabled");

Creating the icon

Compatibility and Dynamic code

Bangle.js1 =240x240

Bangle.js2= 176x176

var v_model=process.env.BOARD;
//EMSCRIPTEN,EMSCRIPTEN2
if (v_model=='BANGLEJS'||v_model=='EMSCRIPTEN') {

Multidevice developing (BJS1, BJS2, P8, C16....

Default background color/theme 
   BJS1 black bg
   BJS2 white bg
Display size
   BJS1 1.3 inch 240x240 
   BJS2 1.3 inch 176x176
Colors
   BJS1  16 bit LCD
   BJS2  3-bit color LCD
Button/touch screen
   BJS1  3 buttons+2 areas (simulated 3=1+2)
   BJS2  1 button+full touch screen


Code for bangle App Loader (store)

convert tab to spaces
trim trailing space

Spend time reading and understanding following help: