Turning on specific leds when hitting a specific layer


(Gergely Nagy) #42

Sure thing! I’ll also try to update the UPGRADE docs so they’re less vague. I think I wrote a more detailed guide somewhere, will update the upgrade docs with that.

For the time being, a minimal example in spirit of the original:

class LayerColorOverride_: public kaleidoscope::Plugin {
public:
  LayerColorOverride_() {}

  kaleidoscope::EventHandlerResult afterEachCycle() {
    LEDControl.setCrgbAt(0, 0, CRGB(255, 0, 0));
    return kaleidoscope::EventHandlerResult::OK;
  }
};

LayerColorOverride_ LayerColorOverride;

KALEIDOSCOPE_INIT_PLUGINS(
  LEDControl,
  LayerColorOverride,
  ...
)

You can get the highest active layer with Layer.top(), and can implement the coloring logic based on that.

Hope this helps!


#43

Perhaps I’m just being dense, but I tried something like this, and I put Kaleidoscope.useLoopHook(layerColorOverride); as the last line in the method called setup() in my Model01-Firmware.ino file, and when I try to compile it, I get the error 'class kaleidoscope::Kaleidoscope_' has no member named 'useLoopHook'. Has anyone else encountered this?


(Gergely Nagy) #44

We changed the API to something much more efficient, and the old API doesn’t work anymore. There’s an updated example here, which works with the new API.