• My conclusions so far:

    1. setTimeout seems to be terribly broken (I could not get it working at all)
    2. code sent from the IDE (to RAM) should not be started immediately after uploading (the IDE seems to expect some response from the connected device which it might not receive otherwise). But you will have to use setInterval for that purpose (as setTimeout is broken, see above)
    3. the graphics library also seems to have its problems (drawString seems to work fine, but drawLine seems to be flaky)

    My updated code

    function currentXYZ () {
      return [2,0,5];
    }
    
    var Buffer;
    function drawBar (x,Length) {
      for (var i = 0; i <= Length; i++) {
        var Bit = x+(4-i)*5;
        Buffer = Buffer | (1 << Bit);
      }
    }
    
    function updateDisplay () {
      var XYZ = currentXYZ();
    
      Buffer = 0;
      drawBar(0,Math.max(0,Math.min(4,XYZ[0]))­);
      drawBar(2,Math.max(0,Math.min(4,XYZ[1]))­);
      drawBar(4,Math.max(0,Math.min(4,XYZ[2]))­);
      show(Buffer);
    }
    setInterval(updateDisplay,100);
    

    runs fine for much longer now than any other variant did.

    With greetings from Germany,

    Andreas Rozek

About