-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPanel.cpp
71 lines (62 loc) · 1.59 KB
/
Panel.cpp
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "Panel.h"
#include "TM1637Display.h"
const uint8_t SEG_ERR[] = {
SEG_A | SEG_F | SEG_G | SEG_E | SEG_D, // E
SEG_G | SEG_E, // r
SEG_G | SEG_E, // r
0,
};
const uint8_t SEG_SG[] = {
0,
SEG_A | SEG_F | SEG_E | SEG_D, // С
SEG_A | SEG_F | SEG_E, // Г
0,
};
const uint8_t SEG_BR[] = {
0,
SEG_A | SEG_F | SEG_E | SEG_D | SEG_C | SEG_G, // Б
SEG_G | SEG_B | SEG_A | SEG_F | SEG_E, // Р
0,
};
Panel::Panel(uint8_t pinCLK, uint8_t pinDIO) : _tm(pinCLK, pinDIO, 100) {
_pinCLK = pinCLK;
_pinDIO = pinDIO;
}
void Panel::setup(uint8_t mode) {
_tm.setBrightness(PANEL_BRIGHTNESS);
_tm.clear();
if (mode == MODE_BR) {
_tm.setSegments(SEG_BR);
delay(PANEL_SPLASH_DURATION);
} else {
_tm.setSegments(SEG_SG);
delay(PANEL_SPLASH_DURATION);
_tm.clear();
}
}
void Panel::displayTime(uint32_t time, bool display_cs) {
Serial.print("T=");
Serial.print(time);
Serial.print(", ");
if (display_cs) {
uint32_t time_cs = time / 10; // milliseconds to centiseconds
Serial.println(time_cs);
_tm.showNumberDecEx(time_cs, 0b01000000, true);
} else {
uint32_t time_cs = time / 1000; // milliseconds to centiseconds
Serial.println(time_cs);
_tm.showNumberDecEx(time_cs, 0, true, 2, 1);
}
}
void Panel::displayFalseStart() {
_tm.clear();
_tm.showNumberHexEx(0xFA, 0, false, 2, 1);
}
void Panel::off() {
_tm.clear();
}
void Panel::error(uint8_t number) {
_tm.clear();
_tm.setSegments(SEG_ERR);
_tm.showNumberDec(number, false, 1, 3);
}