-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathECU_Display.ino
More file actions
72 lines (53 loc) · 1.33 KB
/
Copy pathECU_Display.ino
File metadata and controls
72 lines (53 loc) · 1.33 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
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
#include "ECU_Comms.h"
#include "ECU_Read.h"
#include "DIS_Comms.h"
#include "DIS_Draw.h"
unsigned long MFSW_REC_ID = 0x2C1;
int airFlow, eSpeed, atmPressure, mapPressure, oilTemp, boostP, power, torque = 0;
bool reset = false;
bool paused = false;
void checkComms() {
if (!ecuCommsOk() || !disCommsOk()) {
startComms();
}
}
void startComms() {
// Start DIS Comms
initDIS();
claimScreen();
drawFrame();
//Start ECU Comms
initECU();
}
void setup() {
Serial.begin(115200);
startComms();
}
void loop() {
if (reset) {
reset = false;
paused = false;
startComms();
}
if (!paused) {
checkComms();
airFlow = readMAF();
eSpeed = readES();
atmPressure = readATMP();
mapPressure = readMAP();
oilTemp = readOT();
power = calcPower(airFlow);
torque = calcTorque(airFlow, eSpeed);
boostP = calcBoost(mapPressure, atmPressure);
Serial.println(airFlow);
Serial.println(eSpeed);
Serial.println(atmPressure);
Serial.println(mapPressure);
Serial.println(oilTemp);
drawData(power, torque, boostP, oilTemp);
checkComms();
} else {
readMFSW(MFSW_REC_ID);
}
delay(200);
}