plugin/PersistnetLEDMode: Use the new `onLEDModeChange()` hook

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/733/head
Gergely Nagy 5 years ago
parent fddbd75ff8
commit 9724e2ecea
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -33,8 +33,8 @@ EventHandlerResult PersistentLEDMode::onSetup() {
Kaleidoscope.storage().get(settings_base_, cached_mode_index_); Kaleidoscope.storage().get(settings_base_, cached_mode_index_);
// If the index is max, assume an uninitialized EEPROM, and don't set the LED // If the index is max, assume an uninitialized EEPROM, and don't set the LED
// mode. We don't change the cached index here, `afterEachCycle()` will do // mode. We don't change the cached index here, `onLEDModeChange()` will do
// that at the end of he cycle anyway. // that whenever a led mode change happens.
if (cached_mode_index_ != 0xff) if (cached_mode_index_ != 0xff)
return EventHandlerResult::OK; return EventHandlerResult::OK;
@ -43,7 +43,7 @@ EventHandlerResult PersistentLEDMode::onSetup() {
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }
EventHandlerResult PersistentLEDMode::afterEachCycle() { EventHandlerResult PersistentLEDMode::onLEDModeChange() {
if (cached_mode_index_ == ::LEDControl.get_mode_index()) if (cached_mode_index_ == ::LEDControl.get_mode_index())
return EventHandlerResult::OK; return EventHandlerResult::OK;

@ -16,11 +16,6 @@
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* NOTE: This plugin is a workaround. It allows us to (optionally) save the LED
* mode to storage, and restore it on next boot, without having a way to hook
* into led mode change events. Once we can hook into that, this plugin shall be
* reworked to use it instead of keeping `afterEachCycle()` busy. */
#pragma once #pragma once
#include <Kaleidoscope.h> #include <Kaleidoscope.h>
@ -33,7 +28,7 @@ class PersistentLEDMode: public kaleidoscope::Plugin {
PersistentLEDMode() {} PersistentLEDMode() {}
EventHandlerResult onSetup(); EventHandlerResult onSetup();
EventHandlerResult afterEachCycle(); EventHandlerResult onLEDModeChange();
private: private:
static uint16_t settings_base_; static uint16_t settings_base_;
static uint8_t cached_mode_index_; static uint8_t cached_mode_index_;

Loading…
Cancel
Save