|
|
@ -18,12 +18,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include <Kaleidoscope-LED-AlphaSquare.h>
|
|
|
|
#include <Kaleidoscope-LED-AlphaSquare.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace KaleidoscopePlugins {
|
|
|
|
namespace kaleidoscope {
|
|
|
|
namespace LEDEffects {
|
|
|
|
|
|
|
|
uint16_t AlphaSquareEffect::length = 1000;
|
|
|
|
uint16_t AlphaSquareEffect::length = 1000;
|
|
|
|
uint32_t AlphaSquareEffect::endTimeLeft, AlphaSquareEffect::endTimeRight;
|
|
|
|
uint32_t AlphaSquareEffect::end_time_left_, AlphaSquareEffect::end_time_right_;
|
|
|
|
Key AlphaSquareEffect::lastKeyLeft, AlphaSquareEffect::lastKeyRight;
|
|
|
|
Key AlphaSquareEffect::last_key_left_, AlphaSquareEffect::last_key_right_;
|
|
|
|
uint8_t AlphaSquareEffect::us;
|
|
|
|
uint8_t AlphaSquareEffect::us_;
|
|
|
|
|
|
|
|
|
|
|
|
AlphaSquareEffect::AlphaSquareEffect(void) {
|
|
|
|
AlphaSquareEffect::AlphaSquareEffect(void) {
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -32,54 +32,54 @@ void
|
|
|
|
AlphaSquareEffect::begin(void) {
|
|
|
|
AlphaSquareEffect::begin(void) {
|
|
|
|
Kaleidoscope.useEventHandlerHook(eventHandlerHook);
|
|
|
|
Kaleidoscope.useEventHandlerHook(eventHandlerHook);
|
|
|
|
Kaleidoscope.use(&LEDControl, NULL);
|
|
|
|
Kaleidoscope.use(&LEDControl, NULL);
|
|
|
|
us = LEDControl.mode_add(this);
|
|
|
|
us_ = LEDControl.mode_add(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
AlphaSquareEffect::update(void) {
|
|
|
|
AlphaSquareEffect::update(void) {
|
|
|
|
if (endTimeLeft && millis() > endTimeLeft) {
|
|
|
|
if (end_time_left_ && millis() > end_time_left_) {
|
|
|
|
::AlphaSquare.clear(lastKeyLeft);
|
|
|
|
::AlphaSquare.clear(last_key_left_);
|
|
|
|
endTimeLeft = 0;
|
|
|
|
end_time_left_ = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (endTimeRight && millis() > endTimeRight) {
|
|
|
|
if (end_time_right_ && millis() > end_time_right_) {
|
|
|
|
::AlphaSquare.clear(lastKeyRight, 10);
|
|
|
|
::AlphaSquare.clear(last_key_right_, 10);
|
|
|
|
endTimeRight = 0;
|
|
|
|
end_time_right_ = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Key
|
|
|
|
Key
|
|
|
|
AlphaSquareEffect::eventHandlerHook(Key key, byte row, byte col, uint8_t keyState) {
|
|
|
|
AlphaSquareEffect::eventHandlerHook(Key key, byte row, byte col, uint8_t key_state) {
|
|
|
|
if (LEDControl.get_mode() != us)
|
|
|
|
if (LEDControl.get_mode() != us_)
|
|
|
|
return key;
|
|
|
|
return key;
|
|
|
|
|
|
|
|
|
|
|
|
if (keyState & INJECTED)
|
|
|
|
if (key_state & INJECTED)
|
|
|
|
return key;
|
|
|
|
return key;
|
|
|
|
|
|
|
|
|
|
|
|
if (key < Key_A || key > Key_0)
|
|
|
|
if (key < Key_A || key > Key_0)
|
|
|
|
return key;
|
|
|
|
return key;
|
|
|
|
|
|
|
|
|
|
|
|
if (!key_is_pressed(keyState))
|
|
|
|
if (!key_is_pressed(key_state))
|
|
|
|
return key;
|
|
|
|
return key;
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t displayCol = 2;
|
|
|
|
uint8_t display_col = 2;
|
|
|
|
Key prevKey = lastKeyLeft;
|
|
|
|
Key prev_key = last_key_left_;
|
|
|
|
|
|
|
|
|
|
|
|
if (col < COLS / 2) {
|
|
|
|
if (col < COLS / 2) {
|
|
|
|
lastKeyLeft = key;
|
|
|
|
last_key_left_ = key;
|
|
|
|
endTimeLeft = millis() + length;
|
|
|
|
end_time_left_ = millis() + length;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
prevKey = lastKeyRight;
|
|
|
|
prev_key = last_key_right_;
|
|
|
|
lastKeyRight = key;
|
|
|
|
last_key_right_ = key;
|
|
|
|
endTimeRight = millis() + length;
|
|
|
|
end_time_right_ = millis() + length;
|
|
|
|
displayCol = 10;
|
|
|
|
display_col = 10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (prevKey != key)
|
|
|
|
if (prev_key != key)
|
|
|
|
::AlphaSquare.clear(prevKey, displayCol);
|
|
|
|
::AlphaSquare.clear(prev_key, display_col);
|
|
|
|
::AlphaSquare.display(key, displayCol);
|
|
|
|
::AlphaSquare.display(key, display_col);
|
|
|
|
return key;
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
KaleidoscopePlugins::LEDEffects::AlphaSquareEffect AlphaSquareEffect;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
kaleidoscope::AlphaSquareEffect AlphaSquareEffect;
|
|
|
|