Fix the LED mode handling

First of all, to disallow switching to LEDNumlock, we need to do the check in
the `.init()` method, not in `.setup()`. Second, tracking the previous LED mode
can be done a lot simpler - and a lot reliably.

With these changes, the NumLock LED effect works as it is expected to.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/365/head
Gergely Nagy 8 years ago
parent 5df5b209d7
commit ed92d5109c

@ -18,9 +18,9 @@ LEDNumlock::begin (void) {
} }
void void
LEDNumlock::setup (void) { LEDNumlock::init (void) {
if (!Layer.isOn (numpadIndex)) { if (!Layer.isOn (numpadIndex)) {
LEDControl.next_mode (); LEDControl.next_mode();
} }
} }
@ -42,15 +42,11 @@ LEDNumlock::loopHook (bool postClear) {
if (!postClear) if (!postClear)
return; return;
if (Layer.isOn (numpadIndex)) { if (!Layer.isOn (numpadIndex)) {
if (storedLEDMode != us) { if (LEDControl.get_mode () != us)
storedLEDMode = LEDControl.get_mode (); storedLEDMode = LEDControl.get_mode ();
}
LEDControl.set_mode (us);
}
if (!Layer.isOn (numpadIndex) &&
LEDControl.get_mode () == us) {
LEDControl.set_mode (storedLEDMode); LEDControl.set_mode (storedLEDMode);
} else {
LEDControl.set_mode (us);
} }
} }

@ -10,7 +10,7 @@ class LEDNumlock : LEDMode {
virtual void begin (void) final; virtual void begin (void) final;
virtual void update (void) final; virtual void update (void) final;
virtual void setup (void) final; virtual void init (void) final;
private: private:
static void loopHook (bool postClear); static void loopHook (bool postClear);

Loading…
Cancel
Save