Rob's garden / notes / note

Note

I worked on our sign again today, it's almost there! Now you can upload a JavaScript file to animate the LEDs

(excluding the hslToHex function) the JavaScript is pretty consise! There is a "Thing" API to send commands to the ESP and you use regular standards APIs like setInterval

A black box with Open Lab letters glowing through in an animated rainbow

JavaScript reading:

const factor = 50
const speed = 20 / 1000; // degrees per ms

const HEIGHT = 32
const WIDTH = 128

function tick() {
  for (let column = 0; column < 128; column++) {
    const h = Math.floor(((Date.now() + column * factor) * speed) % 360);
    const [r, g, b] = hslToHex(h, 100, 50)
    for (let row = 0; row < HEIGHT; row++) {
      Thing.setPixel(row * WIDTH + column, r, g, b)
    }
  }
}

tick();
setInterval(() => tick(), 50);

JavaScript code that ticks every 50ms and draws a rainbow moving left to right using a hsl interpolation