-
Notifications
You must be signed in to change notification settings - Fork 0
/
Display.cpp
50 lines (38 loc) · 1.1 KB
/
Display.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
#include "Matrix.h"
#include "Display.h"
Adafruit_PCD8544 Display::controller = Adafruit_PCD8544(PIN_CLK, PIN_DIN, PIN_DC, PIN_CE, PIN_RST);
void Display::Initialize() {
// initialize controller
Display::controller.begin();
// set contrast
Display::controller.setContrast(60);
// clears the screen and buffer
Display::controller.clearDisplay();
}
void Display::UpdateFromDisplay() {
Display::controller.display();
}
void Display::UpdateFromMatrix() {
FOR_i {
FOR_j {
FOR_k {
PIXEL_MAP_ijk(i, j, k);
}
}
}
Display::UpdateFromDisplay();
}
void Display::Set(uint8_t x, uint8_t y) {
Display::controller.drawPixel(x, y, BLACK);
}
void Display::Unset(uint8_t x, uint8_t y) {
Display::controller.drawPixel(x, y, WHITE);
}
void Display::DrawLine(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t x2, uint8_t color) {
Display::controller.drawLine(x0, y0, x1, x2, color);
};
void Display::DrawText(uint8_t x, uint8_t y, String &text) {
Display::controller.setCursor(x, y);
Display::controller.setTextColor(WHITE, BLACK);
Display::controller.print(text);
};