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 // Ref: https://github.com/crankyoldgit/IRremoteESP8266/files/8646964/Voltas.Window.AC.122LZF.Remote.Instructions.pdf
13
14 #ifndef IR_VOLTAS_H_
15 #define IR_VOLTAS_H_
16
17 #define __STDC_LIMIT_MACROS
18 #include <stdint.h>
19 #ifndef UNIT_TEST
20 #include <Arduino.h>
21 #endif
22 #include "IRremoteESP8266.h"
23 #include "IRsend.h"
24 #ifdef UNIT_TEST
25 #include "IRsend_test.h"
26 #endif
27
29 union VoltasProtocol {
30 uint8_t raw[kVoltasStateLength];
31 struct {
32 // Byte 0
33 uint8_t SwingH :1;
34 uint8_t SwingHChange :7;
35 // Byte 1
36 uint8_t Mode :4;
37 uint8_t :1; // Unknown/Unused
38 uint8_t FanSpeed :3;
39 // Byte 2
40 uint8_t SwingV :3;
41 uint8_t Wifi :1;
42 uint8_t :1; // Unknown/Unused
43 uint8_t Turbo :1;
44 uint8_t Sleep :1;
45 uint8_t Power :1;
46 // Byte 3
47 uint8_t Temp :4;
48 uint8_t :2; // Typically 0b01
49 uint8_t Econo :1;
50 uint8_t TempSet :1;
51 // Byte 4
52 uint8_t OnTimerMins :6; // 0-59
53 uint8_t :1; // Unknown/Unused
54 uint8_t OnTimer12Hr :1; // (Nr of Hours + 1) % 12.
55 // Byte 5
56 uint8_t OffTimerMins :6; // 0-59
57 uint8_t :1; // Unknown/Unused
58 uint8_t OffTimer12Hr :1; // (Nr of Hours + 1) % 12.
59 // Byte 6
60 uint8_t :8; // Typically 0b00111011(0x3B)
61 // Byte 7
62 uint8_t OnTimerHrs :4; // (Nr of Hours + 1) % 12.
63 uint8_t OffTimerHrs :4; // (Nr of Hours + 1) % 12.
64 // Byte 8
65 uint8_t :5; // Typically 0b00000
66 uint8_t Light :1;
67 uint8_t OffTimerEnable :1;
68 uint8_t OnTimerEnable :1;
69 // Byte 9
70 uint8_t Checksum :8;
71 };
72 };
73
74 // Constants
75 const uint8_t kVoltasFan = 0b0001;
76 const uint8_t kVoltasHeat = 0b0010;
77 const uint8_t kVoltasDry = 0b0100;
78 const uint8_t kVoltasCool = 0b1000;
79 const uint8_t kVoltasMinTemp = 16;
80 const uint8_t kVoltasDryTemp = 24;
81 const uint8_t kVoltasMaxTemp = 30;
82 const uint8_t kVoltasFanHigh = 0b001;
83 const uint8_t kVoltasFanMed = 0b010;
84 const uint8_t kVoltasFanLow = 0b100;
85 const uint8_t kVoltasFanAuto = 0b111;
86 const uint8_t kVoltasSwingHChange = 0b1111100;
87 const uint8_t kVoltasSwingHNoChange = 0b0011001;
88
89 // Classes
91 class IRVoltas {
92 public:
93 explicit IRVoltas(const uint16_t pin, const bool inverted = false,
94 const bool use_modulation = true);
95 void stateReset();
96 #if SEND_VOLTAS
97 void send(const uint16_t repeat = kNoRepeat);
102 int8_t calibrate(void) { return _irsend.calibrate(); }
103 #endif // SEND_VOLTAS
104 void begin();
105 static bool validChecksum(const uint8_t state[],
106 const uint16_t length = kVoltasStateLength);
107 void setModel(const voltas_ac_remote_model_t model);
108 voltas_ac_remote_model_t getModel(const bool raw = false) const;
109 void setPower(const bool on);
110 bool getPower(void) const;
111 void on(void);
112 void off(void);
113 void setWifi(const bool on);
114 bool getWifi(void) const;
115 void setTemp(const uint8_t temp);
116 uint8_t getTemp(void);
117 void setFan(const uint8_t speed);
118 uint8_t getFan(void);
119 void setMode(const uint8_t mode);
120 uint8_t getMode(void);
121 void setSwingH(const bool on);
122 bool getSwingH(void) const;
123 void setSwingHChange(const bool on);
124 bool getSwingHChange(void) const;
125 void setSwingV(const bool on);
126 bool getSwingV(void) const;
127 void setEcono(const bool on);
128 bool getEcono(void) const;
129 void setLight(const bool on);
130 bool getLight(void) const;
131 void setTurbo(const bool on);
132 bool getTurbo(void) const;
133 void setSleep(const bool on);
134 bool getSleep(void) const;
135 uint16_t getOnTime(void) const;
136 void setOnTime(const uint16_t nr_of_mins);
137 uint16_t getOffTime(void) const;
138 void setOffTime(const uint16_t nr_of_mins);
139 uint8_t* getRaw(void);
140 void setRaw(const uint8_t new_code[]);
141 uint8_t convertMode(const stdAc::opmode_t mode);
142 uint8_t convertFan(const stdAc::fanspeed_t speed);
143 static stdAc::opmode_t toCommonMode(const uint8_t mode);
144 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
145 stdAc::state_t toCommon(const stdAc::state_t *prev = NULL);
146 String toString(void);
147 #ifndef UNIT_TEST
148
149 private:
150 IRsend _irsend;
151 #else
152 IRsendTest _irsend;
154 #endif
156 VoltasProtocol _;
157 voltas_ac_remote_model_t _model;
158 void checksum(void);
159 static uint8_t calcChecksum(const uint8_t state[],
160 const uint16_t length = kVoltasStateLength);
161 };
162 #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:47
kVoltasFan
const uint8_t kVoltasFan
1
Definition: ir_Voltas.h:75
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:36
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:61
VoltasProtocol::OnTimerMins
uint8_t OnTimerMins
Definition: ir_Voltas.h:52
IRVoltas::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Voltas.cpp:301
VoltasProtocol::Wifi
uint8_t Wifi
Definition: ir_Voltas.h:41
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:83
kVoltasSwingHNoChange
const uint8_t kVoltasSwingHNoChange
0x19
Definition: ir_Voltas.h:87
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:33
IRVoltas
Class for handling detailed Voltas A/C messages.
Definition: ir_Voltas.h:91
VoltasProtocol
Native representation of a Voltas A/C message.
Definition: ir_Voltas.h:29
kVoltasFanAuto
const uint8_t kVoltasFanAuto
7
Definition: ir_Voltas.h:85
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
IRVoltas::_model
voltas_ac_remote_model_t _model
Model type.
Definition: ir_Voltas.h:157
kVoltasStateLength
const uint16_t kVoltasStateLength
Definition: IRremoteESP8266.h:1427
VoltasProtocol::SwingV
uint8_t SwingV
Definition: ir_Voltas.h:40
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:66
VoltasProtocol::OffTimerMins
uint8_t OffTimerMins
Definition: ir_Voltas.h:56
String
std::string String
Definition: IRremoteESP8266.h:1521
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:49
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:67
VoltasProtocol::OffTimer12Hr
uint8_t OffTimer12Hr
Definition: ir_Voltas.h:58
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:1145
kVoltasHeat
const uint8_t kVoltasHeat
2
Definition: ir_Voltas.h:76
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 equivalent.
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:63
IRVoltas::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Voltas.h:150
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:38
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:62
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:43
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:45
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:68
kVoltasMaxTemp
const uint8_t kVoltasMaxTemp
Celsius.
Definition: ir_Voltas.h:81
kVoltasDry
const uint8_t kVoltasDry
4
Definition: ir_Voltas.h:77
VoltasProtocol::raw
uint8_t raw[kVoltasStateLength]
The state in native IR code form.
Definition: ir_Voltas.h:30
VoltasProtocol::TempSet
uint8_t TempSet
Definition: ir_Voltas.h:50
VoltasProtocol::Checksum
uint8_t Checksum
Definition: ir_Voltas.h:70
kVoltasSwingHChange
const uint8_t kVoltasSwingHChange
0x7D
Definition: ir_Voltas.h:86
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:79
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:80
IRVoltas::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
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:82
IRVoltas::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Voltas.h:102
VoltasProtocol::Sleep
uint8_t Sleep
Definition: ir_Voltas.h:44
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:54
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:84
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:78
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:156
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:114
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:205
VoltasProtocol::SwingHChange
uint8_t SwingHChange
Definition: ir_Voltas.h:34
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:49