crhallberg / Blinks-Simulator

A JS simulator for the Blinks smart tiles: https://move38.github.io/Blinks-SDK-Docs-EN/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Blinks Simulator

Recreates the Blink SDK API in Javascript.

import { API as T, Blinks } from "./lib/index.js";
import renderFunc from "./lib/drag-drop.js";

function setup() {
  T.setValueSentOnAllFaces(0);
  T.setColor(T.OFF);
}

function loop() {
  if (T.isAlone()) {
    T.setColor(T.OFF);
  }

  let second = Math.floor(T.millis() / 1000);
  T.setValueSentOnFace(second, second % 6);
  T.FOREACH_FACE(i => {
    if (T.isValueReceivedOnFaceExpired(i)) {
      T.setColorOnFace(T.OFF, i);
    } else {
      let v = T.getLastValueReceivedOnFace(i);
      T.setColorOnFace(T.makeColorHSB(v * 4 * 6, 255, 100), i);
    }
  });
}

TODO

  • Button Presses
  • Local variables for tiles
  • Tests
    • api.d.ts added, no index.js to test so no check-dts
    • mocha

Wishlist

I'm not sure these things are possible.

  • Make useable without API prefix

About

A JS simulator for the Blinks smart tiles: https://move38.github.io/Blinks-SDK-Docs-EN/

License:MIT License


Languages

Language:JavaScript 97.8%Language:HTML 2.2%