IRremoteESP8266
Loading...
Searching...
No Matches
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
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
75const uint8_t kVoltasFan = 0b0001;
76const uint8_t kVoltasHeat = 0b0010;
77const uint8_t kVoltasDry = 0b0100;
78const uint8_t kVoltasCool = 0b1000;
79const uint8_t kVoltasMinTemp = 16;
80const uint8_t kVoltasDryTemp = 24;
81const uint8_t kVoltasMaxTemp = 30;
82const uint8_t kVoltasFanHigh = 0b001;
83const uint8_t kVoltasFanMed = 0b010;
84const uint8_t kVoltasFanLow = 0b100;
85const uint8_t kVoltasFanAuto = 0b111;
86const uint8_t kVoltasSwingHChange = 0b1111100;
87const uint8_t kVoltasSwingHNoChange = 0b0011001;
88
89// Classes
91class 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:
151#else
153 IRsendTest _irsend;
155#endif
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_
const uint16_t kNoRepeat
Definition IRremoteESP8266.h:1172
const uint16_t kVoltasStateLength
Definition IRremoteESP8266.h:1457
std::string String
Definition IRremoteESP8266.h:1564
voltas_ac_remote_model_t
Voltas A/C model numbers.
Definition IRsend.h:205
Class for handling detailed Voltas A/C messages.
Definition ir_Voltas.h:91
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
voltas_ac_remote_model_t _model
Model type.
Definition ir_Voltas.h:157
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition ir_Voltas.cpp:262
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
void stateReset()
Definition ir_Voltas.cpp:94
IRsend _irsend
Instance of the IR send class.
Definition ir_Voltas.h:150
void setEcono(const bool on)
Change the Economy setting.
Definition ir_Voltas.cpp:380
void setPower(const bool on)
Change the power setting.
Definition ir_Voltas.cpp:188
bool getTurbo(void) const
Get the value of the current Turbo setting.
Definition ir_Voltas.cpp:375
bool getWifi(void) const
Get the value of the current Wifi setting.
Definition ir_Voltas.cpp:361
void begin()
Set up hardware to be able to send a message.
Definition ir_Voltas.cpp:103
bool getSwingV(void) const
Get the Vertical Swing setting of the A/C.
Definition ir_Voltas.cpp:316
VoltasProtocol _
The state of the IR remote.
Definition ir_Voltas.h:156
void setOnTime(const uint16_t nr_of_mins)
Set the value of the On Timer time.
Definition ir_Voltas.cpp:423
uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition ir_Voltas.cpp:227
void setTemp(const uint8_t temp)
Set the temperature.
Definition ir_Voltas.cpp:250
void setWifi(const bool on)
Change the Wifi setting.
Definition ir_Voltas.cpp:357
void off(void)
Change the power setting to Off.
Definition ir_Voltas.cpp:184
bool getSleep(void) const
Get the value of the current Sleep setting.
Definition ir_Voltas.cpp:411
void setRaw(const uint8_t new_code[])
Set the internal state from a valid code for this protocol.
Definition ir_Voltas.cpp:150
void setSwingH(const bool on)
Set the Horizontal Swing setting of the A/C.
Definition ir_Voltas.cpp:320
void setSleep(const bool on)
Change the Sleep setting.
Definition ir_Voltas.cpp:402
voltas_ac_remote_model_t getModel(const bool raw=false) const
Get the model information currently known.
Definition ir_Voltas.cpp:116
bool getSwingH(void) const
Get the Horizontal Swing setting of the A/C.
Definition ir_Voltas.cpp:332
bool getEcono(void) const
Get the value of the current Econo setting.
Definition ir_Voltas.cpp:389
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
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition ir_Voltas.cpp:301
uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition ir_Voltas.cpp:287
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol.
Definition ir_Voltas.cpp:143
void on(void)
Change the power setting to On.
Definition ir_Voltas.cpp:181
uint8_t getTemp(void)
Get the current temperature setting.
Definition ir_Voltas.cpp:258
uint16_t getOnTime(void) const
Get the value of the On Timer time.
Definition ir_Voltas.cpp:415
uint16_t getOffTime(void) const
Get the value of the On Timer time.
Definition ir_Voltas.cpp:435
void setModel(const voltas_ac_remote_model_t model)
Set the current model for the remote.
Definition ir_Voltas.cpp:131
bool getLight(void) const
Get the value of the current Light setting.
Definition ir_Voltas.cpp:397
void send(const uint16_t repeat=kNoRepeat)
Send the current internal state as an IR message.
Definition ir_Voltas.cpp:108
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition ir_Voltas.h:102
void setTurbo(const bool on)
Change the Turbo setting.
Definition ir_Voltas.cpp:366
bool getSwingHChange(void) const
Are the Horizontal Swing change bits set in the message?
Definition ir_Voltas.cpp:351
void checksum(void)
Calculate and set the checksum values for the internal state.
Definition ir_Voltas.cpp:156
uint8_t getMode(void)
Get the operating mode setting of the A/C.
Definition ir_Voltas.cpp:222
void setSwingHChange(const bool on)
Set the bits for changing the Horizontal Swing setting of the A/C.
Definition ir_Voltas.cpp:344
void setOffTime(const uint16_t nr_of_mins)
Set the value of the Off Timer time.
Definition ir_Voltas.cpp:443
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition ir_Voltas.cpp:239
bool getPower(void) const
Get the value of the current power setting.
Definition ir_Voltas.cpp:192
void setLight(const bool on)
Change the Light setting.
Definition ir_Voltas.cpp:393
String toString(void)
Convert the current internal state into a human readable string.
Definition ir_Voltas.cpp:491
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition ir_Voltas.cpp:197
uint8_t getFan(void)
Get the current fan speed setting.
Definition ir_Voltas.cpp:282
void setSwingV(const bool on)
Set the Vertical Swing setting of the A/C.
Definition ir_Voltas.cpp:312
Class for sending all basic IR protocols.
Definition IRsend.h:249
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition IRsend.cpp:209
const uint8_t kVoltasFanMed
2
Definition ir_Voltas.h:83
const uint8_t kVoltasMaxTemp
Celsius.
Definition ir_Voltas.h:81
const uint8_t kVoltasDry
4
Definition ir_Voltas.h:77
const uint8_t kVoltasFanLow
4
Definition ir_Voltas.h:84
const uint8_t kVoltasFan
1
Definition ir_Voltas.h:75
const uint8_t kVoltasCool
8
Definition ir_Voltas.h:78
const uint8_t kVoltasFanAuto
7
Definition ir_Voltas.h:85
const uint8_t kVoltasFanHigh
1
Definition ir_Voltas.h:82
const uint8_t kVoltasMinTemp
Celsius.
Definition ir_Voltas.h:79
const uint8_t kVoltasSwingHChange
0x7D
Definition ir_Voltas.h:86
const uint8_t kVoltasHeat
2
Definition ir_Voltas.h:76
const uint8_t kVoltasDryTemp
Celsius.
Definition ir_Voltas.h:80
const uint8_t kVoltasSwingHNoChange
0x19
Definition ir_Voltas.h:87
fanspeed_t
Common A/C settings for Fan Speeds.
Definition IRsend.h:61
opmode_t
Common A/C settings for A/C operating modes.
Definition IRsend.h:49
Structure to hold a common A/C state.
Definition IRsend.h:114
Native representation of a Voltas A/C message.
Definition ir_Voltas.h:29
uint8_t TempSet
Definition ir_Voltas.h:50
uint8_t Sleep
Definition ir_Voltas.h:44
uint8_t Temp
Definition ir_Voltas.h:47
uint8_t OffTimerMins
Definition ir_Voltas.h:56
uint8_t OnTimerEnable
Definition ir_Voltas.h:68
uint8_t SwingHChange
Definition ir_Voltas.h:34
uint8_t OnTimerMins
Definition ir_Voltas.h:52
uint8_t OffTimerEnable
Definition ir_Voltas.h:67
uint8_t Checksum
Definition ir_Voltas.h:70
uint8_t Econo
Definition ir_Voltas.h:49
uint8_t SwingH
Definition ir_Voltas.h:33
uint8_t Power
Definition ir_Voltas.h:45
uint8_t OnTimer12Hr
Definition ir_Voltas.h:54
uint8_t OffTimer12Hr
Definition ir_Voltas.h:58
uint8_t FanSpeed
Definition ir_Voltas.h:38
uint8_t Light
Definition ir_Voltas.h:66
uint8_t Turbo
Definition ir_Voltas.h:43
uint8_t Wifi
Definition ir_Voltas.h:41
uint8_t SwingV
Definition ir_Voltas.h:40
uint8_t OnTimerHrs
Definition ir_Voltas.h:62
uint8_t Mode
Definition ir_Voltas.h:36
uint8_t OffTimerHrs
Definition ir_Voltas.h:63
uint8_t raw[kVoltasStateLength]
The state in native IR code form.
Definition ir_Voltas.h:30