# IRremoteESP8266: src/ir_Neoclima.h Source File

ir_Neoclima.h
Go to the documentation of this file.
// Copyright 2019 David Conran
// Supports:
// Brand: Neoclima, Model: NS-09AHTI A/C
// Brand: Neoclima, Model: ZH/TY-01 remote
// Brand: Soleus Air, Model: TTWM1-10-01 A/C
// Brand: Soleus Air, Model: ZCF/TL-05 remote
#ifndef IR_NEOCLIMA_H_
#define IR_NEOCLIMA_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 NeoclimaProtocol {
uint8_t raw[kNeoclimaStateLength];
struct {
// Byte 0
uint8_t :8;
// Byte 1
uint8_t :1;
uint8_t CHeat :1;
uint8_t Ion :1;
uint8_t :5;
// Byte 2
uint8_t :8;
// Byte 3
uint8_t Light :1;
uint8_t :1;
uint8_t Hold :1;
uint8_t Turbo :1;
uint8_t Econo :1;
uint8_t :1;
uint8_t Eye :1;
uint8_t :1;
// Byte 4
uint8_t :8;
// Byte 5
uint8_t Button :5;
uint8_t :2;
uint8_t Fresh :1;
// Byte 6
uint8_t :8;
// Byte 7
uint8_t Sleep :1;
uint8_t Power :1;
uint8_t SwingV :2;
uint8_t SwingH :1;
uint8_t Fan :2;
uint8_t UseFah :1;
// Byte 8
uint8_t Follow :8;
// Byte 9
uint8_t Temp :5;
uint8_t Mode :3;
// Byte 10
uint8_t :8;
// Byte 11
uint8_t Sum :8;
};
};
// Constants
const uint8_t kNeoclimaButtonPower = 0x00;
const uint8_t kNeoclimaButtonMode = 0x01;
const uint8_t kNeoclimaButtonTempUp = 0x02;
const uint8_t kNeoclimaButtonTempDown = 0x03;
const uint8_t kNeoclimaButtonSwing = 0x04;
const uint8_t kNeoclimaButtonFanSpeed = 0x05;
const uint8_t kNeoclimaButtonAirFlow = 0x07;
const uint8_t kNeoclimaButtonHold = 0x08;
const uint8_t kNeoclimaButtonSleep = 0x09;
const uint8_t kNeoclimaButtonTurbo = 0x0A;
const uint8_t kNeoclimaButtonLight = 0x0B;
const uint8_t kNeoclimaButtonEcono = 0x0D;
const uint8_t kNeoclimaButtonEye = 0x0E;
const uint8_t kNeoclimaButtonFollow = 0x13;
const uint8_t kNeoclimaButtonIon = 0x14;
const uint8_t kNeoclimaButtonFresh = 0x15;
const uint8_t kNeoclimaButton8CHeat = 0x1D;
const uint8_t kNeoclimaButtonTempUnit = 0x1E;
const uint8_t kNeoclimaSwingVOn = 0b01;
const uint8_t kNeoclimaSwingVOff = 0b10;
const uint8_t kNeoclimaFanAuto = 0b00;
const uint8_t kNeoclimaFanHigh = 0b01;
const uint8_t kNeoclimaFanMed = 0b10;
const uint8_t kNeoclimaFanLow = 0b11;
const uint8_t kNeoclimaFollowMe = 0x5D; // Also 0x5F
const uint8_t kNeoclimaMinTempC = 16; // 16C
const uint8_t kNeoclimaMaxTempC = 32; // 32C
const uint8_t kNeoclimaMinTempF = 61; // 61F
const uint8_t kNeoclimaMaxTempF = 90; // 90F
const uint8_t kNeoclimaAuto = 0b000;
const uint8_t kNeoclimaCool = 0b001;
const uint8_t kNeoclimaDry = 0b010;
const uint8_t kNeoclimaFan = 0b011;
const uint8_t kNeoclimaHeat = 0b100;
// Classes
class IRNeoclimaAc {
public:
explicit IRNeoclimaAc(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
void stateReset(void);
#if SEND_NEOCLIMA
void send(const uint16_t repeat = kNeoclimaMinRepeat);
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif // SEND_NEOCLIMA
void begin(void);
void setButton(const uint8_t button);
uint8_t getButton(void) const;
void on(void);
void off(void);
void setPower(const bool on);
bool getPower(void) const;
void setMode(const uint8_t mode);
uint8_t getMode(void) const;
void setTemp(const uint8_t temp, const bool celsius = true);
uint8_t getTemp(void) const;
void setFan(const uint8_t speed);
uint8_t getFan(void) const;
void setSwingV(const bool on);
bool getSwingV(void) const;
void setSwingH(const bool on);
bool getSwingH(void) const;
void setSleep(const bool on);
bool getSleep(void) const;
void setTurbo(const bool on);
bool getTurbo(void) const;
void setEcono(const bool on);
bool getEcono(void) const;
void setFresh(const bool on);
bool getFresh(void) const;
void setHold(const bool on);
bool getHold(void) const;
void setIon(const bool on);
bool getIon(void) const;
void setLight(const bool on);
bool getLight(void) const;
void set8CHeat(const bool on);
bool get8CHeat(void) const;
void setEye(const bool on);
bool getEye(void) const;
bool getTempUnits(void) const;
// DISABLED: See TODO in ir_Neoclima.cpp
// void setFollow(const bool on);
bool getFollow(void) const;
uint8_t* getRaw(void);
void setRaw(const uint8_t new_code[],
const uint16_t length = kNeoclimaStateLength);
static bool validChecksum(const uint8_t state[],
const uint16_t length = kNeoclimaStateLength);
static uint8_t calcChecksum(const uint8_t state[],
const uint16_t length = kNeoclimaStateLength);
String toString(void) const;
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;
#ifndef UNIT_TEST
private:
IRsend _irsend;
#else // UNIT_TEST
IRsendTest _irsend;
#endif // UNIT_TEST
NeoclimaProtocol _;
void checksum(const uint16_t length = kNeoclimaStateLength);
};
#endif // IR_NEOCLIMA_H_
IRNeoclimaAc::getPower
bool getPower(void) const
Get the value of the current power setting.
Definition: ir_Neoclima.cpp:178
NeoclimaProtocol::Hold
uint8_t Hold
Definition: ir_Neoclima.h:45
kNeoclimaFanHigh
const uint8_t kNeoclimaFanHigh
Definition: ir_Neoclima.h:102
IRNeoclimaAc::getEcono
bool getEcono(void) const
Get the Economy (Energy Saver) setting of the A/C.
Definition: ir_Neoclima.cpp:375
IRNeoclimaAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Neoclima.cpp:305
kNeoclimaMinTempC
const uint8_t kNeoclimaMinTempC
Definition: ir_Neoclima.h:108
kNeoclimaButtonFanSpeed
const uint8_t kNeoclimaButtonFanSpeed
Definition: ir_Neoclima.h:85
kNeoclimaButtonTurbo
const uint8_t kNeoclimaButtonTurbo
Definition: ir_Neoclima.h:89
kNeoclimaFollowMe
const uint8_t kNeoclimaFollowMe
Definition: ir_Neoclima.h:106
IRNeoclimaAc::_
NeoclimaProtocol _
Definition: ir_Neoclima.h:194
NeoclimaProtocol::Mode
uint8_t Mode
Definition: ir_Neoclima.h:70
kNeoclimaMaxTempC
const uint8_t kNeoclimaMaxTempC
Definition: ir_Neoclima.h:109
NeoclimaProtocol::raw
uint8_t raw[kNeoclimaStateLength]
State of the remote in code.
Definition: ir_Neoclima.h:31
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
NeoclimaProtocol::SwingV
uint8_t SwingV
Definition: ir_Neoclima.h:62
kNeoclimaDry
const uint8_t kNeoclimaDry
Definition: ir_Neoclima.h:114
IRNeoclimaAc::calcChecksum
static uint8_t calcChecksum(const uint8_t state[], const uint16_t length=kNeoclimaStateLength)
Calculate the checksum for a given state.
Definition: ir_Neoclima.cpp:83
IRNeoclimaAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Neoclima.h:131
NeoclimaProtocol::SwingH
uint8_t SwingH
Definition: ir_Neoclima.h:63
IRNeoclimaAc::set8CHeat
void set8CHeat(const bool on)
Set the 8°C Heat setting of the A/C.
Definition: ir_Neoclima.cpp:437
kNeoclimaButtonEye
const uint8_t kNeoclimaButtonEye
Definition: ir_Neoclima.h:92
kNeoclimaButtonPower
const uint8_t kNeoclimaButtonPower
Definition: ir_Neoclima.h:80
IRNeoclimaAc::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Neoclima.cpp:263
kNeoclimaSwingVOn
const uint8_t kNeoclimaSwingVOn
Definition: ir_Neoclima.h:99
kNeoclimaButtonMode
const uint8_t kNeoclimaButtonMode
Definition: ir_Neoclima.h:81
kNeoclimaStateLength
const uint16_t kNeoclimaStateLength
Definition: IRremoteESP8266.h:1023
NeoclimaProtocol
Native representation of a Neoclima A/C message.
Definition: ir_Neoclima.h:30
IRNeoclimaAc::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_Neoclima.cpp:284
IRNeoclimaAc::setHold
void setHold(const bool on)
Set the Hold setting of the A/C.
Definition: ir_Neoclima.cpp:394
kNeoclimaMinTempF
const uint8_t kNeoclimaMinTempF
Definition: ir_Neoclima.h:110
IRNeoclimaAc::setRaw
void setRaw(const uint8_t new_code[], const uint16_t length=kNeoclimaStateLength)
Set the internal state from a valid code for this protocol.
Definition: ir_Neoclima.cpp:124
kNeoclimaButtonHold
const uint8_t kNeoclimaButtonHold
Definition: ir_Neoclima.h:87
NeoclimaProtocol::Power
uint8_t Power
Definition: ir_Neoclima.h:61
IRNeoclimaAc::setEcono
void setEcono(const bool on)
Set the Economy (Energy Saver) setting of the A/C.
Definition: ir_Neoclima.cpp:368
NeoclimaProtocol::Eye
uint8_t Eye
Definition: ir_Neoclima.h:49
IRNeoclimaAc::setTemp
void setTemp(const uint8_t temp, const bool celsius=true)
Set the temperature.
Definition: ir_Neoclima.cpp:239
IRsend.h
IRNeoclimaAc::getSleep
bool getSleep(void) const
Get the Sleep setting of the A/C.
Definition: ir_Neoclima.cpp:323
IRNeoclimaAc::getTurbo
bool getTurbo(void) const
Get the Turbo setting of the A/C.
Definition: ir_Neoclima.cpp:362
IRNeoclimaAc::getMode
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition: ir_Neoclima.cpp:206
kNeoclimaAuto
const uint8_t kNeoclimaAuto
Definition: ir_Neoclima.h:112
kNeoclimaMaxTempF
const uint8_t kNeoclimaMaxTempF
Definition: ir_Neoclima.h:111
IRNeoclimaAc::setLight
void setLight(const bool on)
Set the Light(LED display) setting of the A/C.
Definition: ir_Neoclima.cpp:420
kNeoclimaFan
const uint8_t kNeoclimaFan
Definition: ir_Neoclima.h:115
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:182
IRNeoclimaAc::get8CHeat
bool get8CHeat(void) const
Get the 8°C Heat setting of the A/C.
Definition: ir_Neoclima.cpp:444
NeoclimaProtocol::Sleep
uint8_t Sleep
Definition: ir_Neoclima.h:60
IRNeoclimaAc::getRaw
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol.
Definition: ir_Neoclima.cpp:116
kNeoclimaFanAuto
const uint8_t kNeoclimaFanAuto
Definition: ir_Neoclima.h:101
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
NeoclimaProtocol::Econo
uint8_t Econo
Definition: ir_Neoclima.h:47
String
std::string String
Definition: IRremoteESP8266.h:1178
IRNeoclimaAc::getEye
bool getEye(void) const
Get the Eye (Sensor) setting of the A/C.
Definition: ir_Neoclima.cpp:457
IRNeoclimaAc::getButton
uint8_t getButton(void) const
Get the Button/Command setting of the A/C.
Definition: ir_Neoclima.cpp:159
IRNeoclimaAc::getIon
bool getIon(void) const
Get the Ion (filter) setting of the A/C.
Definition: ir_Neoclima.cpp:414
kNeoclimaButtonFresh
const uint8_t kNeoclimaButtonFresh
Definition: ir_Neoclima.h:95
NeoclimaProtocol::Turbo
uint8_t Turbo
Definition: ir_Neoclima.h:46
kNeoclimaButtonEcono
const uint8_t kNeoclimaButtonEcono
Definition: ir_Neoclima.h:91
NeoclimaProtocol::Temp
uint8_t Temp
Definition: ir_Neoclima.h:69
kNeoclimaButtonAirFlow
const uint8_t kNeoclimaButtonAirFlow
Definition: ir_Neoclima.h:86
IRremoteESP8266.h
NeoclimaProtocol::Button
uint8_t Button
Definition: ir_Neoclima.h:54
NeoclimaProtocol::CHeat
uint8_t CHeat
Definition: ir_Neoclima.h:37
IRNeoclimaAc::stateReset
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition: ir_Neoclima.cpp:70
IRNeoclimaAc::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Neoclima.cpp:291
kNeoclimaButtonTempDown
const uint8_t kNeoclimaButtonTempDown
Definition: ir_Neoclima.h:83
IRNeoclimaAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Neoclima.cpp:77
kNeoclimaButtonLight
const uint8_t kNeoclimaButtonLight
Definition: ir_Neoclima.h:90
IRNeoclimaAc::setIon
void setIon(const bool on)
Set the Ion (filter) setting of the A/C.
Definition: ir_Neoclima.cpp:407
IRNeoclimaAc::getLight
bool getLight(void) const
Get the Light (LED display) setting of the A/C.
Definition: ir_Neoclima.cpp:427
NeoclimaProtocol::Follow
uint8_t Follow
Definition: ir_Neoclima.h:67
kNeoclimaButtonSwing
const uint8_t kNeoclimaButtonSwing
Definition: ir_Neoclima.h:84
kNeoclimaButtonFollow
const uint8_t kNeoclimaButtonFollow
Definition: ir_Neoclima.h:93
IRNeoclimaAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Neoclima.h:188
kNeoclimaSwingVOff
const uint8_t kNeoclimaSwingVOff
Definition: ir_Neoclima.h:100
IRNeoclimaAc::getSwingV
bool getSwingV(void) const
Get the vertical swing setting of the A/C.
Definition: ir_Neoclima.cpp:336
IRNeoclimaAc::setSwingV
void setSwingV(const bool on)
Set the vertical swing setting of the A/C.
Definition: ir_Neoclima.cpp:329
IRNeoclimaAc::setEye
void setEye(const bool on)
Set the Eye (Sensor) setting of the A/C.
Definition: ir_Neoclima.cpp:450
IRNeoclimaAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Neoclima.cpp:226
kNeoclimaButtonSleep
const uint8_t kNeoclimaButtonSleep
Definition: ir_Neoclima.h:88
IRNeoclimaAc::toCommon
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Neoclima.cpp:486
IRNeoclimaAc::on
void on(void)
Set the requested power state of the A/C to on.
Definition: ir_Neoclima.cpp:164
NeoclimaProtocol::UseFah
uint8_t UseFah
Definition: ir_Neoclima.h:65
kNeoclimaFanMed
const uint8_t kNeoclimaFanMed
Definition: ir_Neoclima.h:103
IRNeoclimaAc::getFresh
bool getFresh(void) const
Get the Fresh (air) setting of the A/C.
Definition: ir_Neoclima.cpp:388
kNeoclimaButtonTempUnit
const uint8_t kNeoclimaButtonTempUnit
Definition: ir_Neoclima.h:97
IRNeoclimaAc::setFresh
void setFresh(const bool on)
Set the Fresh (air) setting of the A/C.
Definition: ir_Neoclima.cpp:381
IRNeoclimaAc::getHold
bool getHold(void) const
Get the Hold setting of the A/C.
Definition: ir_Neoclima.cpp:401
IRNeoclimaAc::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Neoclima.cpp:171
kNeoclimaCool
const uint8_t kNeoclimaCool
Definition: ir_Neoclima.h:113
kNeoclimaButton8CHeat
const uint8_t kNeoclimaButton8CHeat
Definition: ir_Neoclima.h:96
NeoclimaProtocol::Ion
uint8_t Ion
Definition: ir_Neoclima.h:38
IRNeoclimaAc::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_Neoclima.cpp:255
IRNeoclimaAc::getFollow
bool getFollow(void) const
Get the Follow Me setting of the A/C.
Definition: ir_Neoclima.cpp:480
IRNeoclimaAc::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Neoclima.cpp:213
kNeoclimaHeat
const uint8_t kNeoclimaHeat
Definition: ir_Neoclima.h:116
IRNeoclimaAc::setButton
void setButton(const uint8_t button)
Set the Button/Command pressed setting of the A/C.
Definition: ir_Neoclima.cpp:130
kNeoclimaButtonIon
const uint8_t kNeoclimaButtonIon
Definition: ir_Neoclima.h:94
IRNeoclimaAc::toString
String toString(void) const
Convert the current internal state into a human readable string.
Definition: ir_Neoclima.cpp:514
NeoclimaProtocol::Sum
uint8_t Sum
Definition: ir_Neoclima.h:74
IRNeoclimaAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Neoclima.cpp:184
kNeoclimaFanLow
const uint8_t kNeoclimaFanLow
Definition: ir_Neoclima.h:104
IRNeoclimaAc::setTurbo
void setTurbo(const bool on)
Set the Turbo setting of the A/C.
Definition: ir_Neoclima.cpp:355
IRNeoclimaAc::getTempUnits
bool getTempUnits(void) const
Is the A/C unit using Fahrenheit or Celsius for temperature units.
Definition: ir_Neoclima.cpp:463
NeoclimaProtocol::Light
uint8_t Light
Definition: ir_Neoclima.h:43
IRNeoclimaAc::getSwingH
bool getSwingH(void) const
Get the horizontal swing (Air Flow) setting of the A/C.
Definition: ir_Neoclima.cpp:349
IRNeoclimaAc::checksum
void checksum(const uint16_t length=kNeoclimaStateLength)
Calculate & update the checksum for the internal state.
Definition: ir_Neoclima.cpp:101
IRNeoclimaAc::setSwingH
void setSwingH(const bool on)
Set the horizontal swing setting of the A/C.
Definition: ir_Neoclima.cpp:342
IRNeoclimaAc::send
void send(const uint16_t repeat=kNeoclimaMinRepeat)
Send the current internal state as an IR message.
Definition: ir_Neoclima.cpp:109
IRNeoclimaAc::off
void off(void)
Set the requested power state of the A/C to off.
Definition: ir_Neoclima.cpp:167
NeoclimaProtocol::Fan
uint8_t Fan
Definition: ir_Neoclima.h:64
NeoclimaProtocol::Fresh
uint8_t Fresh
Definition: ir_Neoclima.h:56
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
kNeoclimaMinRepeat
const uint16_t kNeoclimaMinRepeat
Definition: IRremoteESP8266.h:1025
IRNeoclimaAc::IRNeoclimaAc
IRNeoclimaAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Neoclima.cpp:63
IRNeoclimaAc
Class for handling detailed Neoclima A/C messages.
Definition: ir_Neoclima.h:120
IRNeoclimaAc::setSleep
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition: ir_Neoclima.cpp:316
IRNeoclimaAc::validChecksum
static bool validChecksum(const uint8_t state[], const uint16_t length=kNeoclimaStateLength)
Verify the checksum is valid for a given state.
Definition: ir_Neoclima.cpp:93
kNeoclimaButtonTempUp
const uint8_t kNeoclimaButtonTempUp
Definition: ir_Neoclima.h:82
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46