-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClockController.cpp
More file actions
47 lines (32 loc) · 804 Bytes
/
ClockController.cpp
File metadata and controls
47 lines (32 loc) · 804 Bytes
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
#include "ClockController.h"
ClockController::ClockController(U8G2 _dsp)
{
dsp = _dsp;
hours = random(25);
minutes = random(61);
}
void ClockController::render()
{
String time = String(hours) + String(":") + String(minutes);
dsp.clearBuffer();
dsp.setFont(u8g2_font_helvB18_te);
int timeHeight = 18;
int timeWidth = dsp.getStrWidth(time.c_str());
int posX = (dsp.getDisplayWidth() / 2) - (timeWidth / 2);
int posY = (dsp.getDisplayHeight() / 2) + (timeHeight / 2);
dsp.setCursor(posX, posY);
dsp.print(time);
dsp.sendBuffer();
}
void ClockController::buttonSelect(SimpleList<BaseController *> *controllers)
{
controllers->pop();
}
void ClockController::buttonDown()
{
hours--;
}
void ClockController::buttonUp()
{
hours++;
}