Refactoring to save 44 more PROGMEM and 12 more RAM

pull/365/head
Jesse Vincent 6 years ago
parent b144f626e4
commit 3dd86e34dd

@ -12,22 +12,12 @@
#define RELEASED 0 #define RELEASED 0
cRGB red;
cRGB blue;
cRGB green;
cRGB white;
TestMode_::TestMode_(void) { TestMode_::TestMode_(void) {
} }
void TestMode_::begin(void) { void TestMode_::begin(void) {
red.r = 201;
blue.b = 201;
green.g = 201;
white.r = 50;
white.g = 50;
white.b = 50;
Kaleidoscope.useLoopHook(this->loopHook); Kaleidoscope.useLoopHook(this->loopHook);
} }
@ -42,7 +32,7 @@ void TestMode_::loopHook(bool postClear) {
} }
void TestMode_::waitForKeypress() { void TestMode_::waitForKeypress() {
for (auto temp = 0; temp < 16; temp++) { for (uint8_t temp = 0; temp < 8; temp++) {
KeyboardHardware.readMatrix(); KeyboardHardware.readMatrix();
} }
while (1) { while (1) {
@ -54,21 +44,27 @@ void TestMode_::waitForKeypress() {
} }
} }
void TestMode_::set_leds(uint8_t r, uint8_t g, uint8_t b) { void TestMode_::set_leds(cRGB color) {
LEDControl.set_all_leds_to(r, g, b); LEDControl.set_all_leds_to(color);
LEDControl.syncLeds(); LEDControl.syncLeds();
waitForKeypress(); waitForKeypress();
} }
void TestMode_::test_leds(void) { void TestMode_::test_leds(void) {
cRGB red = { b:0, g:0, r: 201 } ;
cRGB blue = { b:201, g:0, r: 0 } ;
cRGB green = { b:0, g:201, r: 0 } ;
cRGB white = { b:50, g:50, r: 50 } ;
cRGB brightWhite = { b:160, g:160, r: 160 } ;
// make all the LEDs bright red // make all the LEDs bright red
set_leds(200, 0, 0); set_leds(red);
// make all the LEDs bright green // make all the LEDs bright green
set_leds(0, 200, 0); set_leds(green);
// make all the LEDs bright blue // make all the LEDs bright blue
set_leds(0, 0, 200); set_leds(blue);
// make all the LEDs bright white (1.6A) // make all the LEDs bright white (1.6A)
set_leds(160, 160, 160); set_leds(brightWhite);
// rainbow for 10 seconds // rainbow for 10 seconds
for (auto i = 0; i < 1000; i++) { for (auto i = 0; i < 1000; i++) {
LEDRainbowEffect.update(); LEDRainbowEffect.update();
@ -80,6 +76,11 @@ void TestMode_::test_leds(void) {
void TestMode_::handleKeyEvent(side_data_t *side, keydata_t oldState, keydata_t newState, uint8_t row, uint8_t col, uint8_t col_offset) { void TestMode_::handleKeyEvent(side_data_t *side, keydata_t oldState, keydata_t newState, uint8_t row, uint8_t col, uint8_t col_offset) {
cRGB red = { b:0, g:0, r: 201 } ;
cRGB blue = { b:201, g:0, r: 0 } ;
cRGB green = { b:0, g:201, r: 0 } ;
uint8_t keynum = (row * 8) + (col); uint8_t keynum = (row * 8) + (col);
uint8_t keyState = ((bitRead(oldState.all, keynum) << 1) | uint8_t keyState = ((bitRead(oldState.all, keynum) << 1) |

@ -25,7 +25,7 @@ class TestMode_ : public KaleidoscopePlugin {
static void handleKeyEvent(side_data_t *side, keydata_t oldState, keydata_t newState, uint8_t row, uint8_t col, uint8_t col_offset); static void handleKeyEvent(side_data_t *side, keydata_t oldState, keydata_t newState, uint8_t row, uint8_t col, uint8_t col_offset);
static void waitForKeypress(); static void waitForKeypress();
static void loopHook(bool postClear); static void loopHook(bool postClear);
static void set_leds(uint8_t r, uint8_t g, uint8_t b); static void set_leds(cRGB color);
}; };
extern TestMode_ TestMode; extern TestMode_ TestMode;

Loading…
Cancel
Save