IRremoteESP8266: src/ir_Vestel.h Source File

IRremoteESP8266

ir_Vestel.h
Go to the documentation of this file.
1 // Copyright 2018 Erdem U. Altinyurt
2 // Copyright 2019 David Conran
3
7
8 // Supports:
9 // Brand: Vestel, Model: BIOX CXP-9 A/C (9K BTU)
10
11 #ifndef IR_VESTEL_H_
12 #define IR_VESTEL_H_
13
14 #define __STDC_LIMIT_MACROS
15 #include <stdint.h>
16 #ifdef ARDUINO
17 #include <Arduino.h>
18 #endif
19 #include "IRremoteESP8266.h"
20 #include "IRsend.h"
21 #ifdef UNIT_TEST
22 #include "IRsend_test.h"
23 #endif
24
25
26 // Structure of a Command message (56 bits)
27 // Signature: 12 bits. e.g. 0x201
28 // Checksum: 8 bits
29 // Swing: 4 bits. (auto 0xA, stop 0xF)
30 // turbo_sleep_normal: 4bits. (normal 0x1, sleep 0x3, turbo 0x7)
31 // Unused: 8 bits. (0x00)
32 // Temperature: 4 bits. (Celsius, but offset by -16 degrees. e.g. 0x0 = 16C)
33 // Fan Speed: 4 bits (auto 0x1, low 0x5, mid 0x9, high 0xB, 0xD auto hot,
34 // 0xC auto cool)
35 // Mode: 3 bits. (auto 0x0, cold 0x1, dry 0x2, fan 0x3, hot 0x4)
36 // unknown/unused: 6 bits.
37 // Ion flag: 1 bit.
38 // unknown/unused: 1 bit.
39 // Power/message type: 4 bits. (on 0xF, off 0xC, 0x0 == Timer mesage)
40 //
41 // Structure of a Time(r) message (56 bits)
42 // Signature: 12 bits. e.g. 0x201
43 // Checksum: 8 bits
44 // Off Minutes: 3 bits. (Stored in 10 min increments. eg. xx:20 is 0x2)
45 // Off Hours: 5 bits. (0x17 == 11PM / 23:00)
46 // On Minutes: 3 bits. (Stored in 10 min increments. eg. xx:20 is 0x2)
47 // On Hours: 5 bits. (0x9 == 9AM / 09:00)
48 // Clock Hours: 5 bits.
49 // On Timer flag: 1 bit.
50 // Off Timer flag: 1 bit.
51 // Timer mode flag: 1 bit. (Off after X many hours/mins, not at clock time.)
52 // Clock Minutes: 8 bits. (0-59)
53 // Power/message type: 4 bits. (0x0 == Timer mesage, else see Comman message)
54
55 // Constants
56 const uint16_t kVestelAcHdrMark = 3110;
57 const uint16_t kVestelAcHdrSpace = 9066;
58 const uint16_t kVestelAcBitMark = 520;
59 const uint16_t kVestelAcOneSpace = 1535;
60 const uint16_t kVestelAcZeroSpace = 480;
61 const uint16_t kVestelAcTolerance = 30;
62
63 const uint8_t kVestelAcMinTempH = 16;
64 const uint8_t kVestelAcMinTempC = 18;
65 const uint8_t kVestelAcMaxTemp = 30;
66
67 const uint8_t kVestelAcAuto = 0;
68 const uint8_t kVestelAcCool = 1;
69 const uint8_t kVestelAcDry = 2;
70 const uint8_t kVestelAcFan = 3;
71 const uint8_t kVestelAcHeat = 4;
72
73 const uint8_t kVestelAcFanAuto = 1;
74 const uint8_t kVestelAcFanLow = 5;
75 const uint8_t kVestelAcFanMed = 9;
76 const uint8_t kVestelAcFanHigh = 0xB;
77 const uint8_t kVestelAcFanAutoCool = 0xC;
78 const uint8_t kVestelAcFanAutoHot = 0xD;
79
80 const uint8_t kVestelAcNormal = 1;
81 const uint8_t kVestelAcSleep = 3;
82 const uint8_t kVestelAcTurbo = 7;
83 const uint8_t kVestelAcIon = 4;
84 const uint8_t kVestelAcSwing = 0xA;
85
86 const uint8_t kVestelAcChecksumOffset = 12;
87 const uint8_t kVestelAcChecksumSize = 8; // Nr. of bits
88 const uint8_t kVestelAcSwingOffset = 20;
89 const uint8_t kVestelAcTurboSleepOffset = 24;
90 const uint8_t kVestelAcTempOffset = 36;
91 const uint8_t kVestelAcFanOffset = 40;
92 const uint8_t kVestelAcFanSize = 4; // Nr. of bits
93 const uint8_t kVestelAcModeOffset = 44;
94 const uint8_t kVestelAcIonOffset = 50;
95 const uint8_t kVestelAcPowerOffset = 52;
96 const uint8_t kVestelAcPowerSize = 2; // Nr. of bits
97 const uint8_t kVestelAcOffTimeOffset = 20;
98 const uint8_t kVestelAcOnTimeOffset = 28;
99 const uint8_t kVestelAcTimerHourSize = 5; // Nr. of bits
100 const uint8_t kVestelAcTimerMinsSize = 3; // Nr. of bits
101 const uint8_t kVestelAcTimerSize = kVestelAcTimerHourSize +
102 kVestelAcTimerMinsSize; // Nr. of bits
103 const uint8_t kVestelAcHourOffset = 36; // 5 bits
104 const uint8_t kVestelAcHourSize = 5; // Nr. of bits
105 const uint8_t kVestelAcOnTimerFlagOffset = kVestelAcHourOffset + 5;
106 const uint8_t kVestelAcOffTimerFlagOffset = kVestelAcHourOffset + 6;
107 const uint8_t kVestelAcTimerFlagOffset = kVestelAcHourOffset + 7;
108 const uint8_t kVestelAcMinuteOffset = 44;
109 const uint8_t kVestelAcMinuteSize = 8; // Nr. of bits
110 // Default states
111 const uint64_t kVestelAcStateDefault = 0x0F00D9001FEF201ULL;
112 const uint64_t kVestelAcTimeStateDefault = 0x201ULL;
113
114 // Classes
116 class IRVestelAc {
117 public:
118 explicit IRVestelAc(const uint16_t pin, const bool inverted = false,
119 const bool use_modulation = true);
120 void stateReset(void);
121 #if SEND_VESTEL_AC
122 void send(const uint16_t repeat = kNoRepeat);
127 int8_t calibrate(void) { return _irsend.calibrate(); }
128 #endif // SEND_VESTEL_AC
129 void begin(void);
130 void on(void);
131 void off(void);
132 void setPower(const bool on);
133 bool getPower(void);
134 void setAuto(const int8_t autoLevel);
135 void setTimer(const uint16_t minutes);
136 uint16_t getTimer(void);
137 void setTime(const uint16_t minutes);
138 uint16_t getTime(void);
139 void setOnTimer(const uint16_t minutes);
140 uint16_t getOnTimer(void);
141 void setOffTimer(const uint16_t minutes);
142 uint16_t getOffTimer(void);
143 void setTemp(const uint8_t temp);
144 uint8_t getTemp(void);
145 void setFan(const uint8_t fan);
146 uint8_t getFan(void);
147 void setMode(const uint8_t mode);
148 uint8_t getMode(void);
149 void setRaw(const uint8_t* newState);
150 void setRaw(const uint64_t newState);
151 uint64_t getRaw(void);
152 static bool validChecksum(const uint64_t state);
153 void setSwing(const bool on);
154 bool getSwing(void);
155 void setSleep(const bool on);
156 bool getSleep(void);
157 void setTurbo(const bool on);
158 bool getTurbo(void);
159 void setIon(const bool on);
160 bool getIon(void);
161 bool isTimeCommand(void);
162 bool isOnTimerActive(void);
163 void setOnTimerActive(const bool on);
164 bool isOffTimerActive(void);
165 void setOffTimerActive(const bool on);
166 bool isTimerActive(void);
167 void setTimerActive(const bool on);
168 static uint8_t calcChecksum(const uint64_t state);
169 static uint8_t convertMode(const stdAc::opmode_t mode);
170 static uint8_t convertFan(const stdAc::fanspeed_t speed);
171 static stdAc::opmode_t toCommonMode(const uint8_t mode);
172 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
173 stdAc::state_t toCommon(void);
174 String toString(void);
175 #ifndef UNIT_TEST
176
177 private:
178 IRsend _irsend;
179 #else // UNIT_TEST
180 IRsendTest _irsend;
182 #endif // UNIT_TEST
184 uint64_t remote_state;
185 uint64_t remote_time_state;
186 bool use_time_state;
187 void checksum(void);
188 void _setTimer(const uint16_t minutes, const uint8_t offset);
189 uint16_t _getTimer(const uint8_t offset);
190 };
191
192 #endif // IR_VESTEL_H_
kVestelAcHdrSpace
const uint16_t kVestelAcHdrSpace
Definition: ir_Vestel.h:57
kVestelAcOffTimeOffset
const uint8_t kVestelAcOffTimeOffset
Definition: ir_Vestel.h:97
kVestelAcFanAutoHot
const uint8_t kVestelAcFanAutoHot
Definition: ir_Vestel.h:78
IRVestelAc::stateReset
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition: ir_Vestel.cpp:60
IRVestelAc::getOffTimer
uint16_t getOffTimer(void)
Get the A/C's Off Timer time.
Definition: ir_Vestel.cpp:330
kVestelAcTimerHourSize
const uint8_t kVestelAcTimerHourSize
Definition: ir_Vestel.h:99
IRVestelAc::toCommon
stdAc::state_t toCommon(void)
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Vestel.cpp:478
IRVestelAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Vestel.cpp:67
IRVestelAc::setFan
void setFan(const uint8_t fan)
Set the speed of the fan.
Definition: ir_Vestel.cpp:147
kVestelAcHourSize
const uint8_t kVestelAcHourSize
Definition: ir_Vestel.h:104
kVestelAcFanOffset
const uint8_t kVestelAcFanOffset
Definition: ir_Vestel.h:91
IRVestelAc::setTemp
void setTemp(const uint8_t temp)
Set the temperature.
Definition: ir_Vestel.cpp:130
IRVestelAc::setOffTimerActive
void setOffTimerActive(const bool on)
Set the Off timer to be active on the A/C.
Definition: ir_Vestel.cpp:310
IRVestelAc::setTime
void setTime(const uint16_t minutes)
Set the A/C's internal clock.
Definition: ir_Vestel.cpp:247
kVestelAcMaxTemp
const uint8_t kVestelAcMaxTemp
Definition: ir_Vestel.h:65
IRVestelAc::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Vestel.cpp:116
IRVestelAc::isTimeCommand
bool isTimeCommand(void)
Is the current state a time command?
Definition: ir_Vestel.cpp:419
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
kVestelAcSleep
const uint8_t kVestelAcSleep
Definition: ir_Vestel.h:81
IRVestelAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Vestel.h:127
kVestelAcDry
const uint8_t kVestelAcDry
Definition: ir_Vestel.h:69
kVestelAcBitMark
const uint16_t kVestelAcBitMark
Definition: ir_Vestel.h:58
kVestelAcAuto
const uint8_t kVestelAcAuto
Definition: ir_Vestel.h:67
kVestelAcFanMed
const uint8_t kVestelAcFanMed
Definition: ir_Vestel.h:75
IRVestelAc::setTurbo
void setTurbo(const bool on)
Set the Turbo setting of the A/C.
Definition: ir_Vestel.cpp:351
IRVestelAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Vestel.h:178
IRVestelAc::setTimer
void setTimer(const uint16_t minutes)
Set Timer option of A/C.
Definition: ir_Vestel.cpp:228
IRVestelAc::on
void on(void)
Set the requested power state of the A/C to on.
Definition: ir_Vestel.cpp:109
IRVestelAc::_getTimer
uint16_t _getTimer(const uint8_t offset)
Get the number of minutes a timer is set for.
Definition: ir_Vestel.cpp:289
IRVestelAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Vestel.cpp:178
IRsend.h
IRVestelAc::isOffTimerActive
bool isOffTimerActive(void)
Get if the Off Timer is active on the A/C.
Definition: ir_Vestel.cpp:317
kVestelAcMinuteSize
const uint8_t kVestelAcMinuteSize
Definition: ir_Vestel.h:109
kVestelAcMinTempC
const uint8_t kVestelAcMinTempC
Definition: ir_Vestel.h:64
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:187
kVestelAcChecksumSize
const uint8_t kVestelAcChecksumSize
Definition: ir_Vestel.h:87
IRVestelAc::getTimer
uint16_t getTimer(void)
Get the Timer time of A/C.
Definition: ir_Vestel.cpp:243
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
kVestelAcFanSize
const uint8_t kVestelAcFanSize
Definition: ir_Vestel.h:92
kVestelAcSwingOffset
const uint8_t kVestelAcSwingOffset
Definition: ir_Vestel.h:88
IRVestelAc::isOnTimerActive
bool isOnTimerActive(void)
Get if the On Timer is active on the A/C.
Definition: ir_Vestel.cpp:272
String
std::string String
Definition: IRremoteESP8266.h:1199
kVestelAcTimerFlagOffset
const uint8_t kVestelAcTimerFlagOffset
Definition: ir_Vestel.h:107
IRVestelAc::isTimerActive
bool isTimerActive(void)
Get if the Timer is active on the A/C.
Definition: ir_Vestel.cpp:220
IRVestelAc::setRaw
void setRaw(const uint8_t *newState)
Set the internal state from a valid code for this protocol.
Definition: ir_Vestel.cpp:87
kVestelAcFan
const uint8_t kVestelAcFan
Definition: ir_Vestel.h:70
IRremoteESP8266.h
kVestelAcMinTempH
const uint8_t kVestelAcMinTempH
Definition: ir_Vestel.h:63
IRVestelAc::getTemp
uint8_t getTemp(void)
Get the current temperature setting.
Definition: ir_Vestel.cpp:140
kVestelAcHdrMark
const uint16_t kVestelAcHdrMark
Definition: ir_Vestel.h:56
kNoRepeat
const uint16_t kNoRepeat
Definition: IRremoteESP8266.h:891
IRVestelAc::remote_time_state
uint64_t remote_time_state
The time state of the remote in code form.
Definition: ir_Vestel.h:185
kVestelAcOnTimerFlagOffset
const uint8_t kVestelAcOnTimerFlagOffset
Definition: ir_Vestel.h:105
IRVestelAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Vestel.cpp:454
IRVestelAc::remote_state
uint64_t remote_state
The state of the IR remote in IR code form.
Definition: ir_Vestel.h:184
IRVestelAc::getSleep
bool getSleep(void)
Get the Sleep setting of the A/C.
Definition: ir_Vestel.cpp:344
kVestelAcOneSpace
const uint16_t kVestelAcOneSpace
Definition: ir_Vestel.h:59
IRVestelAc::checksum
void checksum(void)
Calculate & set the checksum for the current internal state of the remote.
Definition: ir_Vestel.cpp:409
IRVestelAc::setSwing
void setSwing(const bool on)
Set the Swing Roaming setting of the A/C.
Definition: ir_Vestel.cpp:379
IRVestelAc::getTurbo
bool getTurbo(void)
Get the Turbo setting of the A/C.
Definition: ir_Vestel.cpp:359
kVestelAcTempOffset
const uint8_t kVestelAcTempOffset
Definition: ir_Vestel.h:90
IRVestelAc::setOffTimer
void setOffTimer(const uint16_t minutes)
Set the Off timer time on the A/C.
Definition: ir_Vestel.cpp:323
kVestelAcTimerMinsSize
const uint8_t kVestelAcTimerMinsSize
Definition: ir_Vestel.h:100
IRVestelAc::setOnTimerActive
void setOnTimerActive(const bool on)
Set the On timer to be active on the A/C.
Definition: ir_Vestel.cpp:265
kVestelAcHourOffset
const uint8_t kVestelAcHourOffset
Definition: ir_Vestel.h:103
IRVestelAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Vestel.cpp:467
IRVestelAc::send
void send(const uint16_t repeat=kNoRepeat)
Send the current internal state as an IR message.
Definition: ir_Vestel.cpp:72
IRVestelAc::off
void off(void)
Set the requested power state of the A/C to off.
Definition: ir_Vestel.cpp:112
kVestelAcFanAutoCool
const uint8_t kVestelAcFanAutoCool
Definition: ir_Vestel.h:77
kVestelAcStateDefault
const uint64_t kVestelAcStateDefault
Definition: ir_Vestel.h:111
IRVestelAc::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Vestel.cpp:427
IRVestelAc::setIon
void setIon(const bool on)
Set the Ion (Filter) setting of the A/C.
Definition: ir_Vestel.cpp:366
IRVestelAc::toString
String toString(void)
Convert the current internal state into a human readable string.
Definition: ir_Vestel.cpp:505
kVestelAcTolerance
const uint16_t kVestelAcTolerance
Definition: ir_Vestel.h:61
kVestelAcFanLow
const uint8_t kVestelAcFanLow
Definition: ir_Vestel.h:74
kVestelAcChecksumOffset
const uint8_t kVestelAcChecksumOffset
Definition: ir_Vestel.h:86
kVestelAcPowerSize
const uint8_t kVestelAcPowerSize
Definition: ir_Vestel.h:96
kVestelAcSwing
const uint8_t kVestelAcSwing
Definition: ir_Vestel.h:84
kVestelAcIonOffset
const uint8_t kVestelAcIonOffset
Definition: ir_Vestel.h:94
kVestelAcOnTimeOffset
const uint8_t kVestelAcOnTimeOffset
Definition: ir_Vestel.h:98
kVestelAcZeroSpace
const uint16_t kVestelAcZeroSpace
Definition: ir_Vestel.h:60
kVestelAcMinuteOffset
const uint8_t kVestelAcMinuteOffset
Definition: ir_Vestel.h:108
kVestelAcTimeStateDefault
const uint64_t kVestelAcTimeStateDefault
Definition: ir_Vestel.h:112
IRVestelAc::getTime
uint16_t getTime(void)
Get the A/C's internal clock's time.
Definition: ir_Vestel.cpp:257
kVestelAcTurboSleepOffset
const uint8_t kVestelAcTurboSleepOffset
Definition: ir_Vestel.h:89
kVestelAcTurbo
const uint8_t kVestelAcTurbo
Definition: ir_Vestel.h:82
IRVestelAc::getPower
bool getPower(void)
Get the value of the current power setting.
Definition: ir_Vestel.cpp:124
IRVestelAc::calcChecksum
static uint8_t calcChecksum(const uint64_t state)
Calculate the checksum for a given state.
Definition: ir_Vestel.cpp:395
IRVestelAc::getRaw
uint64_t getRaw(void)
Get a copy of the internal state/code for this protocol.
Definition: ir_Vestel.cpp:79
kVestelAcHeat
const uint8_t kVestelAcHeat
Definition: ir_Vestel.h:71
kVestelAcNormal
const uint8_t kVestelAcNormal
Definition: ir_Vestel.h:80
kVestelAcFanHigh
const uint8_t kVestelAcFanHigh
Definition: ir_Vestel.h:76
kVestelAcTimerSize
const uint8_t kVestelAcTimerSize
Definition: ir_Vestel.h:101
IRVestelAc::IRVestelAc
IRVestelAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Vestel.cpp:54
IRVestelAc
Class for handling detailed Vestel A/C messages.
Definition: ir_Vestel.h:116
IRVestelAc::getIon
bool getIon(void)
Get the Ion (Filter) setting of the A/C.
Definition: ir_Vestel.cpp:373
kVestelAcCool
const uint8_t kVestelAcCool
Definition: ir_Vestel.h:68
IRVestelAc::getMode
uint8_t getMode(void)
Get the operating mode setting of the A/C.
Definition: ir_Vestel.cpp:171
IRVestelAc::getOnTimer
uint16_t getOnTimer(void)
Get the A/C's On Timer time.
Definition: ir_Vestel.cpp:304
IRVestelAc::setTimerActive
void setTimerActive(const bool on)
Set the timer to be active on the A/C.
Definition: ir_Vestel.cpp:213
IRVestelAc::setSleep
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition: ir_Vestel.cpp:336
IRVestelAc::_setTimer
void _setTimer(const uint16_t minutes, const uint8_t offset)
Set a given timer time at a given bit offset.
Definition: ir_Vestel.cpp:279
IRVestelAc::use_time_state
bool use_time_state
Definition: ir_Vestel.h:186
kVestelAcOffTimerFlagOffset
const uint8_t kVestelAcOffTimerFlagOffset
Definition: ir_Vestel.h:106
kVestelAcModeOffset
const uint8_t kVestelAcModeOffset
Definition: ir_Vestel.h:93
kVestelAcIon
const uint8_t kVestelAcIon
Definition: ir_Vestel.h:83
IRVestelAc::getFan
uint8_t getFan(void)
Get the current fan speed setting.
Definition: ir_Vestel.cpp:165
IRVestelAc::getSwing
bool getSwing(void)
Get the Swing Roaming setting of the A/C.
Definition: ir_Vestel.cpp:387
kVestelAcPowerOffset
const uint8_t kVestelAcPowerOffset
Definition: ir_Vestel.h:95
IRVestelAc::validChecksum
static bool validChecksum(const uint64_t state)
Verify the checksum is valid for a given state.
Definition: ir_Vestel.cpp:403
IRVestelAc::setAuto
void setAuto(const int8_t autoLevel)
Set Auto mode/level of the A/C.
Definition: ir_Vestel.cpp:195
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
kVestelAcFanAuto
const uint8_t kVestelAcFanAuto
Definition: ir_Vestel.h:73
IRVestelAc::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Vestel.cpp:440
IRVestelAc::setOnTimer
void setOnTimer(const uint16_t minutes)
Set the On timer time on the A/C.
Definition: ir_Vestel.cpp:297
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46