IRremoteESP8266
ir_Airton.h
Go to the documentation of this file.
1 // Copyright 2021 David Conran (crankyoldgit)
5 
6 // Supports:
7 // Brand: Airton, Model: SMVH09B-2A2A3NH ref. 409730 A/C
8 // Brand: Airton, Model: RD1A1 remote
9 
10 #ifndef IR_AIRTON_H_
11 #define IR_AIRTON_H_
12 
13 #define __STDC_LIMIT_MACROS
14 #include <stdint.h>
15 #ifndef UNIT_TEST
16 #include <Arduino.h>
17 #endif
18 #include "IRremoteESP8266.h"
19 #include "IRsend.h"
20 #ifdef UNIT_TEST
21 #include "IRsend_test.h"
22 #endif
23 
27  uint64_t raw;
28  struct { // Common
29  // Byte 1 & 0 (LSB)
30  uint16_t Header :16; // Header. (0x11D3)
31  // Byte 2
32  uint8_t Mode :3; // Operating Mode
33  uint8_t Power :1; // Power Control
34  uint8_t Fan :3;
35  uint8_t Turbo :1;
36  // Byte 3
37  uint8_t Temp :4; // Degrees Celsius (+16 offset)
38  uint8_t :4; // Unknown / Unused.
39  // Byte 4
40  uint8_t SwingV :1;
41  uint8_t :7; // Unknown / Unused.
42  // Byte 5
43  uint8_t Econo :1;
44  uint8_t Sleep :1;
45  uint8_t NotAutoOn :1;
46  uint8_t :1; // Unknown / Unused.
47  uint8_t HeatOn :1;
48  uint8_t :1; // Unknown / Unused.
49  uint8_t Health :1;
50  uint8_t Light :1;
51  // Byte 6
52  uint8_t Sum :8; // Sepecial checksum value
53  };
54 };
55 
56 // Constants
57 const uint8_t kAirtonAuto = 0b000; // 0
58 const uint8_t kAirtonCool = 0b001; // 1
59 const uint8_t kAirtonDry = 0b010; // 2
60 const uint8_t kAirtonFan = 0b011; // 3
61 const uint8_t kAirtonHeat = 0b100; // 4
62 
63 const uint8_t kAirtonFanAuto = 0b000; // 0
64 const uint8_t kAirtonFanMin = 0b001; // 1
65 const uint8_t kAirtonFanLow = 0b010; // 2
66 const uint8_t kAirtonFanMed = 0b011; // 3
67 const uint8_t kAirtonFanHigh = 0b100; // 4
68 const uint8_t kAirtonFanMax = 0b101; // 5
69 
70 const uint8_t kAirtonMinTemp = 16; // 16C
71 const uint8_t kAirtonMaxTemp = 25; // 25C
72 
73 
75 class IRAirtonAc {
76  public:
77  explicit IRAirtonAc(const uint16_t pin, const bool inverted = false,
78  const bool use_modulation = true);
79  void stateReset(void);
80 #if SEND_AIRTON
81  void send(const uint16_t repeat = kAirtonDefaultRepeat);
86  int8_t calibrate(void) { return _irsend.calibrate(); }
87 #endif // SEND_AIRTON
88  void begin(void);
89  void on(void);
90  void off(void);
91  void setPower(const bool on);
92  bool getPower(void) const;
93  void setTemp(const uint8_t degrees);
94  uint8_t getTemp(void) const;
95  void setFan(const uint8_t speed);
96  uint8_t getFan(void) const;
97  void setMode(const uint8_t mode);
98  uint8_t getMode(void) const;
99  uint64_t getRaw(void);
100  void setRaw(const uint64_t data);
101  void setLight(const bool on);
102  bool getLight(void) const;
103  void setEcono(const bool on);
104  bool getEcono(void) const;
105  void setTurbo(const bool on);
106  bool getTurbo(void) const;
107  void setHealth(const bool on);
108  bool getHealth(void) const;
109  void setSleep(const bool on);
110  bool getSleep(void) const;
111  void setSwingV(const bool on);
112  bool getSwingV(void) const;
113  static bool validChecksum(const uint64_t data);
114  static uint8_t calcChecksum(const uint64_t data);
115  static uint8_t convertMode(const stdAc::opmode_t mode);
116  static uint8_t convertFan(const stdAc::fanspeed_t speed);
117  static uint8_t convertSwingV(const stdAc::swingv_t position);
118  static stdAc::opmode_t toCommonMode(const uint8_t mode);
119  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
120  stdAc::state_t toCommon(void) const;
121  String toString(void) const;
122 #ifndef UNIT_TEST
123 
124  private:
126 #else // UNIT_TEST
127  IRsendTest _irsend;
129 #endif // UNIT_TEST
132  void checksum(void);
133 };
134 #endif // IR_AIRTON_H_
IRAirtonAc::setTurbo
void setTurbo(const bool on)
Set the Turbo setting of the A/C.
Definition: ir_Airton.cpp:284
IRAirtonAc::send
void send(const uint16_t repeat=kAirtonDefaultRepeat)
Send the current internal state as an IR message.
Definition: ir_Airton.cpp:92
IRAirtonAc::calcChecksum
static uint8_t calcChecksum(const uint64_t data)
Calculate the checksum for the supplied state.
Definition: ir_Airton.cpp:100
IRAirtonAc
Class for handling detailed Airton 56-bit A/C messages.
Definition: ir_Airton.h:75
kAirtonMinTemp
const uint8_t kAirtonMinTemp
Definition: ir_Airton.h:70
IRAirtonAc::toString
String toString(void) const
Convert the current internal state into a human readable string.
Definition: ir_Airton.cpp:345
stdAc::swingv_t
swingv_t
Common A/C settings for Vertical Swing.
Definition: IRsend.h:74
kAirtonDefaultRepeat
const uint16_t kAirtonDefaultRepeat
Definition: IRremoteESP8266.h:1149
IRAirtonAc::setHealth
void setHealth(const bool on)
Set the Health/Filter setting of the A/C.
Definition: ir_Airton.cpp:311
IRAirtonAc::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Airton.cpp:230
IRAirtonAc::checksum
void checksum(void)
Update the checksum value for the internal state.
Definition: ir_Airton.cpp:114
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:61
IRAirtonAc::getMode
uint8_t getMode(void) const
Get the current operation mode setting.
Definition: ir_Airton.cpp:151
IRAirtonAc::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Airton.cpp:180
kAirtonFanAuto
const uint8_t kAirtonFanAuto
Definition: ir_Airton.h:63
IRAirtonAc::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Airton.cpp:219
kAirtonCool
const uint8_t kAirtonCool
Definition: ir_Airton.h:58
AirtonProtocol::Turbo
uint8_t Turbo
Definition: ir_Airton.h:35
AirtonProtocol::Sleep
uint8_t Sleep
Definition: ir_Airton.h:44
IRAirtonAc::_
AirtonProtocol _
Definition: ir_Airton.h:131
AirtonProtocol::NotAutoOn
uint8_t NotAutoOn
Definition: ir_Airton.h:45
AirtonProtocol::HeatOn
uint8_t HeatOn
Definition: ir_Airton.h:47
IRAirtonAc::setTemp
void setTemp(const uint8_t degrees)
Set the temperature.
Definition: ir_Airton.cpp:205
IRAirtonAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Airton.cpp:244
IRsend.h
AirtonProtocol::SwingV
uint8_t SwingV
Definition: ir_Airton.h:40
kAirtonFanHigh
const uint8_t kAirtonFanHigh
Definition: ir_Airton.h:67
IRAirtonAc::getLight
bool getLight(void) const
Get the Light/LED/Display setting of the A/C.
Definition: ir_Airton.cpp:269
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:237
kAirtonMaxTemp
const uint8_t kAirtonMaxTemp
Definition: ir_Airton.h:71
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
kAirtonFanMax
const uint8_t kAirtonFanMax
Definition: ir_Airton.h:68
IRAirtonAc::getSleep
bool getSleep(void) const
Get the Sleep setting of the A/C.
Definition: ir_Airton.cpp:307
String
std::string String
Definition: IRremoteESP8266.h:1521
IRAirtonAc::toCommon
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Airton.cpp:319
AirtonProtocol::Sum
uint8_t Sum
Definition: ir_Airton.h:52
kAirtonFan
const uint8_t kAirtonFan
Definition: ir_Airton.h:60
IRAirtonAc::setPower
void setPower(const bool on)
Set the internal state to have the desired power.
Definition: ir_Airton.cpp:140
AirtonProtocol
Native representation of a Airton 56 A/C message.
Definition: ir_Airton.h:26
IRAirtonAc::getRaw
uint64_t getRaw(void)
Get the raw state of the object, suitable to be sent with the appropriate IRsend object method.
Definition: ir_Airton.cpp:122
IRAirtonAc::getHealth
bool getHealth(void) const
Get the Health/Filter setting of the A/C.
Definition: ir_Airton.cpp:315
AirtonProtocol::Health
uint8_t Health
Definition: ir_Airton.h:49
kAirtonFanLow
const uint8_t kAirtonFanLow
Definition: ir_Airton.h:65
IRremoteESP8266.h
kAirtonHeat
const uint8_t kAirtonHeat
Definition: ir_Airton.h:61
AirtonProtocol::Power
uint8_t Power
Definition: ir_Airton.h:33
AirtonProtocol::Mode
uint8_t Mode
Definition: ir_Airton.h:32
IRAirtonAc::getEcono
bool getEcono(void) const
Get the Economy setting of the A/C.
Definition: ir_Airton.cpp:280
IRAirtonAc::validChecksum
static bool validChecksum(const uint64_t data)
Verify the checksum is valid for a given state.
Definition: ir_Airton.cpp:107
IRAirtonAc::setLight
void setLight(const bool on)
Set the Light/LED/Display setting of the A/C.
Definition: ir_Airton.cpp:265
IRAirtonAc::on
void on(void)
Set the internal state to have the power on.
Definition: ir_Airton.cpp:133
kAirtonAuto
const uint8_t kAirtonAuto
Definition: ir_Airton.h:57
IRAirtonAc::setMode
void setMode(const uint8_t mode)
Set the desired operation mode.
Definition: ir_Airton.cpp:155
AirtonProtocol::Fan
uint8_t Fan
Definition: ir_Airton.h:34
IRAirtonAc::off
void off(void)
Set the internal state to have the power off.
Definition: ir_Airton.cpp:136
kAirtonDry
const uint8_t kAirtonDry
Definition: ir_Airton.h:59
IRAirtonAc::getSwingV
bool getSwingV(void) const
Get the Vertical Swing setting of the A/C.
Definition: ir_Airton.cpp:261
IRAirtonAc::setEcono
void setEcono(const bool on)
Set the Economy setting of the A/C.
Definition: ir_Airton.cpp:274
IRAirtonAc::convertSwingV
static uint8_t convertSwingV(const stdAc::swingv_t position)
IRAirtonAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Airton.cpp:193
IRAirtonAc::stateReset
void stateReset(void)
Reset the internals of the object to a known good state.
Definition: ir_Airton.cpp:117
AirtonProtocol::Light
uint8_t Light
Definition: ir_Airton.h:50
IRAirtonAc::getTurbo
bool getTurbo(void) const
Get the Turbo setting of the A/C.
Definition: ir_Airton.cpp:292
IRAirtonAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Airton.h:125
kAirtonFanMed
const uint8_t kAirtonFanMed
Definition: ir_Airton.h:66
IRAirtonAc::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_Airton.cpp:214
IRAirtonAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Airton.cpp:87
IRAirtonAc::setRaw
void setRaw(const uint64_t data)
Set the raw state of the object.
Definition: ir_Airton.cpp:129
AirtonProtocol::Temp
uint8_t Temp
Definition: ir_Airton.h:37
IRAirtonAc::setSleep
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition: ir_Airton.cpp:297
IRAirtonAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Airton.h:86
IRAirtonAc::IRAirtonAc
IRAirtonAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Airton.cpp:82
AirtonProtocol::Econo
uint8_t Econo
Definition: ir_Airton.h:43
kAirtonFanMin
const uint8_t kAirtonFanMin
Definition: ir_Airton.h:64
IRAirtonAc::getPower
bool getPower(void) const
Get the power setting from the internal state.
Definition: ir_Airton.cpp:147
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:114
AirtonProtocol::raw
uint64_t raw
The state in code form.
Definition: ir_Airton.h:27
AirtonProtocol::Header
uint16_t Header
Definition: ir_Airton.h:30
IRAirtonAc::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_Airton.cpp:225
IRAirtonAc::setSwingV
void setSwingV(const bool on)
Set the Vertical Swing setting of the A/C.
Definition: ir_Airton.cpp:257
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:49