# IRremoteESP8266: src/ir_Voltas.h Source File

ir_Voltas.h
Go to the documentation of this file.
// Copyright 2020 David Conran (crankyoldgit)
// Copyright 2020 manj9501
// Supports:
// Brand: Voltas, Model: 122LZF 4011252 Window A/C
//
// Ref: https://docs.google.com/spreadsheets/d/1zzDEUQ52y7MZ7_xCU3pdjdqbRXOwZLsbTGvKWcicqCI/
// Ref: https://www.corona.co.jp/box/download.php?id=145060636229
#ifndef IR_VOLTAS_H_
#define IR_VOLTAS_H_
#define __STDC_LIMIT_MACROS
#include <stdint.h>
#ifndef UNIT_TEST
#include <Arduino.h>
#endif
#include "IRremoteESP8266.h"
#include "IRsend.h"
#ifdef UNIT_TEST
#include "IRsend_test.h"
#endif
union VoltasProtocol {
uint8_t raw[kVoltasStateLength];
struct {
// Byte 0
uint8_t SwingH :1;
uint8_t SwingHChange :7;
// Byte 1
uint8_t Mode :4;
uint8_t :1; // Unknown/Unused
uint8_t FanSpeed :3;
// Byte 2
uint8_t SwingV :3;
uint8_t Wifi :1;
uint8_t :1; // Unknown/Unused
uint8_t Turbo :1;
uint8_t Sleep :1;
uint8_t Power :1;
// Byte 3
uint8_t Temp :4;
uint8_t :2; // Typically 0b01
uint8_t Econo :1;
uint8_t TempSet :1;
// Byte 4
uint8_t OnTimerMins :6; // 0-59
uint8_t :1; // Unknown/Unused
uint8_t OnTimer12Hr :1; // (Nr of Hours + 1) % 12.
// Byte 5
uint8_t OffTimerMins :6; // 0-59
uint8_t :1; // Unknown/Unused
uint8_t OffTimer12Hr :1; // (Nr of Hours + 1) % 12.
// Byte 6
uint8_t :8; // Typically 0b00111011(0x3B)
// Byte 7
uint8_t OnTimerHrs :4; // (Nr of Hours + 1) % 12.
uint8_t OffTimerHrs :4; // (Nr of Hours + 1) % 12.
// Byte 8
uint8_t :5; // Typically 0b00000
uint8_t Light :1;
uint8_t OffTimerEnable :1;
uint8_t OnTimerEnable :1;
// Byte 9
uint8_t Checksum :8;
};
};
// Constants
const uint8_t kVoltasFan = 0b0001;
const uint8_t kVoltasHeat = 0b0010;
const uint8_t kVoltasDry = 0b0100;
const uint8_t kVoltasCool = 0b1000;
const uint8_t kVoltasMinTemp = 16;
const uint8_t kVoltasDryTemp = 24;
const uint8_t kVoltasMaxTemp = 30;
const uint8_t kVoltasFanHigh = 0b001;
const uint8_t kVoltasFanMed = 0b010;
const uint8_t kVoltasFanLow = 0b100;
const uint8_t kVoltasFanAuto = 0b111;
const uint8_t kVoltasSwingHChange = 0b1111100;
const uint8_t kVoltasSwingHNoChange = 0b0011001;
// Classes
class IRVoltas {
public:
explicit IRVoltas(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
void stateReset();
#if SEND_VOLTAS
void send(const uint16_t repeat = kNoRepeat);
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif // SEND_VOLTAS
void begin();
static bool validChecksum(const uint8_t state[],
const uint16_t length = kVoltasStateLength);
void setModel(const voltas_ac_remote_model_t model);
voltas_ac_remote_model_t getModel(const bool raw = false) const;
void setPower(const bool on);
bool getPower(void) const;
void on(void);
void off(void);
void setWifi(const bool on);
bool getWifi(void) const;
void setTemp(const uint8_t temp);
uint8_t getTemp(void);
void setFan(const uint8_t speed);
uint8_t getFan(void);
void setMode(const uint8_t mode);
uint8_t getMode(void);
void setSwingH(const bool on);
bool getSwingH(void) const;
void setSwingHChange(const bool on);
bool getSwingHChange(void) const;
void setSwingV(const bool on);
bool getSwingV(void) const;
void setEcono(const bool on);
bool getEcono(void) const;
void setLight(const bool on);
bool getLight(void) const;
void setTurbo(const bool on);
bool getTurbo(void) const;
void setSleep(const bool on);
bool getSleep(void) const;
uint16_t getOnTime(void) const;
void setOnTime(const uint16_t nr_of_mins);
uint16_t getOffTime(void) const;
void setOffTime(const uint16_t nr_of_mins);
uint8_t* getRaw(void);
void setRaw(const uint8_t new_code[]);
uint8_t convertMode(const stdAc::opmode_t mode);
uint8_t convertFan(const stdAc::fanspeed_t speed);
static stdAc::opmode_t toCommonMode(const uint8_t mode);
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
stdAc::state_t toCommon(const stdAc::state_t *prev = NULL);
String toString(void);
#ifndef UNIT_TEST
private:
IRsend _irsend;
#else
IRsendTest _irsend;
#endif
VoltasProtocol _;
voltas_ac_remote_model_t _model;
void checksum(void);
static uint8_t calcChecksum(const uint8_t state[],
const uint16_t length = kVoltasStateLength);
};
#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 equivalent.
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
Native representation of a Voltas A/C message.
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:182
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:1096
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:1178
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:875
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 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: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 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: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:158
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