make astyle

pull/389/head
Jesse Vincent 8 years ago
parent 9dcb132dbe
commit 517636d479
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -20,34 +20,34 @@
#include <Kaleidoscope-EEPROM-Colormap.h> #include <Kaleidoscope-EEPROM-Colormap.h>
const Key keymaps[][ROWS][COLS] PROGMEM = { const Key keymaps[][ROWS][COLS] PROGMEM = {
[0] = KEYMAP_STACKED [0] = KEYMAP_STACKED
( (
Key_LEDEffectNext, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext, 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_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_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_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
Key_NoKey, Key_NoKey,
Key_skip, Key_6, Key_7, Key_8, Key_9, Key_0, Key_skip, 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_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_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_skip, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_NoKey Key_NoKey
), ),
}; };
void setup () { void setup () {
Kaleidoscope.use (&EEPROMColormapEffect, NULL); Kaleidoscope.use (&EEPROMColormapEffect, NULL);
Kaleidoscope.setup (); Kaleidoscope.setup ();
EEPROMColormapEffect.configure (1); EEPROMColormapEffect.configure (1);
EEPROMColormapEffect.activate (); EEPROMColormapEffect.activate ();
} }
void loop () { void loop () {
Kaleidoscope.loop (); Kaleidoscope.loop ();
} }

@ -23,145 +23,143 @@
namespace KaleidoscopePlugins { namespace KaleidoscopePlugins {
uint16_t EEPROMColormapEffect::paletteBase; uint16_t EEPROMColormapEffect::paletteBase;
uint16_t EEPROMColormapEffect::mapBase; uint16_t EEPROMColormapEffect::mapBase;
uint8_t EEPROMColormapEffect::maxLayers; uint8_t EEPROMColormapEffect::maxLayers;
EEPROMColormapEffect::EEPROMColormapEffect (void) { EEPROMColormapEffect::EEPROMColormapEffect (void) {
} }
void void
EEPROMColormapEffect::configure (uint8_t maxLayers_) { EEPROMColormapEffect::configure (uint8_t maxLayers_) {
USE_PLUGINS (&::EEPROMSettings); USE_PLUGINS (&::EEPROMSettings);
maxLayers = maxLayers_; maxLayers = maxLayers_;
paletteBase = ::EEPROMSettings.requestSlice (15 * sizeof (cRGB)); paletteBase = ::EEPROMSettings.requestSlice (15 * sizeof (cRGB));
mapBase = ::EEPROMSettings.requestSlice (maxLayers * ROWS * COLS / 2); mapBase = ::EEPROMSettings.requestSlice (maxLayers * ROWS * COLS / 2);
} }
void void
EEPROMColormapEffect::update (void) { EEPROMColormapEffect::update (void) {
for (uint8_t l = 0; l < 32; l++) { for (uint8_t l = 0; l < 32; l++) {
if (!Layer.isOn (l)) if (!Layer.isOn (l))
continue; continue;
for (uint8_t r = 0; r < ROWS; r++) { for (uint8_t r = 0; r < ROWS; r++) {
for (uint8_t c = 0; c < COLS; c++) { for (uint8_t c = 0; c < COLS; c++) {
cRGB color; cRGB color;
if (!lookupColor (l, r, c, &color)) if (!lookupColor (l, r, c, &color))
continue; continue;
LEDControl.led_set_crgb_at (r, c, color); LEDControl.led_set_crgb_at (r, c, color);
}
} }
}
} }
} }
const bool const bool
EEPROMColormapEffect::lookupColor (uint8_t layer, uint8_t row, uint8_t column, cRGB *color) { EEPROMColormapEffect::lookupColor (uint8_t layer, uint8_t row, uint8_t column, cRGB *color) {
uint8_t colorIndex; uint8_t colorIndex;
uint16_t mapIndex = (layer * ROWS * COLS / 2 + row * COLS / 2 + column / 2); uint16_t mapIndex = (layer * ROWS * COLS / 2 + row * COLS / 2 + column / 2);
colorIndex = EEPROM.read (mapBase + mapIndex); colorIndex = EEPROM.read (mapBase + mapIndex);
if (column % 2) if (column % 2)
colorIndex &= ~0xf0; colorIndex &= ~0xf0;
else else
colorIndex >>= 4; colorIndex >>= 4;
if (colorIndex == Transparent) if (colorIndex == Transparent)
return false; return false;
EEPROM.get (paletteBase + colorIndex * sizeof (cRGB), *color); EEPROM.get (paletteBase + colorIndex * sizeof (cRGB), *color);
return true; return true;
} }
bool bool
EEPROMColormapEffect::focusHook (const char *command) { EEPROMColormapEffect::focusHook (const char *command) {
enum { enum {
PALETTE, PALETTE,
MAP, MAP,
} subCommand; } subCommand;
if (strncmp_P (command, PSTR ("colormap."), 9) != 0) if (strncmp_P (command, PSTR ("colormap."), 9) != 0)
return false; return false;
if (strcmp_P (command + 9, PSTR ("palette")) == 0) if (strcmp_P (command + 9, PSTR ("palette")) == 0)
subCommand = PALETTE; subCommand = PALETTE;
else if (strcmp_P (command + 9, PSTR ("map")) == 0) else if (strcmp_P (command + 9, PSTR ("map")) == 0)
subCommand = MAP; subCommand = MAP;
else else
return false; return false;
switch (subCommand) { switch (subCommand) {
case PALETTE: case PALETTE: {
{
if (Serial.peek () == '\n') { if (Serial.peek () == '\n') {
for (uint8_t i = 0; i < 15; i++) { for (uint8_t i = 0; i < 15; i++) {
cRGB color; cRGB color;
EEPROM.get (paletteBase + i * sizeof (color), color); EEPROM.get (paletteBase + i * sizeof (color), color);
::Focus.printColor (color.r, color.g, color.b); ::Focus.printColor (color.r, color.g, color.b);
::Focus.printSpace (); ::Focus.printSpace ();
} }
Serial.println (); Serial.println ();
break; break;
} }
uint8_t i = 0; uint8_t i = 0;
while (i < 15 && Serial.peek() != '\n') { while (i < 15 && Serial.peek() != '\n') {
cRGB color; cRGB color;
color.r = Serial.parseInt (); color.r = Serial.parseInt ();
color.g = Serial.parseInt (); color.g = Serial.parseInt ();
color.b = Serial.parseInt (); color.b = Serial.parseInt ();
EEPROM.put (paletteBase + i * sizeof (color), color); EEPROM.put (paletteBase + i * sizeof (color), color);
i++; i++;
} }
break; break;
} }
case MAP: case MAP: {
{
if (Serial.peek () == '\n') { if (Serial.peek () == '\n') {
for (uint8_t layer = 0; layer < maxLayers; layer++) { for (uint8_t layer = 0; layer < maxLayers; layer++) {
for (uint8_t row = 0; row < ROWS; row++) { for (uint8_t row = 0; row < ROWS; row++) {
for (uint8_t col = 0; col < COLS / 2; col++) { for (uint8_t col = 0; col < COLS / 2; col++) {
uint8_t indexes; uint8_t indexes;
uint16_t loc = (layer * ROWS * COLS / 2 + row * COLS / 2 + col); uint16_t loc = (layer * ROWS * COLS / 2 + row * COLS / 2 + col);
indexes = EEPROM.read (mapBase + loc); indexes = EEPROM.read (mapBase + loc);
::Focus.printNumber (indexes >> 4); ::Focus.printNumber (indexes >> 4);
::Focus.printSpace (); ::Focus.printSpace ();
::Focus.printNumber (indexes & ~0xf0); ::Focus.printNumber (indexes & ~0xf0);
::Focus.printSpace (); ::Focus.printSpace ();
} }
}
} }
} Serial.println ();
Serial.println (); break;
break;
} }
uint16_t maxIndex = (maxLayers * ROWS * COLS) / 2; uint16_t maxIndex = (maxLayers * ROWS * COLS) / 2;
uint8_t loc = 0; uint8_t loc = 0;
while ((Serial.peek () != '\n') && (loc < maxIndex)) { while ((Serial.peek () != '\n') && (loc < maxIndex)) {
uint8_t idx1 = Serial.parseInt (); uint8_t idx1 = Serial.parseInt ();
uint8_t idx2 = Serial.parseInt (); uint8_t idx2 = Serial.parseInt ();
uint8_t indexes = (idx1 << 4) + idx2; uint8_t indexes = (idx1 << 4) + idx2;
EEPROM.update (mapBase + loc , indexes); EEPROM.update (mapBase + loc, indexes);
loc++; loc++;
} }
break; break;
} }
} }
return true; return true;
} }
}; };

@ -21,7 +21,7 @@
#include <Kaleidoscope-LEDControl.h> #include <Kaleidoscope-LEDControl.h>
namespace KaleidoscopePlugins { namespace KaleidoscopePlugins {
class EEPROMColormapEffect : public LEDMode { class EEPROMColormapEffect : public LEDMode {
public: public:
static const uint8_t Transparent = 15; static const uint8_t Transparent = 15;
@ -37,7 +37,7 @@ namespace KaleidoscopePlugins {
static uint8_t maxLayers; static uint8_t maxLayers;
static uint16_t paletteBase; static uint16_t paletteBase;
static uint16_t mapBase; static uint16_t mapBase;
}; };
}; };
extern KaleidoscopePlugins::EEPROMColormapEffect EEPROMColormapEffect; extern KaleidoscopePlugins::EEPROMColormapEffect EEPROMColormapEffect;

Loading…
Cancel
Save