astyle with current project style guidelines

pull/365/head
Jesse Vincent 8 years ago
parent 356dd681f9
commit ecef342f1f
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -43,14 +43,14 @@ 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 (!key_toggled_on (keyState)) if (!key_toggled_on(keyState))
return MACRO_NONE; return MACRO_NONE;
if (macroIndex == 0) { if (macroIndex == 0) {
for (uint8_t i = Key_A.keyCode; i <= Key_0.keyCode; i++) { for (uint8_t i = Key_A.keyCode; i <= Key_0.keyCode; i++) {
LEDControl.set_all_leds_to (0, 0, 0); LEDControl.set_all_leds_to(0, 0, 0);
LEDControl.led_sync (); LEDControl.led_sync();
delay (100); delay(100);
uint8_t col = 2; uint8_t col = 2;
if (i % 2) if (i % 2)
@ -58,47 +58,47 @@ const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
for (uint8_t step = 0; step <= 0xf0; step += 8) { for (uint8_t step = 0; step <= 0xf0; step += 8) {
AlphaSquare.color = { step, step, step }; AlphaSquare.color = { step, step, step };
AlphaSquare.display ({i, 0}, col); AlphaSquare.display({i, 0}, col);
delay (10); delay(10);
} }
for (uint8_t step = 0xff; step >= 8; step -= 8) { for (uint8_t step = 0xff; step >= 8; step -= 8) {
AlphaSquare.color = { step, step, step }; AlphaSquare.color = { step, step, step };
AlphaSquare.display ({i, 0}, col); AlphaSquare.display({i, 0}, col);
delay (10); delay(10);
} }
delay (100); delay(100);
} }
LEDControl.set_all_leds_to (0, 0, 0); LEDControl.set_all_leds_to(0, 0, 0);
LEDControl.led_sync (); LEDControl.led_sync();
delay (100); delay(100);
for (uint8_t step = 0; step <= 0xf0; step += 8) { for (uint8_t step = 0; step <= 0xf0; step += 8) {
AlphaSquare.color = { step, step, step }; AlphaSquare.color = { step, step, step };
AlphaSquare.display (KaleidoscopePlugins::AlphaSquareSymbols::Lambda, 2); AlphaSquare.display(KaleidoscopePlugins::AlphaSquareSymbols::Lambda, 2);
AlphaSquare.display (KaleidoscopePlugins::AlphaSquareSymbols::Lambda, 10); AlphaSquare.display(KaleidoscopePlugins::AlphaSquareSymbols::Lambda, 10);
delay (10); delay(10);
} }
for (uint8_t step = 0xff; step >= 8; step -= 8) { for (uint8_t step = 0xff; step >= 8; step -= 8) {
AlphaSquare.color = { step, step, step }; AlphaSquare.color = { step, step, step };
AlphaSquare.display (KaleidoscopePlugins::AlphaSquareSymbols::Lambda, 2); AlphaSquare.display(KaleidoscopePlugins::AlphaSquareSymbols::Lambda, 2);
AlphaSquare.display (KaleidoscopePlugins::AlphaSquareSymbols::Lambda, 10); AlphaSquare.display(KaleidoscopePlugins::AlphaSquareSymbols::Lambda, 10);
delay (10); delay(10);
} }
delay (100); delay(100);
} }
LEDControl.set_all_leds_to (0, 0, 0); LEDControl.set_all_leds_to(0, 0, 0);
return MACRO_NONE; return MACRO_NONE;
} }
void setup () { void setup() {
Kaleidoscope.setup (); Kaleidoscope.setup();
USE_PLUGINS (&AlphaSquare, &AlphaSquareEffect, &Macros); USE_PLUGINS(&AlphaSquare, &AlphaSquareEffect, &Macros);
AlphaSquare.color = { 0xcb, 0xc0, 0xff }; AlphaSquare.color = { 0xcb, 0xc0, 0xff };
} }
void loop () { void loop() {
Kaleidoscope.loop (); Kaleidoscope.loop();
} }

@ -25,31 +25,31 @@ uint32_t AlphaSquareEffect::endTimeLeft, AlphaSquareEffect::endTimeRight;
Key AlphaSquareEffect::lastKeyLeft, AlphaSquareEffect::lastKeyRight; Key AlphaSquareEffect::lastKeyLeft, AlphaSquareEffect::lastKeyRight;
uint8_t AlphaSquareEffect::us; uint8_t AlphaSquareEffect::us;
AlphaSquareEffect::AlphaSquareEffect (void) { AlphaSquareEffect::AlphaSquareEffect(void) {
} }
void void
AlphaSquareEffect::begin (void) { AlphaSquareEffect::begin(void) {
Kaleidoscope.useEventHandlerHook (eventHandlerHook); Kaleidoscope.useEventHandlerHook(eventHandlerHook);
Kaleidoscope.use (&LEDControl, NULL); Kaleidoscope.use(&LEDControl, NULL);
us = LEDControl.mode_add (this); us = LEDControl.mode_add(this);
} }
void void
AlphaSquareEffect::update (void) { AlphaSquareEffect::update(void) {
if (endTimeLeft && millis () > endTimeLeft) { if (endTimeLeft && millis() > endTimeLeft) {
::AlphaSquare.clear (lastKeyLeft); ::AlphaSquare.clear(lastKeyLeft);
endTimeLeft = 0; endTimeLeft = 0;
} }
if (endTimeRight && millis () > endTimeRight) { if (endTimeRight && millis() > endTimeRight) {
::AlphaSquare.clear (lastKeyRight, 10); ::AlphaSquare.clear(lastKeyRight, 10);
endTimeRight = 0; endTimeRight = 0;
} }
} }
Key Key
AlphaSquareEffect::eventHandlerHook (Key key, byte row, byte col, uint8_t keyState) { AlphaSquareEffect::eventHandlerHook(Key key, byte row, byte col, uint8_t keyState) {
if (LEDControl.get_mode () != us) if (LEDControl.get_mode() != us)
return key; return key;
if (keyState & INJECTED) if (keyState & INJECTED)
@ -58,7 +58,7 @@ AlphaSquareEffect::eventHandlerHook (Key key, byte row, byte col, uint8_t keySta
if (key < Key_A || key > Key_0) if (key < Key_A || key > Key_0)
return key; return key;
if (!key_is_pressed (keyState)) if (!key_is_pressed(keyState))
return key; return key;
uint8_t displayCol = 2; uint8_t displayCol = 2;
@ -66,17 +66,17 @@ AlphaSquareEffect::eventHandlerHook (Key key, byte row, byte col, uint8_t keySta
if (col < COLS / 2) { if (col < COLS / 2) {
lastKeyLeft = key; lastKeyLeft = key;
endTimeLeft = millis () + length; endTimeLeft = millis() + length;
} else { } else {
prevKey = lastKeyRight; prevKey = lastKeyRight;
lastKeyRight = key; lastKeyRight = key;
endTimeRight = millis () + length; endTimeRight = millis() + length;
displayCol = 10; displayCol = 10;
} }
if (prevKey != key) if (prevKey != key)
::AlphaSquare.clear (prevKey, displayCol); ::AlphaSquare.clear(prevKey, displayCol);
::AlphaSquare.display (key, displayCol); ::AlphaSquare.display(key, displayCol);
return key; return key;
} }
}; };

@ -25,10 +25,10 @@ namespace KaleidoscopePlugins {
namespace LEDEffects { namespace LEDEffects {
class AlphaSquareEffect : public LEDMode { class AlphaSquareEffect : public LEDMode {
public: public:
AlphaSquareEffect (void); AlphaSquareEffect(void);
virtual void begin (void) final; virtual void begin(void) final;
virtual void update (void) final; virtual void update(void) final;
static uint16_t length; static uint16_t length;
private: private:
@ -36,7 +36,7 @@ class AlphaSquareEffect : public LEDMode {
static Key lastKeyLeft, lastKeyRight; static Key lastKeyLeft, lastKeyRight;
static uint8_t us; static uint8_t us;
static Key eventHandlerHook (Key key, uint8_t row, uint8_t col, uint8_t keyState); static Key eventHandlerHook(Key key, uint8_t row, uint8_t col, uint8_t keyState);
}; };
}; };
}; };

@ -170,47 +170,47 @@ static const uint16_t alphabet[] PROGMEM = {
cRGB AlphaSquare::color = {0x80, 0x80, 0x80}; cRGB AlphaSquare::color = {0x80, 0x80, 0x80};
AlphaSquare::AlphaSquare (void) { AlphaSquare::AlphaSquare(void) {
} }
void void
AlphaSquare::begin (void) { AlphaSquare::begin(void) {
} }
void void
AlphaSquare::display (Key key, uint8_t row, uint8_t col, cRGB keyColor) { AlphaSquare::display(Key key, uint8_t row, uint8_t col, cRGB keyColor) {
if (key < Key_A || key > Key_0) if (key < Key_A || key > Key_0)
return; return;
uint8_t index = key.keyCode - Key_A.keyCode; uint8_t index = key.keyCode - Key_A.keyCode;
uint16_t symbol = pgm_read_word (&alphabet[index]); uint16_t symbol = pgm_read_word(&alphabet[index]);
display (symbol, row, col, keyColor); display(symbol, row, col, keyColor);
} }
void void
AlphaSquare::display (Key key, uint8_t row, uint8_t col) { AlphaSquare::display(Key key, uint8_t row, uint8_t col) {
display (key, row, col, color); display(key, row, col, color);
} }
void void
AlphaSquare::display (uint16_t symbol, uint8_t row, uint8_t col, cRGB keyColor) { AlphaSquare::display(uint16_t symbol, uint8_t row, uint8_t col, cRGB keyColor) {
for (uint8_t r = 0; r < 4; r++) { for (uint8_t r = 0; r < 4; r++) {
for (uint8_t c = 0; c < 4; c++) { for (uint8_t c = 0; c < 4; c++) {
uint8_t pixel = bitRead (symbol, r * 4 + c); uint8_t pixel = bitRead(symbol, r * 4 + c);
if (!pixel) if (!pixel)
continue; continue;
LEDControl.led_set_crgb_at (row + r, col + c, keyColor); LEDControl.led_set_crgb_at(row + r, col + c, keyColor);
} }
} }
LEDControl.led_sync (); LEDControl.led_sync();
} }
void void
AlphaSquare::display (uint16_t symbol, uint8_t row, uint8_t col) { AlphaSquare::display(uint16_t symbol, uint8_t row, uint8_t col) {
display (symbol, row, col, color); display(symbol, row, col, color);
} }
}; };

@ -37,46 +37,46 @@
namespace KaleidoscopePlugins { namespace KaleidoscopePlugins {
class AlphaSquare : public KaleidoscopePlugin { class AlphaSquare : public KaleidoscopePlugin {
public: public:
AlphaSquare (void); AlphaSquare(void);
virtual void begin (void) final; virtual void begin(void) final;
static void display (Key key, uint8_t row, uint8_t col, cRGB keyColor); static void display(Key key, uint8_t row, uint8_t col, cRGB keyColor);
static void display (Key key, uint8_t row, uint8_t col); static void display(Key key, uint8_t row, uint8_t col);
static void display (Key key) { static void display(Key key) {
display (key, 0, 2); display(key, 0, 2);
}; };
static void display (Key key, uint8_t col) { static void display(Key key, uint8_t col) {
display (key, 0, col); display(key, 0, col);
}; };
static void display (uint16_t symbol, uint8_t row, uint8_t col, cRGB keyColor); static void display(uint16_t symbol, uint8_t row, uint8_t col, cRGB keyColor);
static void display (uint16_t symbol, uint8_t row, uint8_t col); static void display(uint16_t symbol, uint8_t row, uint8_t col);
static void display (uint16_t symbol) { static void display(uint16_t symbol) {
display (symbol, 0, 2); display(symbol, 0, 2);
}; };
static void display (uint16_t symbol, uint8_t col) { static void display(uint16_t symbol, uint8_t col) {
display (symbol, 0, col); display(symbol, 0, col);
}; };
static void clear (Key key, uint8_t row, uint8_t col) { static void clear(Key key, uint8_t row, uint8_t col) {
display (key, row, col, {0, 0, 0}); display(key, row, col, {0, 0, 0});
}; };
static void clear (Key key, uint8_t col) { static void clear(Key key, uint8_t col) {
clear (key, 0, col); clear(key, 0, col);
}; };
static void clear (Key key) { static void clear(Key key) {
clear (key, 0, 2); clear(key, 0, 2);
}; };
static void clear (uint16_t symbol, uint8_t row, uint8_t col) { static void clear(uint16_t symbol, uint8_t row, uint8_t col) {
display (symbol, row, col, {0, 0, 0}); display(symbol, row, col, {0, 0, 0});
}; };
static void clear (uint16_t symbol, uint8_t col) { static void clear(uint16_t symbol, uint8_t col) {
clear (symbol, 0, col); clear(symbol, 0, col);
}; };
static void clear (uint16_t symbol) { static void clear(uint16_t symbol) {
clear (symbol, 0, 2); clear(symbol, 0, 2);
}; };
static cRGB color; static cRGB color;

Loading…
Cancel
Save