-
Notifications
You must be signed in to change notification settings - Fork 1
/
UI.cpp
85 lines (65 loc) · 1.61 KB
/
UI.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
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
#include "UI.h"
#include <string.h>
UI::UI()
{
}
UI::~UI()
{
}
void UI::init(U8GLIB_SSD1306_128X64* pDisplay)
{
m_pDisplay = pDisplay;
//OLED
m_pDisplay->setFont(u8g_font_6x10);// (u8g_font_unifont);
const char channelName[] = "CH ";
strcpy(buf_c0, channelName);
strcpy(buf_c1, channelName);
strcpy(buf_c2, channelName);
strcpy(buf_c3, channelName);
strcpy(buf_c4, channelName);
strcpy(buf_c5, channelName);
strcpy(buf_c6, channelName);
strcpy(buf_c7, channelName);
buf_c0[2] = '1';
buf_c1[2] = '2';
buf_c2[2] = '3';
buf_c3[2] = '4';
buf_c4[2] = '5';
buf_c5[2] = '6';
buf_c6[2] = '7';
buf_c7[2] = '8';
}
void UI::draw(int8_t OprMode, int16_t* pChannels)
{
const char* strMode[] = {"MODE: SERIAL BRIDGE","MODE: MANUAL","MODE: ALT HOLD","MODE: LOTER","MODE: AUTO","MODE: RC BRIDGE","Booting..."};
if (pChannels)
{
itoa(pChannels[0], &buf_c0[4], 10);
itoa(pChannels[1], &buf_c1[4], 10);
itoa(pChannels[2], &buf_c2[4], 10);
itoa(pChannels[3], &buf_c3[4], 10);
itoa(pChannels[4], &buf_c4[4], 10);
itoa(pChannels[5], &buf_c5[4], 10);
itoa(pChannels[6], &buf_c6[4], 10);
itoa(pChannels[7], &buf_c7[4], 10);
}
else
{
return;
}
//OLED reset
m_pDisplay->firstPage();
do
{
//Operation mode
m_pDisplay->drawStr(0, 10, strMode[OprMode]);
m_pDisplay->drawStr(0, 20, buf_c0);
m_pDisplay->drawStr(0, 30, buf_c1);
m_pDisplay->drawStr(0, 40, buf_c2);
m_pDisplay->drawStr(0, 50, buf_c3);
m_pDisplay->drawStr(64, 20, buf_c4);
m_pDisplay->drawStr(64, 30, buf_c5);
m_pDisplay->drawStr(64, 40, buf_c6);
m_pDisplay->drawStr(64, 50, buf_c7);
} while (m_pDisplay->nextPage());
}