Add theme focus handler for layerwise themes

pull/389/head
James N. V. Cash 7 years ago
parent cbf651f8bd
commit 6a5a7166c1

@ -158,6 +158,46 @@ bool LEDPaletteTheme::themeFocusHandler(const char *command, const char *expecte
return true; return true;
} }
bool LEDPaletteTheme::themeFocusHandlerLayerwise(const char *command,
const char *expected_command,
uint16_t theme_base,
uint8_t max_themes) {
if (strcmp_P(command, expected_command) != 0)
return false;
uint16_t count_per_layer = (ROWS * COLS) / 2;
uint8_t layer = Serial.parseInt();
uint16_t offset = theme_base + (layer * count_per_layer);
if (Serial.peek() == '\n') {
for (uint16_t pos = 0; pos < count_per_layer; pos++) {
uint8_t indexes = EEPROM.read(offset + pos);
::Focus.printNumber(indexes >> 4);
::Focus.printSpace();
::Focus.printNumber(indexes & ~0xf0);
::Focus.printSpace();
}
Serial.println();
return true;
}
uint16_t pos = 0;
while ((Serial.peek() != '\n') && (pos < count_per_layer)) {
uint8_t idx1 = Serial.parseInt();
uint8_t idx2 = Serial.parseInt();
uint8_t indexes = (idx1 << 4) + idx2;
EEPROM.update(offset + pos, indexes);
pos++;
}
return true;
}
} }
kaleidoscope::LEDPaletteTheme LEDPaletteTheme; kaleidoscope::LEDPaletteTheme LEDPaletteTheme;

@ -43,6 +43,10 @@ class LEDPaletteTheme : public KaleidoscopePlugin {
static bool themeFocusHandler(const char *command, const char *expected_command, static bool themeFocusHandler(const char *command, const char *expected_command,
uint16_t theme_base, uint8_t max_themes); uint16_t theme_base, uint8_t max_themes);
static bool themeFocusHandlerLayerwise(const char *command,
const char *expected_command,
uint16_t theme_base,
uint8_t max_themes);
private: private:
static uint16_t palette_base_; static uint16_t palette_base_;
}; };

Loading…
Cancel
Save