Updated to use the new LEDMode/LEDControl API

Signed-off-by: Gergely Nagy <kaleidoscope@gergo.csillger.hu>
pull/365/head
Gergely Nagy 7 years ago
parent b078a29d23
commit 0d22199cac

@ -23,20 +23,12 @@ namespace kaleidoscope {
uint16_t AlphaSquareEffect::length = 1000;
uint32_t AlphaSquareEffect::end_time_left_, AlphaSquareEffect::end_time_right_;
Key AlphaSquareEffect::last_key_left_, AlphaSquareEffect::last_key_right_;
uint8_t AlphaSquareEffect::us_;
AlphaSquareEffect::AlphaSquareEffect(void) {
}
void
AlphaSquareEffect::begin(void) {
void AlphaSquareEffect::setup(void) {
Kaleidoscope.useEventHandlerHook(eventHandlerHook);
Kaleidoscope.use(&LEDControl);
us_ = LEDControl.mode_add(this);
}
void
AlphaSquareEffect::update(void) {
void AlphaSquareEffect::update(void) {
if (end_time_left_ && millis() > end_time_left_) {
::AlphaSquare.clear(last_key_left_);
end_time_left_ = 0;
@ -47,9 +39,8 @@ AlphaSquareEffect::update(void) {
}
}
Key
AlphaSquareEffect::eventHandlerHook(Key key, byte row, byte col, uint8_t key_state) {
if (LEDControl.get_mode() != us_)
Key AlphaSquareEffect::eventHandlerHook(Key key, byte row, byte col, uint8_t key_state) {
if (::LEDControl.get_mode() != &::AlphaSquareEffect)
return key;
if (key_state & INJECTED)

@ -24,16 +24,16 @@
namespace kaleidoscope {
class AlphaSquareEffect : public LEDMode {
public:
AlphaSquareEffect(void);
AlphaSquareEffect(void) {}
void begin(void) final;
static uint16_t length;
protected:
void setup(void) final;
void update(void) final;
static uint16_t length;
private:
static uint32_t end_time_left_, end_time_right_;
static Key last_key_left_, last_key_right_;
static uint8_t us_;
static Key eventHandlerHook(Key key, uint8_t row, uint8_t col, uint8_t key_state);
};

@ -90,11 +90,11 @@ void AlphaSquare::display(uint16_t symbol, uint8_t row, uint8_t col, cRGB key_co
if (!pixel)
continue;
LEDControl.setCrgbAt(row + r, col + c, key_color);
::LEDControl.setCrgbAt(row + r, col + c, key_color);
}
}
LEDControl.syncLeds();
::LEDControl.syncLeds();
}
void AlphaSquare::display(uint16_t symbol, uint8_t row, uint8_t col) {

Loading…
Cancel
Save