IRremoteESP8266
ir_Voltas.h
Go to the documentation of this file.
1 // Copyright 2020 David Conran (crankyoldgit)
2 // Copyright 2020 manj9501
6 
7 // Supports:
8 // Brand: Voltas, Model: 122LZF 4011252 Window A/C
9 //
10 // Ref: https://docs.google.com/spreadsheets/d/1zzDEUQ52y7MZ7_xCU3pdjdqbRXOwZLsbTGvKWcicqCI/
11 // Ref: https://www.corona.co.jp/box/download.php?id=145060636229
12 
13 #ifndef IR_VOLTAS_H_
14 #define IR_VOLTAS_H_
15 
16 #define __STDC_LIMIT_MACROS
17 #include <stdint.h>
18 #ifndef UNIT_TEST
19 #include <Arduino.h>
20 #endif
21 #include "IRremoteESP8266.h"
22 #include "IRsend.h"
23 #ifdef UNIT_TEST
24 #include "IRsend_test.h"
25 #endif
26 
27 
30  struct {
31  // Byte 0
32  uint8_t SwingH :1;
33  uint8_t SwingHChange :7;
34  // Byte 1
35  uint8_t Mode :4;
36  uint8_t :1; // Unknown/Unused
37  uint8_t FanSpeed :3;
38  // Byte 2
39  uint8_t SwingV :3;
40  uint8_t Wifi :1;
41  uint8_t :1; // Unknown/Unused
42  uint8_t Turbo :1;
43  uint8_t Sleep :1;
44  uint8_t Power :1;
45  // Byte 3
46  uint8_t Temp :4;
47  uint8_t :2; // Typically 0b01
48  uint8_t Econo :1;
49  uint8_t TempSet :1;
50  // Byte 4
51  uint8_t OnTimerMins :6; // 0-59
52  uint8_t :1; // Unknown/Unused
53  uint8_t OnTimer12Hr :1; // (Nr of Hours + 1) % 12.
54  // Byte 5
55  uint8_t OffTimerMins :6; // 0-59
56  uint8_t :1; // Unknown/Unused
57  uint8_t OffTimer12Hr :1; // (Nr of Hours + 1) % 12.
58  // Byte 6
59  uint8_t :8; // Typically 0b00111011(0x3B)
60  // Byte 7
61  uint8_t OnTimerHrs :4; // (Nr of Hours + 1) % 12.
62  uint8_t OffTimerHrs :4; // (Nr of Hours + 1) % 12.
63  // Byte 8
64  uint8_t :5; // Typically 0b00000
65  uint8_t Light :1;
66  uint8_t OffTimerEnable :1;
67  uint8_t OnTimerEnable :1;
68  // Byte 9
69  uint8_t Checksum :8;
70  };
71 };
72 
73 // Constants
74 const uint8_t kVoltasFan = 0b0001;
75 const uint8_t kVoltasHeat = 0b0010;
76 const uint8_t kVoltasDry = 0b0100;
77 const uint8_t kVoltasCool = 0b1000;
78 const uint8_t kVoltasMinTemp = 16;
79 const uint8_t kVoltasDryTemp = 24;
80 const uint8_t kVoltasMaxTemp = 30;
81 const uint8_t kVoltasFanHigh = 0b001;
82 const uint8_t kVoltasFanMed = 0b010;
83 const uint8_t kVoltasFanLow = 0b100;
84 const uint8_t kVoltasFanAuto = 0b111;
85 const uint8_t kVoltasSwingHChange = 0b1111100;
86 const uint8_t kVoltasSwingHNoChange = 0b0011001;
87 
88 // Classes
90 class IRVoltas {
91  public:
92  explicit IRVoltas(const uint16_t pin, const bool inverted = false,
93  const bool use_modulation = true);
94  void stateReset();
95 #if SEND_VOLTAS
96  void send(const uint16_t repeat = kNoRepeat);
101  int8_t calibrate(void) { return _irsend.calibrate(); }
102 #endif // SEND_VOLTAS
103  void begin();
104  static bool validChecksum(const uint8_t state[],
105  const uint16_t length = kVoltasStateLength);
106  void setModel(const voltas_ac_remote_model_t model);
107  voltas_ac_remote_model_t getModel(const bool raw = false) const;
108  void setPower(const bool on);
109  bool getPower(void) const;
110  void on(void);
111  void off(void);
112  void setWifi(const bool on);
113  bool getWifi(void) const;
114  void setTemp(const uint8_t temp);
115  uint8_t getTemp(void);
116  void setFan(const uint8_t speed);
117  uint8_t getFan(void);
118  void setMode(const uint8_t mode);
119  uint8_t getMode(void);
120  void setSwingH(const bool on);
121  bool getSwingH(void) const;
122  void setSwingHChange(const bool on);
123  bool getSwingHChange(void) const;
124  void setSwingV(const bool on);
125  bool getSwingV(void) const;
126  void setEcono(const bool on);
127  bool getEcono(void) const;
128  void setLight(const bool on);
129  bool getLight(void) const;
130  void setTurbo(const bool on);
131  bool getTurbo(void) const;
132  void setSleep(const bool on);
133  bool getSleep(void) const;
134  uint16_t getOnTime(void) const;
135  void setOnTime(const uint16_t nr_of_mins);
136  uint16_t getOffTime(void) const;
137  void setOffTime(const uint16_t nr_of_mins);
138  uint8_t* getRaw(void);
139  void setRaw(const uint8_t new_code[]);
140  uint8_t convertMode(const stdAc::opmode_t mode);
141  uint8_t convertFan(const stdAc::fanspeed_t speed);
142  static stdAc::opmode_t toCommonMode(const uint8_t mode);
143  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
144  stdAc::state_t toCommon(const stdAc::state_t *prev = NULL);
145  String toString(void);
146 #ifndef UNIT_TEST
147 
148  private:
150 #else
151  IRsendTest _irsend;
153 #endif
157  void checksum(void);
158  static uint8_t calcChecksum(const uint8_t state[],
159  const uint16_t length = kVoltasStateLength);
160 };
161 #endif // IR_VOLTAS_H_
IRVoltas::setOnTime
void setOnTime(const uint16_t nr_of_mins)
Set the value of the On Timer time.
Definition: ir_Voltas.cpp:423
IRVoltas::getTemp
uint8_t getTemp(void)
Get the current temperature setting.
Definition: ir_Voltas.cpp:258
VoltasProtocol::Temp
uint8_t Temp
Definition: ir_Voltas.h:46
kVoltasFan
const uint8_t kVoltasFan
1
Definition: ir_Voltas.h:74
IRVoltas::getFan
uint8_t getFan(void)
Get the current fan speed setting.
Definition: ir_Voltas.cpp:282
VoltasProtocol::Mode
uint8_t Mode
Definition: ir_Voltas.h:35
IRVoltas::getOnTime
uint16_t getOnTime(void) const
Get the value of the On Timer time.
Definition: ir_Voltas.cpp:415
IRVoltas::getEcono
bool getEcono(void) const
Get the value of the current Econo setting.
Definition: ir_Voltas.cpp:389
IRVoltas::getMode
uint8_t getMode(void)
Get the operating mode setting of the A/C.
Definition: ir_Voltas.cpp:222
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
VoltasProtocol::OnTimerMins
uint8_t OnTimerMins
Definition: ir_Voltas.h:51
IRVoltas::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivilant.
Definition: ir_Voltas.cpp:301
VoltasProtocol::Wifi
uint8_t Wifi
Definition: ir_Voltas.h:40
IRVoltas::getSwingHChange
bool getSwingHChange(void) const
Are the Horizontal Swing change bits set in the message?
Definition: ir_Voltas.cpp:351
kVoltasFanMed
const uint8_t kVoltasFanMed
2
Definition: ir_Voltas.h:82
kVoltasSwingHNoChange
const uint8_t kVoltasSwingHNoChange
0x19
Definition: ir_Voltas.h:86
IRsend.h
IRVoltas::convertMode
uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Voltas.cpp:227
VoltasProtocol::SwingH
uint8_t SwingH
Definition: ir_Voltas.h:32
IRVoltas
Class for handling detailed Voltas A/C messages.
Definition: ir_Voltas.h:90
VoltasProtocol
Definition: ir_Voltas.h:28
kVoltasFanAuto
const uint8_t kVoltasFanAuto
7
Definition: ir_Voltas.h:84
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:176
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
IRVoltas::_model
voltas_ac_remote_model_t _model
Model type.
Definition: ir_Voltas.h:156
kVoltasStateLength
const uint16_t kVoltasStateLength
Definition: IRremoteESP8266.h:1046
VoltasProtocol::SwingV
uint8_t SwingV
Definition: ir_Voltas.h:39
IRVoltas::off
void off(void)
Change the power setting to Off.
Definition: ir_Voltas.cpp:184
VoltasProtocol::Light
uint8_t Light
Definition: ir_Voltas.h:65
VoltasProtocol::OffTimerMins
uint8_t OffTimerMins
Definition: ir_Voltas.h:55
String
std::string String
Definition: IRremoteESP8266.h:1128
IRVoltas::convertFan
uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Voltas.cpp:287
IRVoltas::setSleep
void setSleep(const bool on)
Change the Sleep setting.
Definition: ir_Voltas.cpp:402
IRVoltas::getWifi
bool getWifi(void) const
Get the value of the current Wifi setting.
Definition: ir_Voltas.cpp:361
IRVoltas::IRVoltas
IRVoltas(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Voltas.cpp:87
IRVoltas::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Voltas.cpp:262
VoltasProtocol::Econo
uint8_t Econo
Definition: ir_Voltas.h:48
IRVoltas::on
void on(void)
Change the power setting to On.
Definition: ir_Voltas.cpp:181
IRremoteESP8266.h
IRVoltas::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Voltas.cpp:188
VoltasProtocol::OffTimerEnable
uint8_t OffTimerEnable
Definition: ir_Voltas.h:66
VoltasProtocol::OffTimer12Hr
uint8_t OffTimer12Hr
Definition: ir_Voltas.h:57
IRVoltas::getSwingV
bool getSwingV(void) const
Get the Vertical Swing setting of the A/C.
Definition: ir_Voltas.cpp:316
kNoRepeat
const uint16_t kNoRepeat
Definition: IRremoteESP8266.h:835
kVoltasHeat
const uint8_t kVoltasHeat
2
Definition: ir_Voltas.h:75
IRVoltas::setSwingV
void setSwingV(const bool on)
Set the Vertical Swing setting of the A/C.
Definition: ir_Voltas.cpp:312
IRVoltas::toCommon
stdAc::state_t toCommon(const stdAc::state_t *prev=NULL)
Convert the current internal state into its stdAc::state_t equivilant.
Definition: ir_Voltas.cpp:456
IRVoltas::setTemp
void setTemp(const uint8_t temp)
Set the temperature.
Definition: ir_Voltas.cpp:250
IRVoltas::setRaw
void setRaw(const uint8_t new_code[])
Set the internal state from a valid code for this protocol.
Definition: ir_Voltas.cpp:150
VoltasProtocol::OffTimerHrs
uint8_t OffTimerHrs
Definition: ir_Voltas.h:62
IRVoltas::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Voltas.h:149
IRVoltas::setTurbo
void setTurbo(const bool on)
Change the Turbo setting.
Definition: ir_Voltas.cpp:366
VoltasProtocol::FanSpeed
uint8_t FanSpeed
Definition: ir_Voltas.h:37
IRVoltas::begin
void begin()
Set up hardware to be able to send a message.
Definition: ir_Voltas.cpp:103
VoltasProtocol::OnTimerHrs
uint8_t OnTimerHrs
Definition: ir_Voltas.h:61
IRVoltas::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Voltas.cpp:197
VoltasProtocol::Turbo
uint8_t Turbo
Definition: ir_Voltas.h:42
IRVoltas::setSwingH
void setSwingH(const bool on)
Set the Horizontal Swing setting of the A/C.
Definition: ir_Voltas.cpp:320
IRVoltas::setWifi
void setWifi(const bool on)
Change the Wifi setting.
Definition: ir_Voltas.cpp:357
IRVoltas::setSwingHChange
void setSwingHChange(const bool on)
Set the bits for changing the Horizontal Swing setting of the A/C.
Definition: ir_Voltas.cpp:344
VoltasProtocol::Power
uint8_t Power
Definition: ir_Voltas.h:44
IRVoltas::getOffTime
uint16_t getOffTime(void) const
Get the value of the On Timer time.
Definition: ir_Voltas.cpp:435
IRVoltas::toString
String toString(void)
Convert the current internal state into a human readable string.
Definition: ir_Voltas.cpp:491
IRVoltas::setModel
void setModel(const voltas_ac_remote_model_t model)
Set the current model for the remote.
Definition: ir_Voltas.cpp:131
IRVoltas::stateReset
void stateReset()
Definition: ir_Voltas.cpp:94
IRVoltas::setEcono
void setEcono(const bool on)
Change the Economy setting.
Definition: ir_Voltas.cpp:380
VoltasProtocol::OnTimerEnable
uint8_t OnTimerEnable
Definition: ir_Voltas.h:67
kVoltasMaxTemp
const uint8_t kVoltasMaxTemp
Celsius.
Definition: ir_Voltas.h:80
kVoltasDry
const uint8_t kVoltasDry
4
Definition: ir_Voltas.h:76
VoltasProtocol::raw
uint8_t raw[kVoltasStateLength]
The state in native IR code form.
Definition: ir_Voltas.h:29
VoltasProtocol::TempSet
uint8_t TempSet
Definition: ir_Voltas.h:49
VoltasProtocol::Checksum
uint8_t Checksum
Definition: ir_Voltas.h:69
kVoltasSwingHChange
const uint8_t kVoltasSwingHChange
0x7D
Definition: ir_Voltas.h:85
IRVoltas::calcChecksum
static uint8_t calcChecksum(const uint8_t state[], const uint16_t length=kVoltasStateLength)
Calculate the checksum is valid for a given state.
Definition: ir_Voltas.cpp:173
kVoltasMinTemp
const uint8_t kVoltasMinTemp
Celsius.
Definition: ir_Voltas.h:78
IRVoltas::checksum
void checksum(void)
Calculate and set the checksum values for the internal state.
Definition: ir_Voltas.cpp:156
kVoltasDryTemp
const uint8_t kVoltasDryTemp
Celsius.
Definition: ir_Voltas.h:79
IRVoltas::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivilant.
Definition: ir_Voltas.cpp:239
IRVoltas::send
void send(const uint16_t repeat=kNoRepeat)
Send the current internal state as an IR message.
Definition: ir_Voltas.cpp:108
kVoltasFanHigh
const uint8_t kVoltasFanHigh
1
Definition: ir_Voltas.h:81
IRVoltas::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Voltas.h:101
VoltasProtocol::Sleep
uint8_t Sleep
Definition: ir_Voltas.h:43
IRVoltas::getSwingH
bool getSwingH(void) const
Get the Horizontal Swing setting of the A/C.
Definition: ir_Voltas.cpp:332
IRVoltas::setOffTime
void setOffTime(const uint16_t nr_of_mins)
Set the value of the Off Timer time.
Definition: ir_Voltas.cpp:443
VoltasProtocol::OnTimer12Hr
uint8_t OnTimer12Hr
Definition: ir_Voltas.h:53
IRVoltas::validChecksum
static bool validChecksum(const uint8_t state[], const uint16_t length=kVoltasStateLength)
Verify the checksum is valid for a given state.
Definition: ir_Voltas.cpp:164
kVoltasFanLow
const uint8_t kVoltasFanLow
4
Definition: ir_Voltas.h:83
IRVoltas::getSleep
bool getSleep(void) const
Get the value of the current Sleep setting.
Definition: ir_Voltas.cpp:411
kVoltasCool
const uint8_t kVoltasCool
8
Definition: ir_Voltas.h:77
IRVoltas::getPower
bool getPower(void) const
Get the value of the current power setting.
Definition: ir_Voltas.cpp:192
IRVoltas::getRaw
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol.
Definition: ir_Voltas.cpp:143
IRVoltas::_
VoltasProtocol _
The state of the IR remote.
Definition: ir_Voltas.h:155
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
IRVoltas::getLight
bool getLight(void) const
Get the value of the current Light setting.
Definition: ir_Voltas.cpp:397
IRVoltas::setLight
void setLight(const bool on)
Change the Light setting.
Definition: ir_Voltas.cpp:393
IRVoltas::getModel
voltas_ac_remote_model_t getModel(const bool raw=false) const
Get the model information currently known.
Definition: ir_Voltas.cpp:116
IRVoltas::getTurbo
bool getTurbo(void) const
Get the value of the current Turbo setting.
Definition: ir_Voltas.cpp:375
voltas_ac_remote_model_t
voltas_ac_remote_model_t
Voltas A/C model numbers.
Definition: IRsend.h:152
VoltasProtocol::SwingHChange
uint8_t SwingHChange
Definition: ir_Voltas.h:33
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46