Chat freely about the open source Javascript projects for ESP8266

User avatar
By tj4shee
#34328 Hi everyone ! I was trying to get some WS2812s (10 coupled together) working with the ESP-01 running Espruino....

The following code loads..... but also resets the ESP-01.... guessing it requires too much memory ?

After a save() it reports 3040 bytes written.... am I correct in using SPI1 of the ESP-01 ?

Code: Select allSPI1.setup({baud:3200000, mosi:D2});
var arr = new Uint8ClampedArray(10*3);
var pos = 0;

var brightness = 0.05;

function getPattern() {
  pos++;
  for (var i=0;i<arr.length;i+=3) {
    arr[i  ] = (1 + Math.sin((i+pos)*0.1324)) * 127 * brightness;
    arr[i+1] = (1 + Math.sin((i+pos)*0.1654)) * 127 * brightness;
    arr[i+2] = (1 + Math.sin((i+pos)*0.1)) * 127 * brightness;
  }
}

function onTimer() {
  getPattern();
  SPI1.send4bit(arr, 0b0001, 0b0011);
}

setInterval(onTimer, 50);


I also tried this same code on my Olimexino... so I know the lights work......