-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBMS_coulomb_counts.h
44 lines (35 loc) · 1.49 KB
/
BMS_coulomb_counts.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
#pragma once
#include <string.h>
#include <stdint.h>
#ifdef HT_DEBUG_EN
#include "Arduino.h"
#endif
#pragma pack(push,1)
// @Parseclass @Prefix(BMS)
class BMS_coulomb_counts {
public:
BMS_coulomb_counts() = default;
BMS_coulomb_counts(uint8_t buf[]) { load(buf); }
BMS_coulomb_counts(uint32_t total_charge, uint32_t total_discharge) {
set_total_charge(total_charge);
set_total_discharge(total_discharge);
}
inline void load(uint8_t buf[]) { memcpy(this, buf, sizeof(*this)); }
inline void write(uint8_t buf[]) const { memcpy(buf, this, sizeof(*this)); }
inline uint32_t get_total_charge() const { return total_charge; }
inline uint32_t get_total_discharge() const { return total_discharge; }
inline void set_total_charge(uint32_t total_charge) { this->total_charge = total_charge; }
inline void set_total_discharge(uint32_t total_discharge) { this->total_discharge = total_discharge; }
#ifdef HT_DEBUG_EN
void print() {
SerialUSB.println("\n\nBMS COULOMB COUNTS");
SerialUSB.println( "------------------");
SerialUSB.print("TOTAL CHARGE: "); SerialUSB.println(total_charge / 10000., 4);
SerialUSB.print("TOTAL DISCHARGE: "); SerialUSB.println(total_discharge / 10000., 4);
}
#endif
private:
uint32_t total_charge; // @Parse @Scale(10000) @Unit(C)
uint32_t total_discharge; // @Parse @Scale(10000) @Unit(C)
};
#pragma pack(pop)