astyle with current project style guidelines

pull/389/head
Jesse Vincent 8 years ago
parent 0489fd9196
commit 17487f9c26
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -41,13 +41,13 @@ const Key keymaps[][ROWS][COLS] PROGMEM = {
), ),
}; };
void setup () { void setup() {
Kaleidoscope.setup (KEYMAP_SIZE); Kaleidoscope.setup(KEYMAP_SIZE);
Kaleidoscope.use (&LEDControl, &HeatmapEffect, NULL); Kaleidoscope.use(&LEDControl, &HeatmapEffect, NULL);
HeatmapEffect.activate (); HeatmapEffect.activate();
} }
void loop () { void loop() {
Kaleidoscope.loop (); Kaleidoscope.loop();
} }

@ -29,7 +29,7 @@ uint32_t Heatmap::endTime;
const float Heatmap::heatColors[][3] = {{0.0, 0.0, 0.0}, {0.1, 1, 0.1}, {1, 1, 0.1}, {1, 0.1, 0.1}}; const float Heatmap::heatColors[][3] = {{0.0, 0.0, 0.0}, {0.1, 1, 0.1}, {1, 1, 0.1}, {1, 0.1, 0.1}};
void void
Heatmap::shiftStats (void) { Heatmap::shiftStats(void) {
highestCount = totalKeys = 0; highestCount = totalKeys = 0;
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++) {
@ -42,7 +42,7 @@ Heatmap::shiftStats (void) {
} }
cRGB cRGB
Heatmap::computeColor (float v) { Heatmap::computeColor(float v) {
float fb = 0; float fb = 0;
uint8_t idx1, idx2; uint8_t idx1, idx2;
@ -64,24 +64,24 @@ Heatmap::computeColor (float v) {
return {b, g, r}; return {b, g, r};
} }
Heatmap::Heatmap (void) { Heatmap::Heatmap(void) {
} }
void void
Heatmap::begin (void) { Heatmap::begin(void) {
LEDControl.mode_add (this); LEDControl.mode_add(this);
event_handler_hook_use (this->eventHook); event_handler_hook_use(this->eventHook);
loop_hook_use (this->loopHook); loop_hook_use(this->loopHook);
} }
Key Key
Heatmap::eventHook (Key mappedKey, byte row, byte col, uint8_t keyState) { Heatmap::eventHook(Key mappedKey, byte row, byte col, uint8_t keyState) {
// if it is a synthetic key, skip it. // if it is a synthetic key, skip it.
if (keyState & INJECTED) if (keyState & INJECTED)
return mappedKey; return mappedKey;
// if the key is not toggled on, return. // if the key is not toggled on, return.
if (!key_toggled_on (keyState)) if (!key_toggled_on(keyState))
return mappedKey; return mappedKey;
totalKeys++; totalKeys++;
@ -93,23 +93,23 @@ Heatmap::eventHook (Key mappedKey, byte row, byte col, uint8_t keyState) {
} }
void void
Heatmap::loopHook (bool postClear) { Heatmap::loopHook(bool postClear) {
if (highestCount > 191 || totalKeys > 16000) if (highestCount > 191 || totalKeys > 16000)
shiftStats(); shiftStats();
} }
void void
Heatmap::update (void) { Heatmap::update(void) {
if (endTime && (millis () > endTime)) if (endTime && (millis() > endTime))
return; return;
endTime = millis () + updateDelay; endTime = millis() + updateDelay;
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++) {
uint8_t cap = max(totalKeys, 1); uint8_t cap = max(totalKeys, 1);
float v = float(heatmap[r][c]) / cap; float v = float(heatmap[r][c]) / cap;
LEDControl.led_set_crgb_at (r, c, computeColor (v)); LEDControl.led_set_crgb_at(r, c, computeColor(v));
} }
} }
} }

@ -24,13 +24,13 @@
namespace KaleidoscopePlugins { namespace KaleidoscopePlugins {
class Heatmap : public LEDMode { class Heatmap : public LEDMode {
public: public:
Heatmap (void); Heatmap(void);
virtual void begin (void) final; virtual void begin(void) final;
static uint16_t updateDelay; static uint16_t updateDelay;
virtual void update (void) final; virtual void update(void) final;
private: private:
static uint8_t heatmap[ROWS][COLS]; static uint8_t heatmap[ROWS][COLS];
static uint16_t totalKeys; static uint16_t totalKeys;
@ -39,11 +39,11 @@ class Heatmap : public LEDMode {
static const float heatColors[][3]; static const float heatColors[][3];
static void shiftStats (void); static void shiftStats(void);
static cRGB computeColor (float v); static cRGB computeColor(float v);
static Key eventHook (Key mappedKey, byte row, byte col, uint8_t keyState); static Key eventHook(Key mappedKey, byte row, byte col, uint8_t keyState);
static void loopHook (bool postClear); static void loopHook(bool postClear);
}; };
}; };

Loading…
Cancel
Save