astyle with current project style guidelines

pull/389/head
Jesse Vincent 8 years ago
parent 09ba7dd756
commit df5c08d5d5
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -46,25 +46,25 @@ const Key keymaps[][ROWS][COLS] PROGMEM = {
}; };
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
if (macroIndex == 0 && key_toggled_off (keyState)) { if (macroIndex == 0 && key_toggled_off(keyState)) {
FingerPainter.toggleEdit (); FingerPainter.toggleEdit();
} }
return MACRO_NONE; return MACRO_NONE;
} }
void setup () { void setup() {
Serial.begin (9600); Serial.begin(9600);
Kaleidoscope.setup (); Kaleidoscope.setup();
USE_PLUGINS (&LEDOff, &EEPROMSettings, &FingerPainter, &Macros); USE_PLUGINS(&LEDOff, &EEPROMSettings, &FingerPainter, &Macros);
EEPROMSettings.seal (); EEPROMSettings.seal();
FingerPainter.activate (); FingerPainter.activate();
} }
void loop () { void loop() {
Kaleidoscope.loop (); Kaleidoscope.loop();
} }

@ -28,47 +28,47 @@ namespace KaleidoscopePlugins {
uint16_t FingerPainter::colorBase; uint16_t FingerPainter::colorBase;
bool FingerPainter::editMode; bool FingerPainter::editMode;
FingerPainter::FingerPainter (void) { FingerPainter::FingerPainter(void) {
} }
void void
FingerPainter::begin (void) { FingerPainter::begin(void) {
USE_PLUGINS (&::LEDPaletteTheme); USE_PLUGINS(&::LEDPaletteTheme);
LEDMode::begin (); LEDMode::begin();
event_handler_hook_use (eventHandlerHook); event_handler_hook_use(eventHandlerHook);
colorBase = ::LEDPaletteTheme.reserveThemes (1); colorBase = ::LEDPaletteTheme.reserveThemes(1);
} }
void void
FingerPainter::update (void) { FingerPainter::update(void) {
::LEDPaletteTheme.update (colorBase, 0); ::LEDPaletteTheme.update(colorBase, 0);
} }
void void
FingerPainter::toggleEdit (void) { FingerPainter::toggleEdit(void) {
editMode = !editMode; editMode = !editMode;
} }
Key Key
FingerPainter::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState) { FingerPainter::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState) {
if (!editMode) if (!editMode)
return mappedKey; return mappedKey;
if (!key_toggled_on (keyState)) if (!key_toggled_on(keyState))
return Key_NoKey; return Key_NoKey;
if (row >= ROWS || col >= COLS) if (row >= ROWS || col >= COLS)
return Key_NoKey; return Key_NoKey;
uint8_t colorIndex = ::LEDPaletteTheme.lookupColorIndex (colorBase, KeyboardHardware.get_led_index (row, col)); uint8_t colorIndex = ::LEDPaletteTheme.lookupColorIndex(colorBase, KeyboardHardware.get_led_index(row, col));
// Find the next color in the palette that is different. // Find the next color in the palette that is different.
// But do not loop forever! // But do not loop forever!
bool turnAround = false; bool turnAround = false;
cRGB oldColor = ::LEDPaletteTheme.lookupColor (colorIndex), newColor = oldColor; cRGB oldColor = ::LEDPaletteTheme.lookupColor(colorIndex), newColor = oldColor;
while (memcmp (&oldColor, &newColor, sizeof (cRGB)) == 0) { while (memcmp(&oldColor, &newColor, sizeof(cRGB)) == 0) {
colorIndex++; colorIndex++;
if (colorIndex > 15) { if (colorIndex > 15) {
colorIndex = 0; colorIndex = 0;
@ -76,40 +76,40 @@ FingerPainter::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyS
break; break;
turnAround = true; turnAround = true;
} }
newColor = ::LEDPaletteTheme.lookupColor (colorIndex); newColor = ::LEDPaletteTheme.lookupColor(colorIndex);
} }
::LEDPaletteTheme.updateColor (colorBase, KeyboardHardware.get_led_index (row, col), colorIndex); ::LEDPaletteTheme.updateColor(colorBase, KeyboardHardware.get_led_index(row, col), colorIndex);
return Key_NoKey; return Key_NoKey;
} }
bool bool
FingerPainter::focusHook (const char *command) { FingerPainter::focusHook(const char *command) {
enum { enum {
TOGGLE, TOGGLE,
CLEAR, CLEAR,
} subCommand; } subCommand;
if (strncmp_P (command, PSTR ("fingerpainter."), 14) != 0) if (strncmp_P(command, PSTR("fingerpainter."), 14) != 0)
return false; return false;
if (strcmp_P (command + 14, PSTR ("toggle")) == 0) if (strcmp_P(command + 14, PSTR("toggle")) == 0)
subCommand = TOGGLE; subCommand = TOGGLE;
else if (strcmp_P (command + 14, PSTR ("clear")) == 0) else if (strcmp_P(command + 14, PSTR("clear")) == 0)
subCommand = CLEAR; subCommand = CLEAR;
else else
return false; return false;
if (subCommand == CLEAR) { if (subCommand == CLEAR) {
for (uint16_t i = 0; i < ROWS * COLS / 2; i++) { for (uint16_t i = 0; i < ROWS * COLS / 2; i++) {
EEPROM.update (colorBase + i, 0); EEPROM.update(colorBase + i, 0);
} }
return true; return true;
} }
::FingerPainter.activate (); ::FingerPainter.activate();
toggleEdit (); toggleEdit();
return true; return true;
} }

@ -23,19 +23,19 @@
namespace KaleidoscopePlugins { namespace KaleidoscopePlugins {
class FingerPainter : public LEDMode { class FingerPainter : public LEDMode {
public: public:
FingerPainter (void); FingerPainter(void);
virtual void begin (void) final; virtual void begin(void) final;
virtual void update (void) final; virtual void update(void) final;
static void toggleEdit (void); static void toggleEdit(void);
static bool focusHook (const char *command); static bool focusHook(const char *command);
private: private:
static uint16_t colorBase; static uint16_t colorBase;
static bool editMode; static bool editMode;
static Key eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState); static Key eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState);
}; };
}; };

Loading…
Cancel
Save