Avatar for ChristianW


Member since Nov 2016 • Last active Jul 2022
  • 18 conversations

German IT developer who found his long lost love for electronics and connected devices...

Most recent activity

  • in Projects
    Avatar for ChristianW

    Thanks @Gordon, there was not much time left before the race and I had to hack everything together to get a semi-working setup.
    It actually worked to a point, but unfortunately the race was called off during warmup because of the wet weather conditions making the track slippery.
    Maybe there is another date in the next weeks, that may give me some time for improvements...

  • in Projects
    Avatar for ChristianW

    Yes, it's reproducable.
    This is/was the actual line:


    Being Flash.NAME = 'laps', LAP_DATA_SIZE=8, LAPS_STORAGE=2000 which would be:

    write('laps', [8], 0, 16001)

    which worked perfectly fine in the console, but not when called via a setWatch() callback when a button was pressed.
    I even changed all the this. references to absolute ones in case the context got lost inside the method.

  • in Projects
    Avatar for ChristianW

    Maybe I'll just switch back to RAM and just use binary, reserved data for now.

    Is there a way to safely acquire memory without crashing the system?
    Something like:

    1. determine how much memory we have left process.memory().free
    2. subtract some margin of memory left unallocated (how much would you suggest?)
    3. calculate how big my ArrayBuffer can get (any clues here?)

    Or I'll just do it via trial + error and put the hardcoded numbers in...

  • in Projects
    Avatar for ChristianW

    Another issue:
    If I keep my storage file in flash and try to upload new code (minified + direct to flash), it gives me this:

    No errors. Minified 23072 bytes to 14425 bytes.
     ____                 _
    |  __|___ ___ ___ _ _|_|___ ___
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     2v09 (c) 2021 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    >fficial boards and donations:

    The only way to get new code flashed is removing the storage file first it seems.

  • in Projects
    Avatar for ChristianW

    @Gordon I'd like to have a method to do a reset "in the field", meaning starting everything new when I have to.

    What is working is calling my reset() method via commandline.
    What does not work is calling it through a handler after a button was pressed.

    The method does this:

      reset: function() {
        if(!Flash.s.write(Flash.NAME, [CONST.LAP_DATA_SIZE], 0, 1 + CONST.LAP_DATA_SIZE * CONST.LAPS_STORAGE)) {
          throw new Error('could not reserve storage');
        Flash.pos = 0;

    manual call:


    through handler:

    Uncaught Error: Unable to find or create file
     at line 1 col 114
    ...ATA_SIZE*CONST.LAPS_STORAGE))throw new Error('could not reserve stor...
    in function "reset" called from line 1 col 15
    a&&Flash.reset(),Object.keys(this.macs).­forEach(c=>{const d=this.macs[c];...
    in function "init" called from line 1 col 122
    in function "wakeup" called from line 1 col 16
    in function "onOff" called from line 1 col 37
    in function called from system
  • in Projects
    Avatar for ChristianW

    OK - something works. I can somehow create a storage and fill it up with data.
    What does not work is removing it at runtime.

    So how to erase and recreate a Storage file on runtime?

    I can storage.eraseAll() but that would remove my code too.

    I can

    storage.write('name', [data], 0, large_value)

    but that gives me

    Uncaught Error: Unable to find or create file

    even if I 'overwrite' my current file.

    So I'll try to

    storage.compact(); // this seems to be necessary to actually free up the space
    storage.write('name', [data], 0, large_value):

    but run into errors too.

    Is Storage buggy or am I doing something wrong here?

  • in Projects
    Avatar for ChristianW

    Thanks @allObjects, but since the day of the track race is already next Sunday there is not much time left to try something with external hardware.

    @Gordon I tried to implemented Storage yesterday, but it gave me headaches.

    EDIT: another error found. Don't put something like require('Storage').eraseAll() as first line in your code on upload... oh my.

  • in Projects
    Avatar for ChristianW

    I blew up another MDBT42Q because I inserted the battery upside down... Only one spare left.
    The others are at FRAport waiting for customs.
    Hope they arrive this week, since the race is next Sunday.

    Thanks to Brexit shipping times are degraded back to the Napoleonic era...