Merge pull request #4 from jamesnvc/layerwise-hooks

Add theme focus handler for layerwise themes
pull/389/head
Gergely Nagy 7 years ago committed by GitHub
commit 42e60891d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -158,6 +158,44 @@ bool LEDPaletteTheme::themeFocusHandler(const char *command, const char *expecte
return true;
}
bool LEDPaletteTheme::themeLayerFocusHandler(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;

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

Loading…
Cancel
Save