-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEM_status.h
More file actions
42 lines (35 loc) · 1.39 KB
/
Copy pathEM_status.h
File metadata and controls
42 lines (35 loc) · 1.39 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
#pragma once
#include <string.h>
#include <stdint.h>
#ifdef HT_DEBUG_EN
#include "Arduino.h"
#endif
#pragma pack(push,1)
// @Parseclass
class EM_status {
public:
EM_status() = default;
EM_status(uint8_t buf[]) { load(buf); }
inline void load(uint8_t buf[]) { memcpy(this, buf, sizeof(*this)); }
inline void write(uint8_t buf[]) const { memcpy(buf, this, sizeof(*this)); }
inline uint8_t get_voltage_gain() const { return gain & 0xF; }
inline uint8_t get_current_gain() const { return gain >> 4; }
inline bool get_overvoltage() const { return flags & 0x1; }
inline bool get_overpower() const { return flags & 0x2; }
inline bool get_logging() const { return flags & 0x4; }
#ifdef HT_DEBUG_EN
void print() {
SerialUSB.println("\n\nEM STATUS");
SerialUSB.println( "---------");
SerialUSB.print("VOLTAGE GAIN: "); SerialUSB.println(get_voltage_gain());
SerialUSB.print("CURRENT GAIN: "); SerialUSB.println(get_current_gain());
SerialUSB.print("OVERVOLTAGE: "); SerialUSB.println(get_overvoltage());
SerialUSB.print("OVERPOWER: "); SerialUSB.println(get_overpower());
SerialUSB.print("LOGGING: "); SerialUSB.println(get_logging());
}
#endif
private:
uint8_t gain;
uint8_t flags; //@Parse @Flaglist(overvoltage, overpower, logging)
};
#pragma pack(pop)