-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserInterface.cpp
More file actions
69 lines (62 loc) · 1.17 KB
/
Copy pathUserInterface.cpp
File metadata and controls
69 lines (62 loc) · 1.17 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
#include "UserInterface.h"
UserInterface::UserInterface(byte screenWidth, byte screenHeight)
{
_sWidth = screenWidth;
_sHeight = screenHeight;
}
void UserInterface::draw(Graphics *gfx)
{
if(!_visible) {
return;
}
gfx->setFont(u8g2_font_u8glib_4_tf);
gfx->setCursor(0, _sHeight);
gfx->getU8g2().print(_deaths);
if (_death)
{
for (byte i = 0; i < _currentLine; i++)
{
gfx->drawLine(0,i, _sWidth, i);
}
}
}
void UserInterface::setDeaths(int d)
{
_deaths = d;
}
void UserInterface::setVisible(bool visible)
{
_visible = visible;
}
void UserInterface::update()
{
if (_death)
{
if (_currentLine > 0)
{
if (_currentLine >= _sHeight)
{
_filling = false;
}
}
else if( !_filling)
{
_death = false;
}
if (_filling)
{
_currentLine+=20;
}
else
{
_currentLine-=20;
}
}
}
void UserInterface::setDeath(bool d)
{
_death = d;
_framesRemaining = (_sHeight * 2)/4;
_filling = true;
_currentLine = 0;
}