-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdebug.h
56 lines (45 loc) · 1.36 KB
/
debug.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
class DebugController {
public:
PatternController *controller;
LEDs *strip;
Radio *radio;
uint32_t lastPhraseTime;
uint32_t lastFrame;
DebugController(PatternController *controller) {
this->controller = controller;
this->strip = controller->led_strip;
this->radio = controller->radio;
}
void setup()
{
this->lastPhraseTime = globalTimer.now_micros;
this->lastFrame = (uint32_t)-1;
}
void update()
{
EVERY_N_MILLISECONDS( 10000 ) {
Serial.print(F("Free memory: "));
Serial.println( freeMemory() );
}
// Show the beat on the master OR if debugging
if (this->controller->options.debugging) {
uint8_t p1 = (this->controller->current_state.beat_frame >> 8) % 16;
this->strip->leds[p1] = CRGB::White;
uint8_t p2 = scale8(this->controller->radio->tubeId, this->strip->num_leds-1);
this->strip->leds[p2] = CRGB::White;
uint8_t p3 = scale8(this->controller->radio->masterTubeId, this->strip->num_leds-1);
if (p3 == p2) {
this->strip->leds[p3] = CRGB::Green;
} else {
this->strip->leds[p3] = CRGB::Yellow;
}
if (this->radio->radioRestarts) {
this->strip->leds[1] = CRGB::Red;
}
}
if (this->radio->radioFailures && !this->radio->radioRestarts) {
this->strip->leds[0] = CRGB::Red;
}
}
};