• Looks good!

    does Espruino support the ECMAScript 6 standard of the 0b1111 way of describing the value 15?

    Yes - so that could be a bit easier to read.

    Also...

    • pinMode(B10, output); isn't needed I think, but if it was, you'd need to define output as a string like pinMode(B10, 'output');. Version 1v81 and later of Espruino will actually produce an error for your code when it comes out, because the output variable isn't actually defined.
    • As @allObjects did with his code, you'll probably find that working with a 4 digit string simplifies things, even if you don't want to use map - which takes a bit of getting used to.
    • While less efficient than @allObjects' Uint8Array example, you could store all your digits directly in an object, which is a bit more readable and also allows you to handle stuff like spaces and alphanumeric characters if you wanted to: {0:0b00111111, 1:0b00110000, ' ':0, '-':..., 'b':...}. It means you'd then be able to display strings like "A -2" if you wanted.
    • If I understand right, what you're doing with digitalPulse is actually really good - because it's running in an IRQ, regardless of what's going on in Espruino it'll always keep the LEDs lit for the same amount of time. Worst case is Espruino gets busy and the LEDs flicker off for a bit.
    • I'd just wrap your 4 loop functions into 1, and I think using setInterval will be a bit neater:

      var digit = 0;
      var z = {0:0b00111111, 1:0b00110000, ' ':0, '-':..., 'b':...};
      var text = "1234";
      setInterval(function() {
      digit = (digit+1)&3; // digits 0..3
      SPI1.send(z[text[digit]],B6);
      digitalPulse(outpins[digit],0,4);
      }, 5); // maybe make setInterval slightly bigger than digitalPulse, just in case
      

    Hope that helps!

About

Avatar for Gordon @Gordon started