You are reading a single comment by @user6772 and its replies. Click here to read the full conversation.
  • Hi,

    I tested it with the following code and it does not work.

    var modules = {};
    
    SPI2.setup({mosi:B15, sck:B13});
    
    modules.connect = function(/*=SPI*/_spi,/*=PIN*/_cs) {
      var spi = _spi;
      var cs = _cs;
      spi.send ([0xA,0xF],cs);  // intensity  -full
      spi.send ([0xB,0x7],cs);  // scan limit - all 8 chars
      spi.send ([0xC,0],cs);    // shutdown
      return {
    
        raw : function(val) {
          digitalWrite(cs,0);
          spi.send ([0x9,0]); // output raw data
          for (var i=0;i<val.length;i++) {
            spi.send([(i&7)+1,val[i]]);
          }
          spi.send([0x0C,1]); // no shutdown
          digitalWrite(cs,1);
        },
    
        off : function() { spi.send([0xC,0],cs); },
    
        intensity : function(i) { spi.send([0xA,E.clip(i*15,0,15)],cs); }
      };
    };
    
    var count = 0;
    
    function doSomerhingStupid() {
      if (count > 0)
        run();
      count ++;
    }
    
    function run () {
      var max = modules.connect (SPI2,B14);
      digitalWrite (LED3, 1);
      max.off();
      clearInterval();
    
      setInterval(function() {
        digitalWrite (LED2, on);
        var c1r0 = Math.random () * 255;
        var c1r1 = Math.random () * 255;
        var c2r0 = Math.random () * 255;
        var c2r1 = Math.random () * 255;
        var c3r0 = Math.random () * 255;
        var c3r1 = Math.random () * 255;
        var c4r0 = Math.random () * 255;
        var c4r1 = Math.random () * 255;
        max.raw([0,c1r0,0,c2r0,0,c3r0,0,c4r0,1,c­1r1,1,c2r1,1,c2r1,1,c3r1]);
        max.intensity (Math.random ());
    
        on = !on;
      }, 200);
    }
    
    var on = 1;
    digitalWrite (LED1, 1);
    digitalWrite (LED2, 0);
    digitalWrite (LED3, 0);
    clearInterval();
    
    setWatch(doSomerhingStupid, BTN1, {repeat:true,edge:"rising", debounce:1});
    

    Here is a video.
    https://www.youtube.com/watch?v=WEmp9NjJ­uwM

    Do you have any idea what I did wrong?

    Regards
    Michael

About

Avatar for user6772 @user6772 started