-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathb500rep.h
72 lines (58 loc) · 1.24 KB
/
b500rep.h
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
#ifndef B500REP_H
#define B500REP_H
#include "rs232_bus.h"
#include "runnable.h"
struct snap_header
{
uint8_t preamble; //0x53
uint8_t sync; //0x54
uint8_t hdb2; //header definition byte 2
uint8_t hdb1; //header definition byte 1
uint8_t dab1; //dst address byte 1
uint8_t sab1; //src address byte 1
} __attribute__ ((__packed__));
struct snap_crc
{
uint8_t crc_high;
uint8_t crc_low;
} __attribute__ ((__packed__));
struct adu_data
{
uint8_t lift_low;
uint8_t lift_high;
uint8_t led_bits;
uint8_t lift_unit;
uint8_t audio_level;
uint8_t avg_low;
uint8_t avg_high;
uint8_t lift_mode;
} __attribute__ ((__packed__));
class b500rep :
public runnable
{
private:
rs232_bus & m_rs232;
int m_needle;
bool m_downdown;
bool m_down;
bool m_up;
bool m_upup;
bool m_minus;
bool m_plus;
uint16_t snap_calc_crc(const uint8_t * buf, uint16_t len) const;
uint8_t calc_led_bits() const;
public:
b500rep(rs232_bus & rs232);
virtual ~b500rep();
void downdown(bool value);
void down(bool value);
void up(bool value);
void upup(bool value);
void minus(bool value);
void plus(bool value);
void needle(int16_t value);
void vario(float value);
void update();
void run();
};
#endif