-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplay.cpp
More file actions
126 lines (110 loc) · 2.75 KB
/
display.cpp
File metadata and controls
126 lines (110 loc) · 2.75 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
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
126
#include "display.h"
#include "motorfunctions.h"
#include "menu.h"
#include "settings.h"
// for some undefined reasons, the buffer size has to be 6 on recent SDK,
// change it back for using an older SDK
#define ROW_NUM 6
// #define ROW_NUM 5
static uint8_t display_timerCounter = 0;
static uint8_t display_timerCounter_step = 0;
static bool initAnimationState = false;
static uint8_t DisBuff[2 + ROW_NUM * 5 * 3];
void display_init(void)
{
display_clear();
M5.dis.displaybuff(DisBuff);
}
void display_set(const uint8_t row, const uint8_t col, const uint8_t Rdata, const uint8_t Gdata, const uint8_t Bdata, const bool updateBuff)
{
const uint8_t pos = row * ROW_NUM + col;
DisBuff[2 + pos * 3 + 0] = Rdata;
DisBuff[2 + pos * 3 + 1] = Gdata;
DisBuff[2 + pos * 3 + 2] = Bdata;
if (updateBuff)
{
M5.dis.displaybuff(DisBuff);
}
}
void display_setRowArray (const uint8_t Row, const uint8_t Start, const uint8_t Lenght, const uint8_t* Array, const bool updateBuff)
{
uint8_t j = 0;
for (int i = Start; i < ROW_NUM; i++)
{
if (i < (Start + Lenght))
{
display_set (Row, i, Array[j++], Array[j++], Array[j++]);
}
}
if (updateBuff)
{
M5.dis.displaybuff(DisBuff);
}
}
void display_clear(void)
{
DisBuff[0] = 0x05;
DisBuff[1] = 0x05;
for (int i = 0; i < ROW_NUM; i++)
{
for (int j = 0; j < 5; j++)
{
display_set (i, j, 0, 0, 0);
}
}
}
void display_counterDelay (uint32_t d)
{
display_timerCounter += d / 50;
delay (d);
}
// Update Counter for animation
bool display_updateAnimationCounter ()
{
display_timerCounter ++;
if (display_timerCounter > 20)
{
display_timerCounter = 0;
return true;
}
return false;
}
void display_resetAnimationCounter ()
{
display_timerCounter_step = 0;
}
void display_initAnimation ()
{
if (display_updateAnimationCounter ())
{
if (initAnimationState)
{
initAnimationState = false;
display_set(0, 0, 0, 0, 0, true);
}
else
{
initAnimationState = true;
display_set(0, 0, 0, 0, 255, true);
}
}
}
void display_drawFunctionAnimation()
{
if (display_updateAnimationCounter ())
{
display_timerCounter_step++;
if (display_timerCounter_step > functionParameters[getSettingsFunction(getRemoteButton(), getPortId())].Steps)
{
display_resetAnimationCounter();
}
display_setRowArray(getSubState(), 1, 4, functionParameters[getSettingsFunction(getRemoteButton(), getPortId())].Graphics[display_timerCounter_step], true);
}
}
void display_redrawFunctions()
{
for (int i = 0; i <= getMaxPortId(); i++)
{
display_setRowArray(i + 1, 1, 4, functionParameters[getSettingsFunction(getRemoteButton(),i)].Graphics[functionParameters[getSettingsFunction(getRemoteButton(),i)].Steps], true);
}
}