# IRremoteESP8266: src/ir_Corona.h Source File

ir_Corona.h
Go to the documentation of this file.
// Corona A/C
//
// Copyright 2020 Christian Nilsson
// Supports:
// Brand: Corona, Model: CSH-N2211 A/C
// Brand: Corona, Model: CSH-N2511 A/C
// Brand: Corona, Model: CSH-N2811 A/C
// Brand: Corona, Model: CSH-N4011 A/C
// Brand: Corona, Model: AR-01 remote
//
// Ref: https://docs.google.com/spreadsheets/d/1zzDEUQ52y7MZ7_xCU3pdjdqbRXOwZLsbTGvKWcicqCI/
// Ref: https://www.corona.co.jp/box/download.php?id=145060636229
#ifndef IR_CORONA_H_
#define IR_CORONA_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
struct CoronaSection {
uint8_t Header0;
uint8_t Header1;
uint8_t Label;
uint8_t Data0;
uint8_t Data0Inv;
uint8_t Data1;
uint8_t Data1Inv;
};
const uint8_t kCoronaAcSections = 3;
union CoronaProtocol {
uint8_t raw[kCoronaAcStateLength];
CoronaSection sections[kCoronaAcSections];
struct {
// Byte 0
uint8_t :8;
// Byte 1
uint8_t :8;
// Byte 2
uint8_t :8;
// Byte 3
uint8_t Fan :2;
uint8_t :1;
uint8_t Econo :1;
uint8_t :1; // always on
uint8_t :1;
uint8_t SwingVToggle :1;
uint8_t :1;
// Byte 4
uint8_t :8;
// Byte 5
uint8_t Temp :4;
uint8_t Power :1;
uint8_t PowerButton :1;
uint8_t Mode :2;
};
};
// Constants
// CORONA_AC
const uint8_t kCoronaAcSectionBytes = 7; // kCoronaAcStateLengthShort
const uint8_t kCoronaAcSectionHeader0 = 0x28;
const uint8_t kCoronaAcSectionHeader1 = 0x61;
const uint8_t kCoronaAcSectionLabelBase = 0x0D; // 0b1101
const uint8_t kCoronaAcSectionData0Base = 0x10; // D0 Pos 4 always on
const uint8_t kCoronaAcFanAuto = 0b00; // 0
const uint8_t kCoronaAcFanLow = 0b01; // 1
const uint8_t kCoronaAcFanMedium = 0b10; // 2
const uint8_t kCoronaAcFanHigh = 0b11; // 3
/* full auto mode not supported by this code yet
const uint8_t kCoronaAcAutoD0 = 0b00010100; // only combined with power save
const uint8_t kCoronaAcAutoD1 = 0b10000011; // only combined with power
*/
const uint8_t kCoronaAcMinTemp = 17; // Celsius = 0b0001
const uint8_t kCoronaAcMaxTemp = 30; // Celsius = 0b1110
const uint8_t kCoronaAcModeHeat = 0b00; // 0
const uint8_t kCoronaAcModeDry = 0b01; // 1
const uint8_t kCoronaAcModeCool = 0b10; // 2
const uint8_t kCoronaAcModeFan = 0b11; // 3
const uint8_t kCoronaAcSettingsSection = 0;
const uint8_t kCoronaAcOnTimerSection = 1;
const uint8_t kCoronaAcOffTimerSection = 2;
const uint16_t kCoronaAcTimerMax = 12 * 60; // 12H in Minutes
// Min value on remote is 1 hour, actual sent value can be 2 secs
const uint16_t kCoronaAcTimerOff = 0xffff;
const uint16_t kCoronaAcTimerUnitsPerMin = 30; // 30 units = 1 minute
// Classes
class IRCoronaAc {
public:
explicit IRCoronaAc(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
void stateReset();
#if SEND_CORONA_AC
void send(const uint16_t repeat = kNoRepeat);
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif // SEND_CORONA_AC
void begin();
static bool validSection(const uint8_t state[], const uint16_t pos,
const uint8_t section);
void setPower(const bool on);
bool getPower(void) const;
bool getPowerButton(void) const;
void on(void);
void off(void);
void setTemp(const uint8_t temp);
uint8_t getTemp(void) const;
void setSwingVToggle(const bool on);
bool getSwingVToggle(void) const;
void setFan(const uint8_t speed);
uint8_t getFan(void) const;
void setMode(const uint8_t mode);
uint8_t getMode(void) const;
void setEcono(const bool on);
bool getEcono(void) const;
void setOnTimer(const uint16_t nr_of_mins);
uint16_t getOnTimer(void) const;
void setOffTimer(const uint16_t nr_of_mins);
uint16_t getOffTimer(void) const;
uint8_t* getRaw();
void setRaw(const uint8_t new_code[],
const uint16_t length = kCoronaAcStateLength);
static uint8_t convertMode(const stdAc::opmode_t mode);
static 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(void) const;
String toString(void) const;
#ifndef UNIT_TEST
private:
IRsend _irsend;
#else
IRsendTest _irsend;
#endif
CoronaProtocol _;
static uint8_t getSectionByte(const uint8_t section);
static void checksum(uint8_t* data);
void setPowerButton(const bool on);
void _setTimer(const uint8_t section, const uint16_t nr_of_mins);
uint16_t _getTimer(const uint8_t section) const;
};
#endif // IR_CORONA_H_
CoronaSection::Header1
uint8_t Header1
Definition: ir_Corona.h:32
kCoronaAcSectionBytes
const uint8_t kCoronaAcSectionBytes
Definition: ir_Corona.h:74
IRCoronaAc::getMode
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition: ir_Corona.cpp:346
IRCoronaAc::setFan
void setFan(const uint8_t speed)
Set the operating speed of the A/C Fan.
Definition: ir_Corona.cpp:398
IRCoronaAc::setEcono
void setEcono(const bool on)
Change the powersave setting.
Definition: ir_Corona.cpp:407
IRCoronaAc::setRaw
void setRaw(const uint8_t new_code[], const uint16_t length=kCoronaAcStateLength)
Set the internal state from a valid code for this protocol.
Definition: ir_Corona.cpp:282
kCoronaAcSectionLabelBase
const uint8_t kCoronaAcSectionLabelBase
Definition: ir_Corona.h:77
kCoronaAcModeFan
const uint8_t kCoronaAcModeFan
Definition: ir_Corona.h:94
CoronaSection::Data1Inv
uint8_t Data1Inv
Definition: ir_Corona.h:37
IRCoronaAc::setPowerButton
void setPowerButton(const bool on)
Change the power button setting.
Definition: ir_Corona.cpp:328
IRCoronaAc
Class for handling detailed Corona A/C messages.
Definition: ir_Corona.h:107
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
kCoronaAcModeDry
const uint8_t kCoronaAcModeDry
Definition: ir_Corona.h:92
kCoronaAcSectionData0Base
const uint8_t kCoronaAcSectionData0Base
Definition: ir_Corona.h:78
CoronaProtocol::Power
uint8_t Power
Definition: ir_Corona.h:65
IRCoronaAc::getOffTimer
uint16_t getOffTimer(void) const
Get the current Off Timer time.
Definition: ir_Corona.cpp:511
IRCoronaAc::setPower
void setPower(const bool on)
Change the power setting. (in practice Standby, remote power)
Definition: ir_Corona.cpp:304
IRCoronaAc::stateReset
void stateReset()
Reset the internal state to a fixed known good state.
Definition: ir_Corona.cpp:154
IRCoronaAc::getFan
uint8_t getFan(void) const
Get the operating speed of the A/C Fan.
Definition: ir_Corona.cpp:392
IRCoronaAc::toCommon
stdAc::state_t toCommon(void) const
Convert the A/C state to it's common stdAc::state_t equivalent.
Definition: ir_Corona.cpp:552
IRCoronaAc::begin
void begin()
Set up hardware to be able to send a message.
Definition: ir_Corona.cpp:252
kCoronaAcFanMedium
const uint8_t kCoronaAcFanMedium
Definition: ir_Corona.h:82
kCoronaAcTimerUnitsPerMin
const uint16_t kCoronaAcTimerUnitsPerMin
Definition: ir_Corona.h:102
IRCoronaAc::setOffTimer
void setOffTimer(const uint16_t nr_of_mins)
Set the Off Timer time.
Definition: ir_Corona.cpp:518
kCoronaAcFanLow
const uint8_t kCoronaAcFanLow
Definition: ir_Corona.h:81
CoronaProtocol
Native representation of a Corona A/C message.
Definition: ir_Corona.h:43
CoronaSection::Header0
uint8_t Header0
Definition: ir_Corona.h:31
IRsend.h
IRCoronaAc::setTemp
void setTemp(const uint8_t temp)
Set the temp in deg C.
Definition: ir_Corona.cpp:288
IRCoronaAc::toString
String toString(void) const
Convert the internal state into a human readable string.
Definition: ir_Corona.cpp:527
kCoronaAcSectionHeader0
const uint8_t kCoronaAcSectionHeader0
Definition: ir_Corona.h:75
IRCoronaAc::setOnTimer
void setOnTimer(const uint16_t nr_of_mins)
Set the On Timer time.
Definition: ir_Corona.cpp:502
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:182
IRCoronaAc::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a standard A/C Fan speed into its native fan speed.
Definition: ir_Corona.cpp:420
IRCoronaAc::_
CoronaProtocol _
Definition: ir_Corona.h:161
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
CoronaProtocol::Econo
uint8_t Econo
Definition: ir_Corona.h:56
String
std::string String
Definition: IRremoteESP8266.h:1178
kCoronaAcOffTimerSection
const uint8_t kCoronaAcOffTimerSection
Definition: ir_Corona.h:98
kCoronaAcTimerMax
const uint16_t kCoronaAcTimerMax
Definition: ir_Corona.h:99
IRCoronaAc::validSection
static bool validSection(const uint8_t state[], const uint16_t pos, const uint8_t section)
Check that a CoronaAc Section part is valid with section byte and inverted.
Definition: ir_Corona.cpp:187
IRCoronaAc::getOnTimer
uint16_t getOnTimer(void) const
Get the current On Timer time.
Definition: ir_Corona.cpp:495
IRCoronaAc::getPower
bool getPower(void) const
Get the current power setting. (in practice Standby, remote power)
Definition: ir_Corona.cpp:315
kCoronaAcSectionHeader1
const uint8_t kCoronaAcSectionHeader1
Definition: ir_Corona.h:76
IRremoteESP8266.h
IRCoronaAc::send
void send(const uint16_t repeat=kNoRepeat)
Send the current internal state as an IR message.
Definition: ir_Corona.cpp:257
kCoronaAcSections
const uint8_t kCoronaAcSections
Definition: ir_Corona.h:40
IRCoronaAc::_getTimer
uint16_t _getTimer(const uint8_t section) const
Get the current Timer time.
Definition: ir_Corona.cpp:482
kNoRepeat
const uint16_t kNoRepeat
Definition: IRremoteESP8266.h:875
kCoronaAcFanHigh
const uint8_t kCoronaAcFanHigh
Definition: ir_Corona.h:83
kCoronaAcStateLength
const uint16_t kCoronaAcStateLength
Definition: IRremoteESP8266.h:898
IRCoronaAc::checksum
static void checksum(uint8_t *data)
Calculate and set the check values for the internal state.
Definition: ir_Corona.cpp:240
IRCoronaAc::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a standard A/C mode into its native mode.
Definition: ir_Corona.cpp:369
CoronaSection::Data0
uint8_t Data0
Definition: ir_Corona.h:34
CoronaProtocol::PowerButton
uint8_t PowerButton
Definition: ir_Corona.h:66
IRCoronaAc::getPowerButton
bool getPowerButton(void) const
Get the value of the current power button setting.
Definition: ir_Corona.cpp:334
IRCoronaAc::off
void off(void)
Change the power setting to Off.
Definition: ir_Corona.cpp:342
IRCoronaAc::_setTimer
void _setTimer(const uint8_t section, const uint16_t nr_of_mins)
Set the Timer time.
Definition: ir_Corona.cpp:462
kCoronaAcModeCool
const uint8_t kCoronaAcModeCool
Definition: ir_Corona.h:93
kCoronaAcMinTemp
const uint8_t kCoronaAcMinTemp
Definition: ir_Corona.h:89
CoronaSection::Data1
uint8_t Data1
Definition: ir_Corona.h:36
CoronaProtocol::Temp
uint8_t Temp
Definition: ir_Corona.h:64
IRCoronaAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode to it's common stdAc::opmode_t equivalent.
Definition: ir_Corona.cpp:381
IRCoronaAc::getTemp
uint8_t getTemp(void) const
Get the current temperature from the internal state.
Definition: ir_Corona.cpp:296
IRCoronaAc::getSwingVToggle
bool getSwingVToggle(void) const
Get the Vertical Swing toggle setting.
Definition: ir_Corona.cpp:453
IRCoronaAc::IRCoronaAc
IRCoronaAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor for handling detailed Corona A/C messages.
Definition: ir_Corona.cpp:148
CoronaSection::Data0Inv
uint8_t Data0Inv
Definition: ir_Corona.h:35
IRCoronaAc::getRaw
uint8_t * getRaw()
Get a copy of the internal state as a valid code for this protocol.
Definition: ir_Corona.cpp:274
IRCoronaAc::on
void on(void)
Change the power setting to On.
Definition: ir_Corona.cpp:339
kCoronaAcSettingsSection
const uint8_t kCoronaAcSettingsSection
Definition: ir_Corona.h:96
CoronaProtocol::SwingVToggle
uint8_t SwingVToggle
Definition: ir_Corona.h:59
CoronaProtocol::raw
uint8_t raw[kCoronaAcStateLength]
The state of the IR remote.
Definition: ir_Corona.h:44
CoronaProtocol::sections
CoronaSection sections[kCoronaAcSections]
Definition: ir_Corona.h:45
kCoronaAcModeHeat
const uint8_t kCoronaAcModeHeat
Definition: ir_Corona.h:91
CoronaSection::Label
uint8_t Label
Definition: ir_Corona.h:33
IRCoronaAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Corona.h:155
IRCoronaAc::setSwingVToggle
void setSwingVToggle(const bool on)
Set the Vertical Swing toggle setting.
Definition: ir_Corona.cpp:447
IRCoronaAc::getSectionByte
static uint8_t getSectionByte(const uint8_t section)
Get the byte that identifies the section.
Definition: ir_Corona.cpp:171
IRCoronaAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Corona.cpp:352
CoronaSection
Native representation of a section of a Corona A/C message.
Definition: ir_Corona.h:30
IRCoronaAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed to it's common equivalent.
Definition: ir_Corona.cpp:434
IRCoronaAc::getEcono
bool getEcono(void) const
Get the value of the current powersave setting.
Definition: ir_Corona.cpp:413
IRCoronaAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Corona.h:119
kCoronaAcTimerOff
const uint16_t kCoronaAcTimerOff
Definition: ir_Corona.h:101
CoronaProtocol::Mode
uint8_t Mode
Definition: ir_Corona.h:67
kCoronaAcOnTimerSection
const uint8_t kCoronaAcOnTimerSection
Definition: ir_Corona.h:97
CoronaProtocol::Fan
uint8_t Fan
Definition: ir_Corona.h:54
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
kCoronaAcMaxTemp
const uint8_t kCoronaAcMaxTemp
Definition: ir_Corona.h:90
kCoronaAcFanAuto
const uint8_t kCoronaAcFanAuto
Definition: ir_Corona.h:80
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46