-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cpp
40 lines (34 loc) · 862 Bytes
/
main.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
// this is an example and will not work as is (probably).
#include "defines.h"
#include "structs.h"
#include "Utils.h"
#include "AntBMS.h"
#include <elapsedMillis.h>
AntBMS BMS;
struct SabStruct SabValues;
elapsedMillis sinceBMSRead, sinceBMSQuery;
void setup(){
BMS.begin();
}
void loop(){
// Handle BMS communication
if (!status.waitingBMSResponse &&
sinceBMSRead > BMS_INTERVAL_READ) {
//Serial.println("Request BMS...");
status.waitingBMSResponse = true;
BMS.request_data();
sinceBMSQuery = 0;
}
if (status.waitingBMSResponse && sinceBMSQuery > BMS_DELAY_RESPONSE) {
if (BMS.read_data(&BMSValues)) {
//Serial.println("BMS OK Read");
//if (DEBUG) BMS.dump_packet();
//if (DEBUG) BMS.printSerial(&BMSValues);
}
else {
Serial.println("Failed Read BMS");
}
status.waitingBMSResponse = false;
sinceBMSRead = 0;
}
}