-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDigit.h
125 lines (118 loc) · 4.3 KB
/
Digit.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#ifndef FOURTEENSEGMENT_DIGIT_H
#define FOURTEENSEGMENT_DIGIT_H
#include <Arduino.h>
class Digit {
public:
explicit Digit(uint8_t cathode, const uint8_t* segments);
void hide() const;
void show() const;
void drawSegment(uint8_t segment);
void eraseSegment(uint8_t segment);
void drawChar(char c);
private:
uint8_t cathode;
uint8_t anodes [15];
// Maps most ASCII values to a bitmask of the segments that should be lit.
// It starts at 0, however, while the ASCII values start at 32, so you need to subtract 32 from the ASCII value of each character.
// This is taken with minimal modifications from https://github.com/dmadison/LED-Segment-ASCII. All credit goes to them.
const uint16_t charMap[96] = {
0b000000000000000, // (space)
0b100000000000110, // !
0b000001000000010, // "
0b001001011001110, // #
0b001001011101101, // $
0b011111111100100, // %
0b010001101011001, // &
0b000001000000000, // '
0b010010000000000, // (
0b000100100000000, // )
0b011111111000000, // *
0b001001011000000, // +
0b000100000000000, // ,
0b000000011000000, // -
0b100000000000000, // .
0b000110000000000, // /
0b000110000111111, // 0
0b000010000000110, // 1
0b000000011011011, // 2
0b000000010001111, // 3
0b000000011100110, // 4
0b010000001101001, // 5
0b000000011111101, // 6
0b000000000000111, // 7
0b000000011111111, // 8
0b000000011101111, // 9
0b001001000000000, // :
0b000101000000000, // ;
0b010010001000000, // <
0b000000011001000, // =
0b000100110000000, // >
0b101000010000011, // ?
0b000001010111011, // @
0b000000011110111, // A
0b001001010001111, // B
0b000000000111001, // C
0b001001000001111, // D
0b000000001111001, // E
0b000000001110001, // F
0b000000010111101, // G
0b000000011110110, // H
0b001001000001001, // I
0b000000000011110, // J
0b010010001110000, // K
0b000000000111000, // L
0b000010100110110, // M
0b010000100110110, // N
0b000000000111111, // O
0b000000011110011, // P
0b010000000111111, // Q
0b010000011110011, // R
0b000000011101101, // S
0b001001000000001, // T
0b000000000111110, // U
0b000110000110000, // V
0b010100000110110, // W
0b010110100000000, // X
0b000000011101110, // Y
0b000110000001001, // Z
0b000000000111001, // [
0b010000100000000, // backslash
0b000000000001111, // ]
0b010100000000000, // ^
0b000000000001000, // _
0b000000100000000, // `
0b001000001011000, // a
0b010000001111000, // b
0b000000011011000, // c
0b000100010001110, // d
0b000100001011000, // e
0b001010011000000, // f
0b000010010001110, // g
0b001000001110000, // h
0b001000000000000, // i
0b000101000010000, // j
0b011011000000000, // k
0b000000000110000, // l
0b001000011010100, // m
0b001000001010000, // n
0b000000011011100, // o
0b000000101110000, // p
0b000010010000110, // q
0b000000001010000, // r
0b010000010001000, // s
0b000000001111000, // t
0b000000000011100, // u
0b000100000010000, // v
0b010100000010100, // w
0b010110100000000, // x
0b000001010001110, // y
0b000100001001000, // z
0b000100101001001, // {
0b001001000000000, // |
0b010010010001001, // }
0b000110011000000, // ~
0b000000000000000, // (del)
};
uint16_t getCharDef(char c);
};
#endif //FOURTEENSEGMENT_DIGIT_H