• @tc You just beat me to posting this :) I had a similar idea I've been building in the recent days, especially rotation for volume control.

    Mine's here: https://github.com/rsmeral/puck.js/

    I modularized it into these

    • Button - emits events for single/double/long/multi press

      Button.on("double", ()=>console.log("I got double clicked!"));
      
    • Proximity - emits "far" and "close" events, emulating a proximity sensor (based on light)

      Prox.on("close", ()=>console.log("close"));
      Prox.on("far", ()=>console.log("far"));
      
    • Scroll Wheel - emits "plus", "minus" and "notch", based on magnetometer

      Knob.on("plus", hid.volumeUp);
      Knob.on("minus", hid.volumeDown);
      Knob.start();
      
    • Lights - (WIP - works, but needs tweaks) - pretty API to control the LEDs

      Lights.pulsing().color(Lights.BLUE).when­(Button, "down").until(Button, "up");
      Lights.blip(Lights.CYAN, 500);
      Lights.steady().rainbow().now().for(5000­);
      

    The VolumePlayPause demo is quite fat (especially due to Lights being fat) - when I load it through the Web IDE, it gives me Out of memory error, but when loaded through CLI, it works OK. Most likely the difference is in minification.

  • @Ron, nice work. I would suggest "near" and "far" events as "close" can be confused with the verb close as in shut or end, often associated with streams.

About

Avatar for CanyonCasa @CanyonCasa started