-
Notifications
You must be signed in to change notification settings - Fork 8
/
carduino.cpp
67 lines (51 loc) · 1.44 KB
/
carduino.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
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
#include <arduino.h>
#include "carduino.h"
void CarSystem::serialize() {
uint8_t packetSize = _state->getSize();
char* data = _state->getData();
Serial.write("{s");
Serial.write(_id);
Serial.write(packetSize);
for (int i = 0; i < packetSize; i++) {
Serial.write(data[i]);
}
Serial.write("}");
}
//////////////////////////////////////////
void ClimateControl::setAc(bool state) {
_state->writeFlag(0, 0x80, state);
}
void ClimateControl::setAuto(bool state) {
_state->writeFlag(0, 0x40, state);
}
void ClimateControl::setAirductWindshield(bool state) {
_state->writeFlag(0, 0x20, state);
}
void ClimateControl::setAirductFace(bool state) {
_state->writeFlag(0, 0x10, state);
}
void ClimateControl::setAirductFeet(bool state) {
_state->writeFlag(0, 0x08, state);
}
void ClimateControl::setWindshieldHeating(bool state) {
_state->writeFlag(0, 0x04, state);
}
void ClimateControl::setRearWindowHeating(bool state) {
_state->writeFlag(0, 0x02, state);
}
void ClimateControl::setRecirculation(bool state) {
_state->writeFlag(0, 0x01, state);
}
void ClimateControl::setFanLevel(uint8_t fans) {
_state->writeByte(1, fans);
}
void ClimateControl::setDesiredTemperature(uint8_t temperature) {
_state->writeByte(2, temperature);
}
//////////////////////////////////////////
void GearBox::setGear(int8_t gearNum) {
_state->writeByte(0, gearNum);
}
void GearBox::setSynchroRev(bool state) {
_state->writeFlag(0, 0x80, state);
}