• Brilliant idea,

    unfortunately, there must be more that goes wrong:

    I order to make it right from the very beginning, I tried to replace setInterval by setTimeout within updateDisplay (that saves me the "trial-and-error" approaches to find the proper interval whenever I change s.th. within the loop)

    The result looked like this:

    var Gfx = Graphics.createArrayBuffer(5,5,1);
    Gfx.flip = function () { show(this.buffer); };
    
    function currentXYZ () {
      return [2,0,5];
    }
    
    function updateDisplay () {
      var XYZ = currentXYZ();
    
      Gfx.clear();
      Gfx.drawLine(0,4, 0,4-Math.max(0,Math.min(4,XYZ[0])));
      Gfx.drawLine(2,4, 2,4-Math.max(0,Math.min(4,XYZ[1])));
      Gfx.drawLine(4,4, 4,4-Math.max(0,Math.min(4,XYZ[2])));
      Gfx.flip();
      
      setTimeout(updateDisplay,100);
    }
    updateDisplay();
    

    but did not work at all!!!! (when entered into the Editor area of the IDE and sent to RAM from there - which implies a "reset" before uploading)

    So, I commented the setTimeout and tried again - and now I got the following message:

    >Uncaught Error: Too much recursion - the stack is about to overflow
     at line 4 col 41
      Gfx.drawLine(0,4, 0,4-Math.max(0,Math.min(4,XYZ[0])));
                                            ^
    in function "updateDisplay" called from line 1 col 15
    updateDisplay();
                  ^
    Execution Interrupted
    > 
    

    Now, I'm completely lost (I do not have any pretokenization or other kind of minification switched on)

    What makes it even worse: after crashing, I have to push the reset button of my BBC micro:bit in order to let it reappear in the scanned list of BT devices. Sometimes even several resets are necessary before I'm able to upload any JS code again....)

    I'm now also trying to figure out whether the device itself is broken (which could theoretically be the reason for all these weird problems)
    [UPDATE] my second micro:bit behaves the same...

    Any ideas?

About