From 332b5ceec3963a5ecbf123865698d824d1eedc43 Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 15 Feb 2019 15:13:07 +0000 Subject: probably simpler: use LEDMode --- color-picker.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'color-picker.h') diff --git a/color-picker.h b/color-picker.h index 9782ef7..9aa9f1f 100644 --- a/color-picker.h +++ b/color-picker.h @@ -1,26 +1,27 @@ // -*- mode: c++ -*- #pragma once -#include +#include -class ColorPicker : public kaleidoscope::Plugin { +class ColorPicker : public kaleidoscope::plugin::LEDMode { public: - ColorPicker(void) : is_active(false), current_index(0), colors{}, map{} { } - - void toggle(void) { is_active = !is_active; } + ColorPicker(void) : current_index(0), colors{}, map{} { } kaleidoscope::EventHandlerResult onKeyswitchEvent(Key &mapped_key, byte row, byte col, uint8_t key_state) { - if (!Kaleidoscope.has_leds || !is_active) + if (!Kaleidoscope.has_leds || !is_active()) return kaleidoscope::EventHandlerResult::OK; return kaleidoscope::EventHandlerResult::EVENT_CONSUMED; } private: - bool is_active; uint8_t current_index; cRGB colors[16]; uint8_t map[ROWS][COLS]; + + bool is_active() { + return LEDControl.get_mode() == this; + } }; ColorPicker theColorPicker; -- cgit v1.2.3