astyle with current project style guidelines

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

@ -25,46 +25,46 @@
#include "LED-Off.h"
const Key keymaps[][ROWS][COLS] PROGMEM = {
[0] = KEYMAP_STACKED
(
M(0), 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,
[0] = KEYMAP_STACKED
(
M(0), 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_skip,
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
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_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_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_skip
),
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_skip
),
};
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
if (macroIndex == 0 && key_toggled_off (keyState)) {
FingerPainter.toggleEdit ();
}
if (macroIndex == 0 && key_toggled_off(keyState)) {
FingerPainter.toggleEdit();
}
return MACRO_NONE;
return MACRO_NONE;
}
void setup () {
Serial.begin (9600);
void setup() {
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 () {
Kaleidoscope.loop ();
void loop() {
Kaleidoscope.loop();
}

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

@ -22,20 +22,20 @@
namespace KaleidoscopePlugins {
class FingerPainter : public LEDMode {
public:
FingerPainter (void);
public:
FingerPainter(void);
virtual void begin (void) final;
virtual void update (void) final;
virtual void begin(void) final;
virtual void update(void) final;
static void toggleEdit (void);
static bool focusHook (const char *command);
static void toggleEdit(void);
static bool focusHook(const char *command);
private:
static uint16_t colorBase;
static bool editMode;
private:
static uint16_t colorBase;
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