IRremoteESP8266
ir_Airwell.h
Go to the documentation of this file.
1 // Copyright 2020 David Conran
2 
6 
7 // Supports:
8 // Brand: Airwell, Model: RC08W remote
9 // Brand: Airwell, Model: RC04 remote
10 // Brand: Airwell, Model: DLS 21 DCI R410 AW A/C
11 
12 #ifndef IR_AIRWELL_H_
13 #define IR_AIRWELL_H_
14 
15 #define __STDC_LIMIT_MACROS
16 #include <stdint.h>
17 #ifndef UNIT_TEST
18 #include <Arduino.h>
19 #endif
20 #include "IRremoteESP8266.h"
21 #include "IRsend.h"
22 #ifdef UNIT_TEST
23 #include "IRsend_test.h"
24 #endif
25 
26 
27 // Constants
28 const uint64_t kAirwellKnownGoodState = 0x140500002; // Mode Fan, Speed 1, 25C
29 // Temperature
30 const uint8_t kAirwellMinTemp = 16; // Celsius
31 const uint8_t kAirwellMaxTemp = 30; // Celsius
32 const uint8_t kAirwellTempSize = 4; // Bits
33 const uint8_t kAirwellTempOffset = 19; // 0b1111 << 19
34 // Fan
35 const uint8_t kAirwellFanSize = 2; // Bits
36 const uint8_t kAirwellFanOffset = 28; // 0b11 << 28
37 const uint8_t kAirwellFanLow = 0; // 0b00
38 const uint8_t kAirwellFanMedium = 1; // 0b01
39 const uint8_t kAirwellFanHigh = 2; // 0b10
40 const uint8_t kAirwellFanAuto = 3; // 0b11
41 // Modes
42 const uint8_t kAirwellModeSize = 3; // Bits
43 const uint8_t kAirwellModeOffset = 30; // 0b111 << 30
44 const uint8_t kAirwellCool = 1; // 0b001
45 const uint8_t kAirwellHeat = 2; // 0b010
46 const uint8_t kAirwellAuto = 3; // 0b011
47 const uint8_t kAirwellDry = 4; // 0b100
48 const uint8_t kAirwellFan = 5; // 0b101
49 // Power
50 const uint8_t kAirwellPowerToggleBit = 33; // 0b1 << 33
51 
52 
53 // Classes
55 class IRAirwellAc {
56  public:
57  explicit IRAirwellAc(const uint16_t pin, const bool inverted = false,
58  const bool use_modulation = true);
59  void stateReset();
60 #if SEND_AIRWELL
61  void send(const uint16_t repeat = kAirwellMinRepeats);
66  int8_t calibrate(void) { return _irsend.calibrate(); }
67 #endif // SEND_AIRWELL
68  void begin();
69  void setPowerToggle(const bool on);
70  bool getPowerToggle();
71  void setTemp(const uint8_t temp);
72  uint8_t getTemp();
73  void setFan(const uint8_t speed);
74  uint8_t getFan();
75  void setMode(const uint8_t mode);
76  uint8_t getMode();
77  uint64_t getRaw();
78  void setRaw(const uint64_t state);
79  uint8_t convertMode(const stdAc::opmode_t mode);
80  uint8_t convertFan(const stdAc::fanspeed_t speed);
81  static stdAc::opmode_t toCommonMode(const uint8_t mode);
82  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
84  String toString();
85 #ifndef UNIT_TEST
86 
87  private:
89 #else
90  IRsendTest _irsend;
92 #endif
94  uint64_t remote_state; // The state of the IR remote in native IR code form.
95  void checksum(void);
96 };
97 #endif // IR_AIRWELL_H_
kAirwellFanSize
const uint8_t kAirwellFanSize
Definition: ir_Airwell.h:35
kAirwellMinRepeats
const uint16_t kAirwellMinRepeats
Definition: IRremoteESP8266.h:822
IRAirwellAc::remote_state
uint64_t remote_state
Definition: ir_Airwell.h:94
kAirwellFanHigh
const uint8_t kAirwellFanHigh
Definition: ir_Airwell.h:39
kAirwellModeOffset
const uint8_t kAirwellModeOffset
Definition: ir_Airwell.h:43
IRAirwellAc::send
void send(const uint16_t repeat=kAirwellMinRepeats)
Send the current internal state as an IR message.
Definition: ir_Airwell.cpp:110
IRAirwellAc::setTemp
void setTemp(const uint8_t temp)
Set the temperature.
Definition: ir_Airwell.cpp:228
IRAirwellAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Airwell.h:88
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
kAirwellCool
const uint8_t kAirwellCool
Definition: ir_Airwell.h:44
IRAirwellAc::IRAirwellAc
IRAirwellAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Airwell.cpp:87
kAirwellHeat
const uint8_t kAirwellHeat
Definition: ir_Airwell.h:45
IRAirwellAc::setMode
void setMode(const uint8_t mode)
Set the desired operation mode.
Definition: ir_Airwell.cpp:140
IRsend.h
kAirwellMinTemp
const uint8_t kAirwellMinTemp
Definition: ir_Airwell.h:30
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:170
kAirwellFanAuto
const uint8_t kAirwellFanAuto
Definition: ir_Airwell.h:40
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
kAirwellFan
const uint8_t kAirwellFan
Definition: ir_Airwell.h:48
String
std::string String
Definition: IRremoteESP8266.h:1107
IRAirwellAc::getTemp
uint8_t getTemp()
Get the current temperature setting.
Definition: ir_Airwell.cpp:237
IRAirwellAc::getRaw
uint64_t getRaw()
Get the raw state of the object, suitable to be sent with the appropriate IRsend object method.
Definition: ir_Airwell.cpp:97
IRAirwellAc::toString
String toString()
Convert the current internal state into a human readable string.
Definition: ir_Airwell.cpp:270
IRremoteESP8266.h
kAirwellTempOffset
const uint8_t kAirwellTempOffset
Definition: ir_Airwell.h:33
kAirwellFanLow
const uint8_t kAirwellFanLow
Definition: ir_Airwell.h:37
kAirwellAuto
const uint8_t kAirwellAuto
Definition: ir_Airwell.h:46
IRAirwellAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Airwell.h:66
IRAirwellAc::stateReset
void stateReset()
Reset the internals of the object to a known good state.
Definition: ir_Airwell.cpp:116
IRAirwellAc::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Airwell.cpp:184
IRAirwellAc::convertMode
uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Airwell.cpp:158
kAirwellMaxTemp
const uint8_t kAirwellMaxTemp
Definition: ir_Airwell.h:31
IRAirwellAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivilant.
Definition: ir_Airwell.cpp:171
kAirwellFanOffset
const uint8_t kAirwellFanOffset
Definition: ir_Airwell.h:36
kAirwellTempSize
const uint8_t kAirwellTempSize
Definition: ir_Airwell.h:32
IRAirwellAc::getPowerToggle
bool getPowerToggle()
Get the power toggle setting from the internal state.
Definition: ir_Airwell.cpp:128
IRAirwellAc
Class for handling detailed Airwell A/C messages.
Definition: ir_Airwell.h:55
kAirwellKnownGoodState
const uint64_t kAirwellKnownGoodState
Definition: ir_Airwell.h:28
kAirwellPowerToggleBit
const uint8_t kAirwellPowerToggleBit
Definition: ir_Airwell.h:50
IRAirwellAc::getMode
uint8_t getMode()
Get the current operation mode setting.
Definition: ir_Airwell.cpp:134
IRAirwellAc::getFan
uint8_t getFan()
Get the current fan speed setting.
Definition: ir_Airwell.cpp:192
IRAirwellAc::checksum
void checksum(void)
IRAirwellAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivilant.
Definition: ir_Airwell.cpp:217
IRAirwellAc::toCommon
stdAc::state_t toCommon(void)
Convert the current internal state into its stdAc::state_t equivilant.
Definition: ir_Airwell.cpp:244
kAirwellModeSize
const uint8_t kAirwellModeSize
Definition: ir_Airwell.h:42
IRAirwellAc::convertFan
uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Airwell.cpp:199
IRAirwellAc::setPowerToggle
void setPowerToggle(const bool on)
Turn on/off the Power Airwell setting.
Definition: ir_Airwell.cpp:122
IRAirwellAc::begin
void begin()
Set up hardware to be able to send a message.
Definition: ir_Airwell.cpp:92
kAirwellFanMedium
const uint8_t kAirwellFanMedium
Definition: ir_Airwell.h:38
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
kAirwellDry
const uint8_t kAirwellDry
Definition: ir_Airwell.h:47
IRAirwellAc::setRaw
void setRaw(const uint64_t state)
Set the raw state of the object.
Definition: ir_Airwell.cpp:103
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46