FAQ

What follows are a few answers to common questions we’ve been asked at the conference:

Fixing your badge

After uploading code, your badge might not work any more or might show the ‘Espruino’ logo.

To fix it, just disconnect and reconnect the battery. You can do that by pulling the edge of the battery away from the PCB using a finger nail.

If that doesn’t fix the badge, you might need to go to the hacking bench and use the flashing tool there to rewrite the badge’s JS firmware.

You can also disconect/reconnect the battery while holding BTNA until the Espruino logo appears to make the badge start up without loading any new code. It’ll be connectable, but will be completely blank.

Saving your code

Espruino can save code in 2 ways - as raw JavaScript, or as a compressed ‘RAM image’ which is a bit like ‘hibernate’ - that’s the default if you type save() (normally any code you upload goes straight into RAM).

Your main badge firmware is stored as raw JS, and there’s not enough room to store that as well as saving anything else.

The easiest solution is to just turn on Save On Send on in the IDE’s options - this switches to saving raw JS to the device’s flash whenever you upload - the next upload will remove the badge’s existing JavaScript.

If you want to use save() - the hibernate style of saving - just remove your badge’s built-in JS firmware with E.setBootCode(). save() will then work great.

Fixing your badge after the conference

We crammed as much JS code into the badge as we could, but that means that the original main.js file can’t be written using the normal IDE.

You have two options:

Strip some code out of main.js, and write it with Save on Send set in the IDE’s settings

Use flash_as_js.sh to turn the badge firmware into a large JavaScript file that writes directly into flash memory. This is super nasty and slow - but it will restore your badge to default

Graphics

You can draw to the display with g.drawString/etc, but it won’t update immediately - you need to call g.flip() to send the contents of the offscreen buffer to the screen whenever you want an update.

Images

The badge display is 128x64, 1 bit per pixel. All the images for the Badge slideshow are stored in a Badge.badgeImages variable which you can change.

Adding to existing badge firmware

Most functionality is stored in a Badge variable - you can overwrite/modify any part of it.

In the IDE, make sure Settings → Communications → Reset Before Send (and Save on Send) is UNCHECKED. You can then upload code from the right-hand side of the IDE without removing any of the badge’s existing firmware.

For instance you can replace the ‘Badge mode’ by copying Badge.badge out of main.js and modifying it so that you no longer need to enter the Konami code (just the B) to get to the menu: