IRremoteESP8266
Loading...
Searching...
No Matches
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
57const uint8_t kAirtonAuto = 0b000; // 0
58const uint8_t kAirtonCool = 0b001; // 1
59const uint8_t kAirtonDry = 0b010; // 2
60const uint8_t kAirtonFan = 0b011; // 3
61const uint8_t kAirtonHeat = 0b100; // 4
62
63const uint8_t kAirtonFanAuto = 0b000; // 0
64const uint8_t kAirtonFanMin = 0b001; // 1
65const uint8_t kAirtonFanLow = 0b010; // 2
66const uint8_t kAirtonFanMed = 0b011; // 3
67const uint8_t kAirtonFanHigh = 0b100; // 4
68const uint8_t kAirtonFanMax = 0b101; // 5
69
70const uint8_t kAirtonMinTemp = 16; // 16C
71const uint8_t kAirtonMaxTemp = 31; // 31C
72
73
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
128 IRsendTest _irsend;
130#endif // UNIT_TEST
132 void checksum(void);
133};
134#endif // IR_AIRTON_H_
const uint16_t kAirtonDefaultRepeat
Definition IRremoteESP8266.h:1176
std::string String
Definition IRremoteESP8266.h:1564
Class for handling detailed Airton 56-bit A/C messages.
Definition ir_Airton.h:75
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition ir_Airton.cpp:244
AirtonProtocol _
Definition ir_Airton.h:131
void setTemp(const uint8_t degrees)
Set the temperature.
Definition ir_Airton.cpp:205
void setPower(const bool on)
Set the internal state to have the desired power.
Definition ir_Airton.cpp:140
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
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
bool getLight(void) const
Get the Light/LED/Display setting of the A/C.
Definition ir_Airton.cpp:269
static bool validChecksum(const uint64_t data)
Verify the checksum is valid for a given state.
Definition ir_Airton.cpp:107
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition ir_Airton.cpp:193
void off(void)
Set the internal state to have the power off.
Definition ir_Airton.cpp:136
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition ir_Airton.cpp:219
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition ir_Airton.cpp:319
bool getTurbo(void) const
Get the Turbo setting of the A/C.
Definition ir_Airton.cpp:292
bool getSwingV(void) const
Get the Vertical Swing setting of the A/C.
Definition ir_Airton.cpp:261
bool getSleep(void) const
Get the Sleep setting of the A/C.
Definition ir_Airton.cpp:307
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition ir_Airton.cpp:297
void on(void)
Set the internal state to have the power on.
Definition ir_Airton.cpp:133
void setHealth(const bool on)
Set the Health/Filter setting of the A/C.
Definition ir_Airton.cpp:311
void setEcono(const bool on)
Set the Economy setting of the A/C.
Definition ir_Airton.cpp:274
uint8_t getTemp(void) const
Get the current temperature setting.
Definition ir_Airton.cpp:214
uint8_t getMode(void) const
Get the current operation mode setting.
Definition ir_Airton.cpp:151
void stateReset(void)
Reset the internals of the object to a known good state.
Definition ir_Airton.cpp:117
void checksum(void)
Update the checksum value for the internal state.
Definition ir_Airton.cpp:114
bool getPower(void) const
Get the power setting from the internal state.
Definition ir_Airton.cpp:147
void setMode(const uint8_t mode)
Set the desired operation mode.
Definition ir_Airton.cpp:155
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition ir_Airton.cpp:180
bool getEcono(void) const
Get the Economy setting of the A/C.
Definition ir_Airton.cpp:280
void send(const uint16_t repeat=kAirtonDefaultRepeat)
Send the current internal state as an IR message.
Definition ir_Airton.cpp:92
static uint8_t convertSwingV(const stdAc::swingv_t position)
bool getHealth(void) const
Get the Health/Filter setting of the A/C.
Definition ir_Airton.cpp:315
uint8_t getFan(void) const
Get the current fan speed setting.
Definition ir_Airton.cpp:225
void setLight(const bool on)
Set the Light/LED/Display setting of the A/C.
Definition ir_Airton.cpp:265
void setTurbo(const bool on)
Set the Turbo setting of the A/C.
Definition ir_Airton.cpp:284
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition ir_Airton.h:86
void setSwingV(const bool on)
Set the Vertical Swing setting of the A/C.
Definition ir_Airton.cpp:257
IRsend _irsend
Instance of the IR send class.
Definition ir_Airton.h:125
String toString(void) const
Convert the current internal state into a human readable string.
Definition ir_Airton.cpp:345
void begin(void)
Set up hardware to be able to send a message.
Definition ir_Airton.cpp:87
static uint8_t calcChecksum(const uint64_t data)
Calculate the checksum for the supplied state.
Definition ir_Airton.cpp:100
void setRaw(const uint64_t data)
Set the raw state of the object.
Definition ir_Airton.cpp:129
Class for sending all basic IR protocols.
Definition IRsend.h:249
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition IRsend.cpp:209
const uint8_t kAirtonFan
Definition ir_Airton.h:60
const uint8_t kAirtonMinTemp
Definition ir_Airton.h:70
const uint8_t kAirtonFanAuto
Definition ir_Airton.h:63
const uint8_t kAirtonFanMax
Definition ir_Airton.h:68
const uint8_t kAirtonFanMed
Definition ir_Airton.h:66
const uint8_t kAirtonFanLow
Definition ir_Airton.h:65
const uint8_t kAirtonMaxTemp
Definition ir_Airton.h:71
const uint8_t kAirtonFanHigh
Definition ir_Airton.h:67
const uint8_t kAirtonCool
Definition ir_Airton.h:58
const uint8_t kAirtonFanMin
Definition ir_Airton.h:64
const uint8_t kAirtonAuto
Definition ir_Airton.h:57
const uint8_t kAirtonHeat
Definition ir_Airton.h:61
const uint8_t kAirtonDry
Definition ir_Airton.h:59
fanspeed_t
Common A/C settings for Fan Speeds.
Definition IRsend.h:61
opmode_t
Common A/C settings for A/C operating modes.
Definition IRsend.h:49
swingv_t
Common A/C settings for Vertical Swing.
Definition IRsend.h:74
Structure to hold a common A/C state.
Definition IRsend.h:114
Native representation of a Airton 56 A/C message.
Definition ir_Airton.h:26
uint8_t Health
Definition ir_Airton.h:49
uint8_t SwingV
Definition ir_Airton.h:40
uint8_t Light
Definition ir_Airton.h:50
uint8_t Sum
Definition ir_Airton.h:52
uint8_t Temp
Definition ir_Airton.h:37
uint16_t Header
Definition ir_Airton.h:30
uint64_t raw
The state in code form.
Definition ir_Airton.h:27
uint8_t Mode
Definition ir_Airton.h:32
uint8_t NotAutoOn
Definition ir_Airton.h:45
uint8_t Fan
Definition ir_Airton.h:34
uint8_t Power
Definition ir_Airton.h:33
uint8_t Turbo
Definition ir_Airton.h:35
uint8_t Sleep
Definition ir_Airton.h:44
uint8_t Econo
Definition ir_Airton.h:43
uint8_t HeatOn
Definition ir_Airton.h:47