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 
27  struct {
28  uint64_t cmdState;
29  uint64_t timeState;
30  };
31  struct {
32  // Command
33  uint64_t Signature :12; // 0x201
34  uint64_t CmdSum :8;
35  uint64_t Swing :4; // auto 0xA, stop 0xF
36  uint64_t TurboSleep :4; // normal 0x1, sleep 0x3, turbo 0x7
37  uint64_t :8;
38  uint64_t Temp :4;
39  uint64_t Fan :4;
40  uint64_t Mode :3;
41  uint64_t :3;
42  uint64_t Ion :1;
43  uint64_t :1;
44  uint64_t Power :2;
45  uint64_t UseCmd :1;
46  uint64_t :0;
47  // Time
48  uint64_t :12;
49  uint64_t TimeSum :8;
50  uint64_t OffTenMins :3;
51  uint64_t OffHours :5;
52  uint64_t OnTenMins :3;
53  uint64_t OnHours :5;
54  uint64_t Hours :5;
55  uint64_t OnTimer :1;
56  uint64_t OffTimer :1;
57  uint64_t Timer :1;
58  uint64_t Minutes :8;
59  uint64_t :0;
60  };
61 };
62 
63 // Constants
64 const uint16_t kVestelAcHdrMark = 3110;
65 const uint16_t kVestelAcHdrSpace = 9066;
66 const uint16_t kVestelAcBitMark = 520;
67 const uint16_t kVestelAcOneSpace = 1535;
68 const uint16_t kVestelAcZeroSpace = 480;
69 const uint16_t kVestelAcTolerance = 30;
70 
71 const uint8_t kVestelAcMinTempH = 16;
72 const uint8_t kVestelAcMinTempC = 18;
73 const uint8_t kVestelAcMaxTemp = 30;
74 
75 const uint8_t kVestelAcAuto = 0;
76 const uint8_t kVestelAcCool = 1;
77 const uint8_t kVestelAcDry = 2;
78 const uint8_t kVestelAcFan = 3;
79 const uint8_t kVestelAcHeat = 4;
80 
81 const uint8_t kVestelAcFanAuto = 1;
82 const uint8_t kVestelAcFanLow = 5;
83 const uint8_t kVestelAcFanMed = 9;
84 const uint8_t kVestelAcFanHigh = 0xB;
85 const uint8_t kVestelAcFanAutoCool = 0xC;
86 const uint8_t kVestelAcFanAutoHot = 0xD;
87 
88 const uint8_t kVestelAcNormal = 1;
89 const uint8_t kVestelAcSleep = 3;
90 const uint8_t kVestelAcTurbo = 7;
91 const uint8_t kVestelAcIon = 4;
92 const uint8_t kVestelAcSwing = 0xA;
93 
94 // Default states
95 const uint64_t kVestelAcStateDefault = 0x0F00D9001FEF201ULL;
96 const uint64_t kVestelAcTimeStateDefault = 0x201ULL;
97 
98 // Classes
100 class IRVestelAc {
101  public:
102  explicit IRVestelAc(const uint16_t pin, const bool inverted = false,
103  const bool use_modulation = true);
104  void stateReset(void);
105 #if SEND_VESTEL_AC
106  void send(const uint16_t repeat = kNoRepeat);
111  int8_t calibrate(void) { return _irsend.calibrate(); }
112 #endif // SEND_VESTEL_AC
113  void begin(void);
114  void on(void);
115  void off(void);
116  void setPower(const bool on);
117  bool getPower(void) const;
118  void setAuto(const int8_t autoLevel);
119  void setTimer(const uint16_t minutes);
120  uint16_t getTimer(void) const;
121  void setTime(const uint16_t minutes);
122  uint16_t getTime(void) const;
123  void setOnTimer(const uint16_t minutes);
124  uint16_t getOnTimer(void) const;
125  void setOffTimer(const uint16_t minutes);
126  uint16_t getOffTimer(void) const;
127  void setTemp(const uint8_t temp);
128  uint8_t getTemp(void) const;
129  void setFan(const uint8_t fan);
130  uint8_t getFan(void) const;
131  void setMode(const uint8_t mode);
132  uint8_t getMode(void) const;
133  void setRaw(const uint8_t* newState);
134  void setRaw(const uint64_t newState);
135  uint64_t getRaw(void);
136  static bool validChecksum(const uint64_t state);
137  void setSwing(const bool on);
138  bool getSwing(void) const;
139  void setSleep(const bool on);
140  bool getSleep(void) const;
141  void setTurbo(const bool on);
142  bool getTurbo(void) const;
143  void setIon(const bool on);
144  bool getIon(void) const;
145  bool isTimeCommand(void) const;
146  bool isOnTimerActive(void) const;
147  void setOnTimerActive(const bool on);
148  bool isOffTimerActive(void) const;
149  void setOffTimerActive(const bool on);
150  bool isTimerActive(void) const;
151  void setTimerActive(const bool on);
152  static uint8_t calcChecksum(const uint64_t state);
153  static uint8_t convertMode(const stdAc::opmode_t mode);
154  static uint8_t convertFan(const stdAc::fanspeed_t speed);
155  static stdAc::opmode_t toCommonMode(const uint8_t mode);
156  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
157  stdAc::state_t toCommon(void) const;
158  String toString(void) const;
159 #ifndef UNIT_TEST
160 
161  private:
163 #else // UNIT_TEST
164  IRsendTest _irsend;
166 #endif // UNIT_TEST
169  void checksum(void);
170 };
171 
172 #endif // IR_VESTEL_H_
kVestelAcHdrSpace
const uint16_t kVestelAcHdrSpace
Definition: ir_Vestel.h:65
kVestelAcFanAutoHot
const uint8_t kVestelAcFanAutoHot
Definition: ir_Vestel.h:86
IRVestelAc::stateReset
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition: ir_Vestel.cpp:58
IRVestelAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Vestel.cpp:64
IRVestelAc::setFan
void setFan(const uint8_t fan)
Set the speed of the fan.
Definition: ir_Vestel.cpp:140
VestelProtocol::Timer
uint64_t Timer
Definition: ir_Vestel.h:57
IRVestelAc::setTemp
void setTemp(const uint8_t temp)
Set the temperature.
Definition: ir_Vestel.cpp:125
IRVestelAc::setOffTimerActive
void setOffTimerActive(const bool on)
Set the Off timer to be active on the A/C.
Definition: ir_Vestel.cpp:282
IRVestelAc::setTime
void setTime(const uint16_t minutes)
Set the A/C's internal clock.
Definition: ir_Vestel.cpp:240
VestelProtocol::OffHours
uint64_t OffHours
Definition: ir_Vestel.h:51
kVestelAcMaxTemp
const uint8_t kVestelAcMaxTemp
Definition: ir_Vestel.h:73
IRVestelAc::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Vestel.cpp:112
IRVestelAc::getOnTimer
uint16_t getOnTimer(void) const
Get the A/C's On Timer time.
Definition: ir_Vestel.cpp:276
IRVestelAc::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_Vestel.cpp:158
IRVestelAc::getTimer
uint16_t getTimer(void) const
Get the Timer time of A/C.
Definition: ir_Vestel.cpp:236
IRVestelAc::isOnTimerActive
bool isOnTimerActive(void) const
Get if the On Timer is active on the A/C.
Definition: ir_Vestel.cpp:261
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:61
VestelProtocol::Swing
uint64_t Swing
Definition: ir_Vestel.h:35
kVestelAcSleep
const uint8_t kVestelAcSleep
Definition: ir_Vestel.h:89
IRVestelAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Vestel.h:111
kVestelAcDry
const uint8_t kVestelAcDry
Definition: ir_Vestel.h:77
IRVestelAc::getIon
bool getIon(void) const
Get the Ion (Filter) setting of the A/C.
Definition: ir_Vestel.cpp:343
kVestelAcBitMark
const uint16_t kVestelAcBitMark
Definition: ir_Vestel.h:66
kVestelAcAuto
const uint8_t kVestelAcAuto
Definition: ir_Vestel.h:75
kVestelAcFanMed
const uint8_t kVestelAcFanMed
Definition: ir_Vestel.h:83
IRVestelAc::setTurbo
void setTurbo(const bool on)
Set the Turbo setting of the A/C.
Definition: ir_Vestel.cpp:323
IRVestelAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Vestel.h:162
IRVestelAc::setTimer
void setTimer(const uint16_t minutes)
Set Timer option of A/C.
Definition: ir_Vestel.cpp:221
IRVestelAc::on
void on(void)
Set the requested power state of the A/C to on.
Definition: ir_Vestel.cpp:105
IRVestelAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Vestel.cpp:171
IRsend.h
IRVestelAc::toString
String toString(void) const
Convert the current internal state into a human readable string.
Definition: ir_Vestel.cpp:471
IRVestelAc::toCommon
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Vestel.cpp:444
kVestelAcMinTempC
const uint8_t kVestelAcMinTempC
Definition: ir_Vestel.h:72
VestelProtocol
Native representation of a Vestel A/C message.
Definition: ir_Vestel.h:26
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:237
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
String
std::string String
Definition: IRremoteESP8266.h:1521
IRVestelAc::getTime
uint16_t getTime(void) const
Get the A/C's internal clock's time.
Definition: ir_Vestel.cpp:248
VestelProtocol::CmdSum
uint64_t CmdSum
Definition: ir_Vestel.h:34
IRVestelAc::setRaw
void setRaw(const uint8_t *newState)
Set the internal state from a valid code for this protocol.
Definition: ir_Vestel.cpp:84
kVestelAcFan
const uint8_t kVestelAcFan
Definition: ir_Vestel.h:78
IRVestelAc::isOffTimerActive
bool isOffTimerActive(void) const
Get if the Off Timer is active on the A/C.
Definition: ir_Vestel.cpp:289
IRremoteESP8266.h
kVestelAcMinTempH
const uint8_t kVestelAcMinTempH
Definition: ir_Vestel.h:71
VestelProtocol::OffTimer
uint64_t OffTimer
Definition: ir_Vestel.h:56
kVestelAcHdrMark
const uint16_t kVestelAcHdrMark
Definition: ir_Vestel.h:64
kNoRepeat
const uint16_t kNoRepeat
Definition: IRremoteESP8266.h:1145
IRVestelAc::isTimeCommand
bool isTimeCommand(void) const
Is the current state a time command?
Definition: ir_Vestel.cpp:386
VestelProtocol::Power
uint64_t Power
Definition: ir_Vestel.h:44
IRVestelAc::getOffTimer
uint16_t getOffTimer(void) const
Get the A/C's Off Timer time.
Definition: ir_Vestel.cpp:304
IRVestelAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Vestel.cpp:420
IRVestelAc::getTurbo
bool getTurbo(void) const
Get the Turbo setting of the A/C.
Definition: ir_Vestel.cpp:330
VestelProtocol::Ion
uint64_t Ion
Definition: ir_Vestel.h:42
kVestelAcOneSpace
const uint16_t kVestelAcOneSpace
Definition: ir_Vestel.h:67
VestelProtocol::Hours
uint64_t Hours
Definition: ir_Vestel.h:54
IRVestelAc::checksum
void checksum(void)
Calculate & set the checksum for the current internal state of the remote.
Definition: ir_Vestel.cpp:378
IRVestelAc::setSwing
void setSwing(const bool on)
Set the Swing Roaming setting of the A/C.
Definition: ir_Vestel.cpp:349
IRVestelAc::getSwing
bool getSwing(void) const
Get the Swing Roaming setting of the A/C.
Definition: ir_Vestel.cpp:356
VestelProtocol::OffTenMins
uint64_t OffTenMins
Definition: ir_Vestel.h:50
IRVestelAc::setOffTimer
void setOffTimer(const uint16_t minutes)
Set the Off timer time on the A/C.
Definition: ir_Vestel.cpp:295
VestelProtocol::timeState
uint64_t timeState
Definition: ir_Vestel.h:29
VestelProtocol::OnHours
uint64_t OnHours
Definition: ir_Vestel.h:53
VestelProtocol::TurboSleep
uint64_t TurboSleep
Definition: ir_Vestel.h:36
IRVestelAc::setOnTimerActive
void setOnTimerActive(const bool on)
Set the On timer to be active on the A/C.
Definition: ir_Vestel.cpp:254
IRVestelAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Vestel.cpp:433
IRVestelAc::send
void send(const uint16_t repeat=kNoRepeat)
Send the current internal state as an IR message.
Definition: ir_Vestel.cpp:69
IRVestelAc::off
void off(void)
Set the requested power state of the A/C to off.
Definition: ir_Vestel.cpp:108
kVestelAcFanAutoCool
const uint8_t kVestelAcFanAutoCool
Definition: ir_Vestel.h:85
kVestelAcStateDefault
const uint64_t kVestelAcStateDefault
Definition: ir_Vestel.h:95
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:393
IRVestelAc::setIon
void setIon(const bool on)
Set the Ion (Filter) setting of the A/C.
Definition: ir_Vestel.cpp:336
kVestelAcTolerance
const uint16_t kVestelAcTolerance
Definition: ir_Vestel.h:69
kVestelAcFanLow
const uint8_t kVestelAcFanLow
Definition: ir_Vestel.h:82
VestelProtocol::Mode
uint64_t Mode
Definition: ir_Vestel.h:40
VestelProtocol::Fan
uint64_t Fan
Definition: ir_Vestel.h:39
kVestelAcSwing
const uint8_t kVestelAcSwing
Definition: ir_Vestel.h:92
kVestelAcZeroSpace
const uint16_t kVestelAcZeroSpace
Definition: ir_Vestel.h:68
IRVestelAc::getSleep
bool getSleep(void) const
Get the Sleep setting of the A/C.
Definition: ir_Vestel.cpp:317
kVestelAcTimeStateDefault
const uint64_t kVestelAcTimeStateDefault
Definition: ir_Vestel.h:96
VestelProtocol::OnTenMins
uint64_t OnTenMins
Definition: ir_Vestel.h:52
kVestelAcTurbo
const uint8_t kVestelAcTurbo
Definition: ir_Vestel.h:90
IRVestelAc::calcChecksum
static uint8_t calcChecksum(const uint64_t state)
Calculate the checksum for a given state.
Definition: ir_Vestel.cpp:363
IRVestelAc::getRaw
uint64_t getRaw(void)
Get a copy of the internal state/code for this protocol.
Definition: ir_Vestel.cpp:76
kVestelAcHeat
const uint8_t kVestelAcHeat
Definition: ir_Vestel.h:79
kVestelAcNormal
const uint8_t kVestelAcNormal
Definition: ir_Vestel.h:88
kVestelAcFanHigh
const uint8_t kVestelAcFanHigh
Definition: ir_Vestel.h:84
VestelProtocol::Signature
uint64_t Signature
Definition: ir_Vestel.h:33
IRVestelAc::IRVestelAc
IRVestelAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Vestel.cpp:52
IRVestelAc::getPower
bool getPower(void) const
Get the value of the current power setting.
Definition: ir_Vestel.cpp:119
IRVestelAc
Class for handling detailed Vestel A/C messages.
Definition: ir_Vestel.h:100
kVestelAcCool
const uint8_t kVestelAcCool
Definition: ir_Vestel.h:76
IRVestelAc::_
VestelProtocol _
Definition: ir_Vestel.h:168
VestelProtocol::cmdState
uint64_t cmdState
Definition: ir_Vestel.h:28
IRVestelAc::isTimerActive
bool isTimerActive(void) const
Get if the Timer is active on the A/C.
Definition: ir_Vestel.cpp:213
IRVestelAc::setTimerActive
void setTimerActive(const bool on)
Set the timer to be active on the A/C.
Definition: ir_Vestel.cpp:206
IRVestelAc::setSleep
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition: ir_Vestel.cpp:310
IRVestelAc::getMode
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition: ir_Vestel.cpp:164
VestelProtocol::UseCmd
uint64_t UseCmd
Definition: ir_Vestel.h:45
VestelProtocol::OnTimer
uint64_t OnTimer
Definition: ir_Vestel.h:55
IRVestelAc::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_Vestel.cpp:134
kVestelAcIon
const uint8_t kVestelAcIon
Definition: ir_Vestel.h:91
VestelProtocol::Minutes
uint64_t Minutes
Definition: ir_Vestel.h:58
VestelProtocol::Temp
uint64_t Temp
Definition: ir_Vestel.h:38
IRVestelAc::validChecksum
static bool validChecksum(const uint64_t state)
Verify the checksum is valid for a given state.
Definition: ir_Vestel.cpp:371
IRVestelAc::setAuto
void setAuto(const int8_t autoLevel)
Set Auto mode/level of the A/C.
Definition: ir_Vestel.cpp:188
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:114
kVestelAcFanAuto
const uint8_t kVestelAcFanAuto
Definition: ir_Vestel.h:81
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:406
IRVestelAc::setOnTimer
void setOnTimer(const uint16_t minutes)
Set the On timer time on the A/C.
Definition: ir_Vestel.cpp:267
VestelProtocol::TimeSum
uint64_t TimeSum
Definition: ir_Vestel.h:49
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:49