Lock layer without the LED?

i have been using LockLayer to implement multiple key layouts (qwerty and norman because on some systems i let the system implement the keymap and sometimes i want my keyboard to do the remapping.).

anyways, the problem is that when i go to my NORMAN layout, i don’t want the LED to stay lit all the time. it would be nice to have it blink at least to let me know that i have switched layouts but i don’t want it to stay lit.

for now i have implemented this with macros and using Layout.move(...).

1 Like

A quick way to implement this would be a macro like this:

void togleNORMAN(uint8_t key_state) {
  static uint16_t blink_end;

  if (keyToggledOn(key_state)) {
    blink_end = millis() + 1000;
    if (Layer.isOn(NORMAN)) {
      Layer.off(NORMAN);
    } else {
      Layer.on(NORMAN);
    }
    LEDControl.setAllLedsTo(128, 0, 0);
    return;
  }

  if (blink_end && millis() > blink_end) {
    LEDControl.setAllLedsTo(0, 0, 0);
    blink_end = 0;
  }
}

The idea here is that when toggling the layer, we’ll set the leds, and record when the leds should turn off (1s after toggling on). When the key’s not toggled on, we check if we have an end time, and if we do and it is over, we turn the LEDs off. This does not blink, but show you a static color, mind you. Blinking can be implemented with reasonable ease. Or you could even add breathing… But those are left as an exercise for the reader! :wink:

Oh of course! This all makes total sense now. Although based on your code I think the bottom if statement would need to go into the main macro loop otherwise it would only get triggered when the key is pressed.

So one off question, I looked through layers.cc and I couldn’t find what is actually turning the leds on. Did I miss it in there?

No, because macro actions are called even when there are no key events. This allows implementing macros that do something even with the key released!

No, you did not miss anything. The layer code does not touch LEDs at all by default. You may have some other plugin that does, though.