How to enable the LED of a single key for a brief period?

I’m looking to use the LEDs to give me feedback as to the state of Layers (if one is locked or not), or the state of plugins (which are enabled/disabled/etc).

I see there is the LEDControl plugin, but I’m not 100% sure how to use/leverage it. For instance, I’m looking to create a Macro that would be triggered that would LOCK_LAYER and turn a LED on the trigger key a color for 2 or 3 secs to indicate the layer is locked. Similarly, a different color would light when the Macro is run and the layer is unlocked.

Is this easily done/feasibly just using the existing plugins? If not, where would a good starting point to plugin development be for Kaleidoscope be? I haven’t coded with C++ in over 10 years, but figured it shouldn’t be too hard to remember/pick up again.

Thanks,

Eric

1 Like

I’m sorry that I don’t know how to answer your question Eric. But I do agree this could be a useful thing to know. Perhaps a more experienced programmer would consider writing a plugin that uses the number keys to display the current layer. I.e., when layer 3 is active, the number 4 key lights up in a certain specified color (this because the layers are numbered starting with 0).

The LED-ActiveModColor plugin can do this. It will light up any active layer keys, as long as they are active. It will also light up modifiers, mind you. If all you need is the layer highlight, that’d be a reasonably small change to the plugin - please file an issue in this case, so the request doesn’t get lost.

1 Like

@algernon I’ve been using the LED-ActiveModColor in conjunction with the OneShot plugin and it works great. But what I was looking for was something that I could potentially use in a macro defn that would allow me to light a given Key for a period of time to indicate a status.

For example, if I wanted to bing a key to enable/disable the SpaceCadet plugin, I would be able to create a macro and map it to a given key which does:

static void toggleSpaceCadet(uint8_t keyState) {
  static Key lastKey = ????  // figure out what is the KeyAddr of the last  key pressed;
  cRGB RED = CRGB(0xff, 0x00, 0x00);
  cRGB GREEN = CRGB(0x00, 0xff, 0x00);

	if( SpaceCadet.active()) {
	   SpaceCadet.disable();
	   // light the key pressed red to show SpaceCadet was enabled for 3 seconds
	   LED.enable( lastKey, RED, 3000);     <----  How do to this??
	} else {
	   SpaceCadet.enable();
	   // light the key pressed green to show SpaceCadet was enabled for 3 seconds
	   LED.enable( lastKey, GREEN, 3000);      <----  How do to this??
	}
}

How would I manage to do something like that? Is there any existing support for this?

Thanks,

Eric

There isn’t yet, but it’s not too hard to do that. The hard part is keeping track of which keys are lit and their remaining time. Can you file an issue against Kaleidoscope, so the request is not forgotten?

Can you point me in the right direction if I find the time to play with something like this? I took a quick look at the LED-ActiveModColor for inspiration, but couldn’t find any docs on how the plugin platform worked (ie: the type of interface that needs to be respected/etc). I see there are events being handled, but not sure how those events are registered, or even which handler event methods exist for implementation.

Additionally, I was looking for a timer object but couldn’t quickly find references to one either.

Thanks,

Eric