-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathxbot_display_data.cpp
52 lines (49 loc) · 1.21 KB
/
xbot_display_data.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
#include "xbot_display_data.h"
xbot_display_data::xbot_display_data()
{
}
xbot_display_data::~xbot_display_data()
{
}
void xbot_display_data::init()
{
speed_ = 0.0;
battery_percent_ = 0;
battery_points_ = 0.0;
throttle_ = 0;
break_ = 0;
eco_ = false;
light_ = false;
unlockedSpeed_ = false;
}
void xbot_display_data::newData(byte * data)
{
int t,b;
switch(data[2])
{
case 0x60: t = data[5]; //max: 0xC5=197 min: 0x2b=43
t = (int) (t-42)/1.55;
throttle_ = t;
b = data[6]; //max: 0x??=181 min: 0x2b=43
b = (int) (b-42)/1.39;
break_ = b;
break;
case 0x63:
break;
case 0x6d: if(data[4] == 2) // 0x00 = off 0x02 = on
{
eco_ = true;
}
else
{
eco_ = false;
}
battery_points_ = data[5]; // max: 8
light_ = data[6]; // 0x00 = off 0x01 = on
speed_ = ((float)(data[8] + data[9] * 256) ) / 1000;
battery_percent_ = data[12]; // 0x64 = 100%
break;
default:
break;
}
}