IRremoteIDF
Infrared send & receive for ESP-IDF
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#include "IRplatform.h"
20#include "IRremoteESP8266.h"
21#include "IRsend.h"
22#ifdef UNIT_TEST
23#include "IRsend_test.h"
24#endif
25
29 struct {
30 // Byte 0
31 uint8_t SwingH :1;
32 uint8_t SwingHChange :7;
33 // Byte 1
34 uint8_t Mode :4;
35 uint8_t :1; // Unknown/Unused
36 uint8_t FanSpeed :3;
37 // Byte 2
38 uint8_t SwingV :3;
39 uint8_t Wifi :1;
40 uint8_t :1; // Unknown/Unused
41 uint8_t Turbo :1;
42 uint8_t Sleep :1;
43 uint8_t Power :1;
44 // Byte 3
45 uint8_t Temp :4;
46 uint8_t :2; // Typically 0b01
47 uint8_t Econo :1;
48 uint8_t TempSet :1;
49 // Byte 4
50 uint8_t OnTimerMins :6; // 0-59
51 uint8_t :1; // Unknown/Unused
52 uint8_t OnTimer12Hr :1; // (Nr of Hours + 1) % 12.
53 // Byte 5
54 uint8_t OffTimerMins :6; // 0-59
55 uint8_t :1; // Unknown/Unused
56 uint8_t OffTimer12Hr :1; // (Nr of Hours + 1) % 12.
57 // Byte 6
58 uint8_t :8; // Typically 0b00111011(0x3B)
59 // Byte 7
60 uint8_t OnTimerHrs :4; // (Nr of Hours + 1) % 12.
61 uint8_t OffTimerHrs :4; // (Nr of Hours + 1) % 12.
62 // Byte 8
63 uint8_t :5; // Typically 0b00000
64 uint8_t Light :1;
65 uint8_t OffTimerEnable :1;
66 uint8_t OnTimerEnable :1;
67 // Byte 9
68 uint8_t Checksum :8;
69 };
70};
71
72// Constants
73const uint8_t kVoltasFan = 0b0001;
74const uint8_t kVoltasHeat = 0b0010;
75const uint8_t kVoltasDry = 0b0100;
76const uint8_t kVoltasCool = 0b1000;
77const uint8_t kVoltasMinTemp = 16;
78const uint8_t kVoltasDryTemp = 24;
79const uint8_t kVoltasMaxTemp = 30;
80const uint8_t kVoltasFanHigh = 0b001;
81const uint8_t kVoltasFanMed = 0b010;
82const uint8_t kVoltasFanLow = 0b100;
83const uint8_t kVoltasFanAuto = 0b111;
84const uint8_t kVoltasSwingHChange = 0b1111100;
85const uint8_t kVoltasSwingHNoChange = 0b0011001;
86
87// Classes
89class IRVoltas {
90 public:
91 explicit IRVoltas(const uint16_t pin, const bool inverted = false,
92 const bool use_modulation = true);
93 void stateReset();
94#if SEND_VOLTAS
95 void send(const uint16_t repeat = kNoRepeat);
100 int8_t calibrate(void) { return _irsend.calibrate(); }
101#endif // SEND_VOLTAS
102 void begin();
103 static bool validChecksum(const uint8_t state[],
104 const uint16_t length = kVoltasStateLength);
105 void setModel(const voltas_ac_remote_model_t model);
106 voltas_ac_remote_model_t getModel(const bool raw = false) const;
107 void setPower(const bool on);
108 bool getPower(void) const;
109 void on(void);
110 void off(void);
111 void setWifi(const bool on);
112 bool getWifi(void) const;
113 void setTemp(const uint8_t temp);
114 uint8_t getTemp(void);
115 void setFan(const uint8_t speed);
116 uint8_t getFan(void);
117 void setMode(const uint8_t mode);
118 uint8_t getMode(void);
119 void setSwingH(const bool on);
120 bool getSwingH(void) const;
121 void setSwingHChange(const bool on);
122 bool getSwingHChange(void) const;
123 void setSwingV(const bool on);
124 bool getSwingV(void) const;
125 void setEcono(const bool on);
126 bool getEcono(void) const;
127 void setLight(const bool on);
128 bool getLight(void) const;
129 void setTurbo(const bool on);
130 bool getTurbo(void) const;
131 void setSleep(const bool on);
132 bool getSleep(void) const;
133 uint16_t getOnTime(void) const;
134 void setOnTime(const uint16_t nr_of_mins);
135 uint16_t getOffTime(void) const;
136 void setOffTime(const uint16_t nr_of_mins);
137 uint8_t* getRaw(void);
138 void setRaw(const uint8_t new_code[]);
139 uint8_t convertMode(const stdAc::opmode_t mode);
140 uint8_t convertFan(const stdAc::fanspeed_t speed);
141 static stdAc::opmode_t toCommonMode(const uint8_t mode);
142 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
143 stdAc::state_t toCommon(const stdAc::state_t *prev = NULL);
144 String toString(void);
145#ifndef UNIT_TEST
146
147 private:
149#else
151 IRsendTest _irsend;
153#endif
156 void checksum(void);
157 static uint8_t calcChecksum(const uint8_t state[],
158 const uint16_t length = kVoltasStateLength);
159};
160#endif // IR_VOLTAS_H_
std::string String
The protocol code builds human readable output with String. On ESP-IDF that is just std::string.
Definition IRplatform.h:21
const uint16_t kNoRepeat
Definition IRremoteESP8266.h:1171
const uint16_t kVoltasStateLength
Definition IRremoteESP8266.h:1456
voltas_ac_remote_model_t
Voltas A/C model numbers.
Definition IRsend.h:211
Class for handling detailed Voltas A/C messages.
Definition ir_Voltas.h:89
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:155
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:148
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:154
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:100
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:256
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition IRsend.cpp:286
const uint8_t kVoltasFanMed
2
Definition ir_Voltas.h:81
const uint8_t kVoltasMaxTemp
Celsius.
Definition ir_Voltas.h:79
const uint8_t kVoltasDry
4
Definition ir_Voltas.h:75
const uint8_t kVoltasFanLow
4
Definition ir_Voltas.h:82
const uint8_t kVoltasFan
1
Definition ir_Voltas.h:73
const uint8_t kVoltasCool
8
Definition ir_Voltas.h:76
const uint8_t kVoltasFanAuto
7
Definition ir_Voltas.h:83
const uint8_t kVoltasFanHigh
1
Definition ir_Voltas.h:80
const uint8_t kVoltasMinTemp
Celsius.
Definition ir_Voltas.h:77
const uint8_t kVoltasSwingHChange
0x7D
Definition ir_Voltas.h:84
const uint8_t kVoltasHeat
2
Definition ir_Voltas.h:74
const uint8_t kVoltasDryTemp
Celsius.
Definition ir_Voltas.h:78
const uint8_t kVoltasSwingHNoChange
0x19
Definition ir_Voltas.h:85
fanspeed_t
Common A/C settings for Fan Speeds.
Definition IRsend.h:67
opmode_t
Common A/C settings for A/C operating modes.
Definition IRsend.h:55
Structure to hold a common A/C state.
Definition IRsend.h:120
Native representation of a Voltas A/C message.
Definition ir_Voltas.h:27
uint8_t TempSet
Definition ir_Voltas.h:48
uint8_t Sleep
Definition ir_Voltas.h:42
uint8_t Temp
Definition ir_Voltas.h:45
uint8_t OffTimerMins
Definition ir_Voltas.h:54
uint8_t OnTimerEnable
Definition ir_Voltas.h:66
uint8_t SwingHChange
Definition ir_Voltas.h:32
uint8_t OnTimerMins
Definition ir_Voltas.h:50
uint8_t OffTimerEnable
Definition ir_Voltas.h:65
uint8_t Checksum
Definition ir_Voltas.h:68
uint8_t Econo
Definition ir_Voltas.h:47
uint8_t SwingH
Definition ir_Voltas.h:31
uint8_t Power
Definition ir_Voltas.h:43
uint8_t OnTimer12Hr
Definition ir_Voltas.h:52
uint8_t OffTimer12Hr
Definition ir_Voltas.h:56
uint8_t FanSpeed
Definition ir_Voltas.h:36
uint8_t Light
Definition ir_Voltas.h:64
uint8_t Turbo
Definition ir_Voltas.h:41
uint8_t Wifi
Definition ir_Voltas.h:39
uint8_t SwingV
Definition ir_Voltas.h:38
uint8_t OnTimerHrs
Definition ir_Voltas.h:60
uint8_t Mode
Definition ir_Voltas.h:34
uint8_t OffTimerHrs
Definition ir_Voltas.h:61
uint8_t raw[kVoltasStateLength]
The state in native IR code form.
Definition ir_Voltas.h:28