-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisplay.cpp
More file actions
92 lines (61 loc) · 1.54 KB
/
Display.cpp
File metadata and controls
92 lines (61 loc) · 1.54 KB
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
#include "Display.h"
/* PCD8544 controller */
Adafruit_PCD8544 Display::controller = Adafruit_PCD8544(PIN_CLK, PIN_DIN, PIN_DC, PIN_CE, PIN_RST);
void Display::Initialize() {
// initialize controller
controller.begin();
// set contrast
controller.setContrast(50);
// clears the screen
Clear();
}
void Display::Clear() {
controller.clearDisplay();
controller.display();
}
void Display::Update() {
controller.display();
}
void Display::PixelOn(uint8_t x, uint8_t y) {
controller.drawPixel(x, y, BLACK);
}
void Display::PixelOff(uint8_t x, uint8_t y) {
controller.drawPixel(x, y, WHITE);
}
uint8_t Display::GetPixel(uint8_t x, uint8_t y) {
return controller.getPixel(x, y);
}
void Display::DrawLine(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t x2, uint8_t color) {
controller.drawLine(x0, y0, x1, x2, color);
};
void Display::DrawText(uint8_t x, uint8_t y, const __FlashStringHelper * text) {
controller.setCursor(x, y);
controller.setTextColor(WHITE, BLACK);
controller.print(text);
};
void Display::DrawText(uint8_t x, uint8_t y, char * text) {
controller.setCursor(x, y);
controller.setTextColor(WHITE, BLACK);
controller.print(text);
};
void Display::HorizontalSwipe() {
FOR_x {
DrawLine(x, 0, x, LCD_HEIGHT - 1, BLACK);
Update();
delay(10);
}
}
void Display::VerticalSwipe() {
FOR_y {
DrawLine(0, y, LCD_WIDTH - 1, y, BLACK);
Update();
delay(10);
}
}
void Display::RandomSwipe() {
if (random(256) < 128) {
HorizontalSwipe();
} else {
VerticalSwipe();
}
}