From 517636d479b3e4a3114d68ae9c6a16f717febc31 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Fri, 26 May 2017 16:20:21 -0700 Subject: [PATCH] make astyle --- examples/EEPROM-Colormap/EEPROM-Colormap.ino | 46 +++--- src/Kaleidoscope/EEPROM-Colormap.cpp | 150 +++++++++---------- src/Kaleidoscope/EEPROM-Colormap.h | 4 +- 3 files changed, 99 insertions(+), 101 deletions(-) diff --git a/examples/EEPROM-Colormap/EEPROM-Colormap.ino b/examples/EEPROM-Colormap/EEPROM-Colormap.ino index 47eeb497..536288e7 100644 --- a/examples/EEPROM-Colormap/EEPROM-Colormap.ino +++ b/examples/EEPROM-Colormap/EEPROM-Colormap.ino @@ -20,34 +20,34 @@ #include const Key keymaps[][ROWS][COLS] PROGMEM = { - [0] = KEYMAP_STACKED - ( - Key_LEDEffectNext, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext, - Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab, - Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G, - Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape, - - Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, - Key_NoKey, - - Key_skip, Key_6, Key_7, Key_8, Key_9, Key_0, Key_skip, - Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals, - Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote, - Key_skip, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus, - - Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, - Key_NoKey - ), + [0] = KEYMAP_STACKED + ( + Key_LEDEffectNext, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext, + Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab, + Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G, + Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape, + + Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, + Key_NoKey, + + Key_skip, Key_6, Key_7, Key_8, Key_9, Key_0, Key_skip, + Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals, + Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote, + Key_skip, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus, + + Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, + Key_NoKey + ), }; void setup () { - Kaleidoscope.use (&EEPROMColormapEffect, NULL); + Kaleidoscope.use (&EEPROMColormapEffect, NULL); - Kaleidoscope.setup (); - EEPROMColormapEffect.configure (1); - EEPROMColormapEffect.activate (); + Kaleidoscope.setup (); + EEPROMColormapEffect.configure (1); + EEPROMColormapEffect.activate (); } void loop () { - Kaleidoscope.loop (); + Kaleidoscope.loop (); } diff --git a/src/Kaleidoscope/EEPROM-Colormap.cpp b/src/Kaleidoscope/EEPROM-Colormap.cpp index e11fc96c..2d4d5bff 100644 --- a/src/Kaleidoscope/EEPROM-Colormap.cpp +++ b/src/Kaleidoscope/EEPROM-Colormap.cpp @@ -23,145 +23,143 @@ namespace KaleidoscopePlugins { - uint16_t EEPROMColormapEffect::paletteBase; - uint16_t EEPROMColormapEffect::mapBase; - uint8_t EEPROMColormapEffect::maxLayers; +uint16_t EEPROMColormapEffect::paletteBase; +uint16_t EEPROMColormapEffect::mapBase; +uint8_t EEPROMColormapEffect::maxLayers; - EEPROMColormapEffect::EEPROMColormapEffect (void) { - } +EEPROMColormapEffect::EEPROMColormapEffect (void) { +} - void - EEPROMColormapEffect::configure (uint8_t maxLayers_) { +void +EEPROMColormapEffect::configure (uint8_t maxLayers_) { USE_PLUGINS (&::EEPROMSettings); maxLayers = maxLayers_; paletteBase = ::EEPROMSettings.requestSlice (15 * sizeof (cRGB)); mapBase = ::EEPROMSettings.requestSlice (maxLayers * ROWS * COLS / 2); - } +} - void - EEPROMColormapEffect::update (void) { +void +EEPROMColormapEffect::update (void) { for (uint8_t l = 0; l < 32; l++) { - if (!Layer.isOn (l)) - continue; + if (!Layer.isOn (l)) + continue; - for (uint8_t r = 0; r < ROWS; r++) { - for (uint8_t c = 0; c < COLS; c++) { - cRGB color; + for (uint8_t r = 0; r < ROWS; r++) { + for (uint8_t c = 0; c < COLS; c++) { + cRGB color; - if (!lookupColor (l, r, c, &color)) - continue; + if (!lookupColor (l, r, c, &color)) + continue; - LEDControl.led_set_crgb_at (r, c, color); + LEDControl.led_set_crgb_at (r, c, color); + } } - } } - } +} - const bool - EEPROMColormapEffect::lookupColor (uint8_t layer, uint8_t row, uint8_t column, cRGB *color) { +const bool +EEPROMColormapEffect::lookupColor (uint8_t layer, uint8_t row, uint8_t column, cRGB *color) { uint8_t colorIndex; uint16_t mapIndex = (layer * ROWS * COLS / 2 + row * COLS / 2 + column / 2); colorIndex = EEPROM.read (mapBase + mapIndex); if (column % 2) - colorIndex &= ~0xf0; + colorIndex &= ~0xf0; else - colorIndex >>= 4; + colorIndex >>= 4; if (colorIndex == Transparent) - return false; + return false; EEPROM.get (paletteBase + colorIndex * sizeof (cRGB), *color); return true; - } +} - bool - EEPROMColormapEffect::focusHook (const char *command) { +bool +EEPROMColormapEffect::focusHook (const char *command) { enum { - PALETTE, - MAP, + PALETTE, + MAP, } subCommand; if (strncmp_P (command, PSTR ("colormap."), 9) != 0) - return false; + return false; if (strcmp_P (command + 9, PSTR ("palette")) == 0) - subCommand = PALETTE; + subCommand = PALETTE; else if (strcmp_P (command + 9, PSTR ("map")) == 0) - subCommand = MAP; + subCommand = MAP; else - return false; + return false; switch (subCommand) { - case PALETTE: - { + case PALETTE: { if (Serial.peek () == '\n') { - for (uint8_t i = 0; i < 15; i++) { - cRGB color; + for (uint8_t i = 0; i < 15; i++) { + cRGB color; - EEPROM.get (paletteBase + i * sizeof (color), color); - ::Focus.printColor (color.r, color.g, color.b); - ::Focus.printSpace (); - } - Serial.println (); - break; + EEPROM.get (paletteBase + i * sizeof (color), color); + ::Focus.printColor (color.r, color.g, color.b); + ::Focus.printSpace (); + } + Serial.println (); + break; } uint8_t i = 0; while (i < 15 && Serial.peek() != '\n') { - cRGB color; + cRGB color; - color.r = Serial.parseInt (); - color.g = Serial.parseInt (); - color.b = Serial.parseInt (); + color.r = Serial.parseInt (); + color.g = Serial.parseInt (); + color.b = Serial.parseInt (); - EEPROM.put (paletteBase + i * sizeof (color), color); - i++; + EEPROM.put (paletteBase + i * sizeof (color), color); + i++; } break; - } + } - case MAP: - { + case MAP: { if (Serial.peek () == '\n') { - for (uint8_t layer = 0; layer < maxLayers; layer++) { - for (uint8_t row = 0; row < ROWS; row++) { - for (uint8_t col = 0; col < COLS / 2; col++) { - uint8_t indexes; - uint16_t loc = (layer * ROWS * COLS / 2 + row * COLS / 2 + col); - - indexes = EEPROM.read (mapBase + loc); - - ::Focus.printNumber (indexes >> 4); - ::Focus.printSpace (); - ::Focus.printNumber (indexes & ~0xf0); - ::Focus.printSpace (); - } + for (uint8_t layer = 0; layer < maxLayers; layer++) { + for (uint8_t row = 0; row < ROWS; row++) { + for (uint8_t col = 0; col < COLS / 2; col++) { + uint8_t indexes; + uint16_t loc = (layer * ROWS * COLS / 2 + row * COLS / 2 + col); + + indexes = EEPROM.read (mapBase + loc); + + ::Focus.printNumber (indexes >> 4); + ::Focus.printSpace (); + ::Focus.printNumber (indexes & ~0xf0); + ::Focus.printSpace (); + } + } } - } - Serial.println (); - break; + Serial.println (); + break; } uint16_t maxIndex = (maxLayers * ROWS * COLS) / 2; uint8_t loc = 0; while ((Serial.peek () != '\n') && (loc < maxIndex)) { - uint8_t idx1 = Serial.parseInt (); - uint8_t idx2 = Serial.parseInt (); - uint8_t indexes = (idx1 << 4) + idx2; + uint8_t idx1 = Serial.parseInt (); + uint8_t idx2 = Serial.parseInt (); + uint8_t indexes = (idx1 << 4) + idx2; - EEPROM.update (mapBase + loc , indexes); - loc++; + EEPROM.update (mapBase + loc, indexes); + loc++; } break; - } + } } return true; - } +} }; diff --git a/src/Kaleidoscope/EEPROM-Colormap.h b/src/Kaleidoscope/EEPROM-Colormap.h index 1c7adacf..e21b0e9d 100644 --- a/src/Kaleidoscope/EEPROM-Colormap.h +++ b/src/Kaleidoscope/EEPROM-Colormap.h @@ -21,7 +21,7 @@ #include namespace KaleidoscopePlugins { - class EEPROMColormapEffect : public LEDMode { +class EEPROMColormapEffect : public LEDMode { public: static const uint8_t Transparent = 15; @@ -37,7 +37,7 @@ namespace KaleidoscopePlugins { static uint8_t maxLayers; static uint16_t paletteBase; static uint16_t mapBase; - }; +}; }; extern KaleidoscopePlugins::EEPROMColormapEffect EEPROMColormapEffect;