-
Notifications
You must be signed in to change notification settings - Fork 1
/
MFD.cpp
99 lines (80 loc) · 1.41 KB
/
MFD.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "MFD.hpp"
MFD::MFD ()
{
hdl = x52_init();
x52_setbri(hdl,1,100);
}
MFD::~MFD ()
{
x52_close(hdl);
}
void
MFD::setLine1 ( std::string line, bool center )
{
setLine(0,line,center);
}
void
MFD::setLine2 ( std::string line, bool center )
{
setLine(1,line,center);
}
void
MFD::setLine3 ( std::string line, bool center)
{
setLine(2,line,center);
}
void
MFD::setLine(int line_id, std::string line, bool center)
{
// pad with spaces to center text
if (center) {
int spaceCount = (16-line.length())/2;
for (int i=0; i<spaceCount; i++) {
line = " "+line;
};
}
std::cout<<"setting line "<<line_id<<" to: "<<line<<std::endl;
char * constLine = const_cast<char*>(line.c_str());
x52_settext(hdl,line_id,constLine, strlen(constLine));
}
void
MFD::setPage ( MfdPage page )
{
std::string line1(page.getLine1());
std::string line2(page.getLine2());
std::string line3(page.getLine3());
if(isUpdateEnabled){
MFD::setLine1(line1, true);
MFD::setLine2(line2, true);
MFD::setLine3(line3, true);
}
}
MfdPage::MfdPage (Msg msg)
{
message = msg;
}
std::string
MfdPage::getLine1 ( )
{
return message.title;
}
std::string
MfdPage::getLine2 ( )
{
return message.actFreq0+"<>"+message.stbyFreq0;
}
std::string
MfdPage::getLine3 ( )
{
return message.actFreq1+"<>"+message.stbyFreq1;
}
void
MFD::enableUpdate ()
{
isUpdateEnabled = true ;
}
void
MFD::disableUpdate ()
{
isUpdateEnabled = false ;
}