astyle with current project style guidelines

pull/365/head
Jesse Vincent 8 years ago
parent 63835fa1bd
commit 89c79ef6fe
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -17,9 +17,9 @@ type_letter(uint8_t letter) {
#endif #endif
void void
bootAnimation (void) { bootAnimation(void) {
#ifdef ARDUINO_AVR_MODEL01 #ifdef ARDUINO_AVR_MODEL01
if (EEPROM.read (EEPROM_BOOT_ANIMATION_LOCATION)) if (EEPROM.read(EEPROM_BOOT_ANIMATION_LOCATION))
return; return;
LEDControl.set_all_leds_to(0, 0, 0); LEDControl.set_all_leds_to(0, 0, 0);
@ -38,6 +38,6 @@ bootAnimation (void) {
type_letter(LED_PERIOD); type_letter(LED_PERIOD);
type_letter(LED_9); type_letter(LED_9);
EEPROM.update (EEPROM_BOOT_ANIMATION_LOCATION, 1); EEPROM.update(EEPROM_BOOT_ANIMATION_LOCATION, 1);
#endif #endif
} }

@ -7,8 +7,8 @@ uint16_t LEDControl_::syncDelay = 16;
uint32_t LEDControl_::syncTimer; uint32_t LEDControl_::syncTimer;
void void
LEDMode::activate (void) { LEDMode::activate(void) {
LEDControl.activate (this); LEDControl.activate(this);
} }
void void
@ -19,11 +19,11 @@ LEDMode::begin(void) {
LEDControl_::LEDControl_(void) { LEDControl_::LEDControl_(void) {
mode = previousMode = 0; mode = previousMode = 0;
memset (modes, 0, LED_MAX_MODES * sizeof (modes[0])); memset(modes, 0, LED_MAX_MODES * sizeof(modes[0]));
} }
void void
LEDControl_::next_mode (void) { LEDControl_::next_mode(void) {
mode++; mode++;
if (mode >= LED_MAX_MODES) { if (mode >= LED_MAX_MODES) {
@ -38,32 +38,32 @@ LEDControl_::next_mode (void) {
} }
void void
LEDControl_::update (void) { LEDControl_::update(void) {
if (previousMode != mode) { if (previousMode != mode) {
set_all_leds_to ({0, 0, 0}); set_all_leds_to({0, 0, 0});
if (modes[mode]) if (modes[mode])
(modes[mode]->init) (); (modes[mode]->init)();
} }
if (modes[mode]) if (modes[mode])
(modes[mode]->update) (); (modes[mode]->update)();
previousMode = mode; previousMode = mode;
} }
void void
LEDControl_::set_mode (uint8_t mode_) { LEDControl_::set_mode(uint8_t mode_) {
if (mode_ < LED_MAX_MODES) if (mode_ < LED_MAX_MODES)
mode = mode_; mode = mode_;
} }
uint8_t uint8_t
LEDControl_::get_mode (void) { LEDControl_::get_mode(void) {
return mode; return mode;
} }
void void
LEDControl_::activate (LEDMode *mode) { LEDControl_::activate(LEDMode *mode) {
for (uint8_t i = 0; i < LED_MAX_MODES; i++) { for (uint8_t i = 0; i < LED_MAX_MODES; i++) {
if (modes[i] == mode) if (modes[i] == mode)
return set_mode(i); return set_mode(i);
@ -71,7 +71,7 @@ LEDControl_::activate (LEDMode *mode) {
} }
int8_t int8_t
LEDControl_::mode_add (LEDMode *mode) { LEDControl_::mode_add(LEDMode *mode) {
for (int i = 0; i < LED_MAX_MODES; i++) { for (int i = 0; i < LED_MAX_MODES; i++) {
if (modes[i]) if (modes[i])
continue; continue;
@ -119,8 +119,8 @@ LEDControl_::led_sync(void) {
} }
void void
LEDControl_::begin (void) { LEDControl_::begin(void) {
set_all_leds_to ({0, 0, 0}); set_all_leds_to({0, 0, 0});
for (uint8_t i = 0; i < LED_MAX_MODES; i++) { for (uint8_t i = 0; i < LED_MAX_MODES; i++) {
if (modes[i]) if (modes[i])
@ -134,7 +134,7 @@ LEDControl_::begin (void) {
} }
Key Key
LEDControl_::eventHandler (Key mappedKey, byte row, byte col, uint8_t keyState) { LEDControl_::eventHandler(Key mappedKey, byte row, byte col, uint8_t keyState) {
if (mappedKey.flags != (SYNTHETIC | IS_INTERNAL | LED_TOGGLE)) if (mappedKey.flags != (SYNTHETIC | IS_INTERNAL | LED_TOGGLE))
return mappedKey; return mappedKey;
@ -145,7 +145,7 @@ LEDControl_::eventHandler (Key mappedKey, byte row, byte col, uint8_t keyState)
} }
void void
LEDControl_::loopHook (bool postClear) { LEDControl_::loopHook(bool postClear) {
if (postClear) if (postClear)
return; return;
@ -157,7 +157,7 @@ LEDControl_::loopHook (bool postClear) {
} }
bool bool
LEDControl_::focusHook (const char *command) { LEDControl_::focusHook(const char *command) {
enum { enum {
SETALL, SETALL,
MODE, MODE,
@ -165,80 +165,76 @@ LEDControl_::focusHook (const char *command) {
THEME, THEME,
} subCommand; } subCommand;
if (strncmp_P (command, PSTR ("led."), 4) != 0) if (strncmp_P(command, PSTR("led."), 4) != 0)
return false; return false;
if (strcmp_P (command + 4, PSTR ("at")) == 0) if (strcmp_P(command + 4, PSTR("at")) == 0)
subCommand = AT; subCommand = AT;
else if (strcmp_P (command + 4, PSTR ("setAll")) == 0) else if (strcmp_P(command + 4, PSTR("setAll")) == 0)
subCommand = SETALL; subCommand = SETALL;
else if (strcmp_P (command + 4, PSTR ("mode")) == 0) else if (strcmp_P(command + 4, PSTR("mode")) == 0)
subCommand = MODE; subCommand = MODE;
else if (strcmp_P (command + 4, PSTR ("theme")) == 0) else if (strcmp_P(command + 4, PSTR("theme")) == 0)
subCommand = THEME; subCommand = THEME;
else else
return false; return false;
switch (subCommand) { switch (subCommand) {
case AT: case AT: {
{ uint8_t idx = Serial.parseInt();
uint8_t idx = Serial.parseInt ();
if (Serial.peek () == '\n') { if (Serial.peek() == '\n') {
cRGB c = LEDControl.led_get_crgb_at (idx); cRGB c = LEDControl.led_get_crgb_at(idx);
Focus.printColor (c.r, c.g, c.b); Focus.printColor(c.r, c.g, c.b);
Serial.println (); Serial.println();
} else { } else {
cRGB c; cRGB c;
c.r = Serial.parseInt (); c.r = Serial.parseInt();
c.g = Serial.parseInt (); c.g = Serial.parseInt();
c.b = Serial.parseInt (); c.b = Serial.parseInt();
LEDControl.led_set_crgb_at (idx, c); LEDControl.led_set_crgb_at(idx, c);
} }
break; break;
} }
case SETALL: case SETALL: {
{
cRGB c; cRGB c;
c.r = Serial.parseInt (); c.r = Serial.parseInt();
c.g = Serial.parseInt (); c.g = Serial.parseInt();
c.b = Serial.parseInt (); c.b = Serial.parseInt();
LEDControl.set_all_leds_to (c); LEDControl.set_all_leds_to(c);
break; break;
} }
case MODE: case MODE: {
{ char peek = Serial.peek();
char peek = Serial.peek ();
if (peek == '\n') { if (peek == '\n') {
Serial.println (LEDControl.get_mode ()); Serial.println(LEDControl.get_mode());
} else if (peek == 'n') { } else if (peek == 'n') {
LEDControl.next_mode (); LEDControl.next_mode();
Serial.read (); Serial.read();
} else if (peek == 'p') { } else if (peek == 'p') {
// TODO // TODO
Serial.read (); Serial.read();
} else { } else {
uint8_t mode = Serial.parseInt (); uint8_t mode = Serial.parseInt();
LEDControl.set_mode (mode); LEDControl.set_mode(mode);
} }
break; break;
} }
case THEME: case THEME: {
{ if (Serial.peek() == '\n') {
if (Serial.peek () == '\n') {
for (uint8_t idx = 0; idx < LED_COUNT; idx++) { for (uint8_t idx = 0; idx < LED_COUNT; idx++) {
cRGB c = LEDControl.led_get_crgb_at (idx); cRGB c = LEDControl.led_get_crgb_at(idx);
Focus.printColor (c.r, c.g, c.b); Focus.printColor(c.r, c.g, c.b);
Focus.printSpace (); Focus.printSpace();
} }
Serial.println (); Serial.println();
break; break;
} }
@ -246,11 +242,11 @@ LEDControl_::focusHook (const char *command) {
while (idx < LED_COUNT && Serial.peek() != '\n') { while (idx < LED_COUNT && 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();
LEDControl.led_set_crgb_at (idx, color); LEDControl.led_set_crgb_at(idx, color);
idx++; idx++;
} }
break; break;

@ -10,11 +10,11 @@
class LEDMode : public KaleidoscopePlugin { class LEDMode : public KaleidoscopePlugin {
public: public:
virtual void begin (void); virtual void begin(void);
virtual void setup (void) {}; virtual void setup(void) {};
virtual void init (void) {}; virtual void init(void) {};
virtual void update (void) {}; virtual void update(void) {};
virtual void activate (void); virtual void activate(void);
}; };
class LEDControl_ : public KaleidoscopePlugin { class LEDControl_ : public KaleidoscopePlugin {
@ -29,7 +29,7 @@ class LEDControl_ : public KaleidoscopePlugin {
static void set_mode(uint8_t mode); static void set_mode(uint8_t mode);
static uint8_t get_mode(); static uint8_t get_mode();
static int8_t mode_add (LEDMode *mode); static int8_t mode_add(LEDMode *mode);
static void led_set_crgb_at(uint8_t i, cRGB crgb); static void led_set_crgb_at(uint8_t i, cRGB crgb);
static void led_set_crgb_at(byte row, byte col, cRGB color); static void led_set_crgb_at(byte row, byte col, cRGB color);
@ -39,11 +39,11 @@ class LEDControl_ : public KaleidoscopePlugin {
static void set_all_leds_to(uint8_t r, uint8_t g, uint8_t b); static void set_all_leds_to(uint8_t r, uint8_t g, uint8_t b);
static void set_all_leds_to(cRGB color); static void set_all_leds_to(cRGB color);
static void activate (LEDMode *mode); static void activate(LEDMode *mode);
static uint16_t syncDelay; static uint16_t syncDelay;
static bool focusHook (const char *command); static bool focusHook(const char *command);
private: private:
static uint32_t syncTimer; static uint32_t syncTimer;
@ -51,7 +51,7 @@ class LEDControl_ : public KaleidoscopePlugin {
static uint8_t previousMode, mode; static uint8_t previousMode, mode;
static Key eventHandler(Key mappedKey, byte row, byte col, uint8_t keyState); static Key eventHandler(Key mappedKey, byte row, byte col, uint8_t keyState);
static void loopHook (bool postClear); static void loopHook(bool postClear);
}; };
extern LEDControl_ LEDControl; extern LEDControl_ LEDControl;

@ -1,7 +1,7 @@
#include "LED-Off.h" #include "LED-Off.h"
void LEDOff_::update (void) { void LEDOff_::update(void) {
LEDControl.set_all_leds_to ({0, 0, 0}); LEDControl.set_all_leds_to({0, 0, 0});
} }
LEDOff_ LEDOff; LEDOff_ LEDOff;

@ -4,9 +4,9 @@
class LEDOff_ : public LEDMode { class LEDOff_ : public LEDMode {
public: public:
LEDOff_ (void) { }; LEDOff_(void) { };
virtual void update (void) final; virtual void update(void) final;
}; };
extern LEDOff_ LEDOff; extern LEDOff_ LEDOff;

@ -1,14 +1,14 @@
#include "LEDUtils.h" #include "LEDUtils.h"
cRGB cRGB
breath_compute () { breath_compute() {
// This code is adapted from FastLED lib8tion.h as of dd5d96c6b289cb6b4b891748a4aeef3ddceaf0e6 // This code is adapted from FastLED lib8tion.h as of dd5d96c6b289cb6b4b891748a4aeef3ddceaf0e6
// Eventually, we should consider just using FastLED // Eventually, we should consider just using FastLED
uint8_t i = (uint16_t)millis()/12; uint8_t i = (uint16_t)millis()/12;
if( i & 0x80) { if (i & 0x80) {
i = 255 - i; i = 255 - i;
} }
@ -16,7 +16,7 @@ breath_compute () {
uint8_t ii = (i*i)>>8; uint8_t ii = (i*i)>>8;
uint8_t iii = (ii*i)>>8; uint8_t iii = (ii*i)>>8;
i = (( (3 * (uint16_t)(ii)) - ( 2 * (uint16_t)(iii))) / 2) + 2; i = (((3 * (uint16_t)(ii)) - (2 * (uint16_t)(iii))) / 2) + 2;
return hsv_to_rgb(200, 255, i); return hsv_to_rgb(200, 255, i);
} }
@ -32,7 +32,7 @@ hsv_to_rgb(uint16_t h, uint16_t s, uint16_t v) {
* math */ * math */
uint16_t region, fpart, p, q, t; uint16_t region, fpart, p, q, t;
if(s == 0) { if (s == 0) {
/* color is grayscale */ /* color is grayscale */
color.r = color.g = color.b = v; color.r = color.g = color.b = v;
return color; return color;
@ -49,7 +49,7 @@ hsv_to_rgb(uint16_t h, uint16_t s, uint16_t v) {
t = (v * (255 - ((s * (255 - fpart)) >> 8))) >> 8; t = (v * (255 - ((s * (255 - fpart)) >> 8))) >> 8;
/* assign temp vars based on color cone region */ /* assign temp vars based on color cone region */
switch(region) { switch (region) {
case 0: case 0:
color.r = v; color.r = v;
color.g = t; color.g = t;

@ -2,5 +2,5 @@
#include <Kaleidoscope.h> #include <Kaleidoscope.h>
cRGB breath_compute (void); cRGB breath_compute(void);
cRGB hsv_to_rgb(uint16_t h, uint16_t s, uint16_t v); cRGB hsv_to_rgb(uint16_t h, uint16_t s, uint16_t v);

Loading…
Cancel
Save