IRremoteESP8266
ir_Teco.h
Go to the documentation of this file.
1 // Copyright 2019 Fabien Valthier
2 
5 
6 // Supports:
7 // Brand: Alaska, Model: SAC9010QC A/C
8 // Brand: Alaska, Model: SAC9010QC remote
9 
10 #ifndef IR_TECO_H_
11 #define IR_TECO_H_
12 
13 #ifndef UNIT_TEST
14 #include <Arduino.h>
15 #endif
16 #include "IRremoteESP8266.h"
17 #include "IRsend.h"
18 #ifdef UNIT_TEST
19 #include "IRsend_test.h"
20 #endif
21 
24  uint64_t raw;
25  struct {
26  uint8_t Mode :3;
27  uint8_t Power :1;
28  uint8_t Fan :2;
29  uint8_t Swing :1;
30  uint8_t Sleep :1;
31  uint8_t Temp :4;
32  uint8_t HalfHour :1;
33  uint8_t TensHours :2; // number of 10hours
34  uint8_t TimerOn :1;
35  uint8_t UnitHours :4; // unit, not thenth
36  uint8_t Humid :1;
37  uint8_t Light :1;
38  uint8_t :1; // "Tree with bubbles" / Filter?? (Not Implemented)
39  uint8_t Save :1;
40  uint8_t :8; // Cst 0x50
41  uint8_t :8; // Cst 0x02
42  };
43 };
44 
45 // Constants.
46 const uint8_t kTecoAuto = 0; // temp = 25C
47 const uint8_t kTecoCool = 1;
48 const uint8_t kTecoDry = 2; // temp = 25C, but not shown
49 const uint8_t kTecoFan = 3;
50 const uint8_t kTecoHeat = 4;
51 const uint8_t kTecoFanAuto = 0; // 0b00
52 const uint8_t kTecoFanLow = 1; // 0b01
53 const uint8_t kTecoFanMed = 2; // 0b10
54 const uint8_t kTecoFanHigh = 3; // 0b11
55 const uint8_t kTecoMinTemp = 16; // 16C
56 const uint8_t kTecoMaxTemp = 30; // 30C
57 
58 const uint64_t kTecoReset = 0b01001010000000000000010000000000000;
59 
60 // Classes
62 class IRTecoAc {
63  public:
64  explicit IRTecoAc(const uint16_t pin, const bool inverted = false,
65  const bool use_modulation = true);
66  void stateReset(void);
67 #if SEND_TECO
68  void send(const uint16_t repeat = kTecoDefaultRepeat);
73  int8_t calibrate(void) { return _irsend.calibrate(); }
74 #endif // SEND_TECO
75  void begin(void);
76  void on(void);
77  void off(void);
78 
79  void setPower(const bool on);
80  bool getPower(void) const;
81 
82  void setTemp(const uint8_t temp);
83  uint8_t getTemp(void) const;
84 
85  void setFan(const uint8_t fan);
86  uint8_t getFan(void) const;
87 
88  void setMode(const uint8_t mode);
89  uint8_t getMode(void) const;
90 
91  void setSwing(const bool on);
92  bool getSwing(void) const;
93 
94  void setSleep(const bool on);
95  bool getSleep(void) const;
96 
97  void setLight(const bool on);
98  bool getLight(void) const;
99 
100  void setHumid(const bool on);
101  bool getHumid(void) const;
102 
103  void setSave(const bool on);
104  bool getSave(void) const;
105 
106  uint16_t getTimer(void) const;
107  void setTimer(const uint16_t mins);
108 
109  uint64_t getRaw(void) const;
110  void setRaw(const uint64_t new_code);
111 
112  static uint8_t convertMode(const stdAc::opmode_t mode);
113  static uint8_t convertFan(const stdAc::fanspeed_t speed);
114  static stdAc::opmode_t toCommonMode(const uint8_t mode);
115  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
116  stdAc::state_t toCommon(void) const;
117  String toString(void) const;
118 #ifndef UNIT_TEST
119 
120  private:
122 #else // UNIT_TEST
123  IRsendTest _irsend;
125 #endif // UNIT_TEST
128  bool getTimerEnabled(void) const;
129 };
130 
131 #endif // IR_TECO_H_
TecoProtocol::TensHours
uint8_t TensHours
Definition: ir_Teco.h:33
TecoProtocol::TimerOn
uint8_t TimerOn
Definition: ir_Teco.h:34
IRTecoAc::toString
String toString(void) const
Convert the current internal state into a human readable string.
Definition: ir_Teco.cpp:322
kTecoFanMed
const uint8_t kTecoFanMed
Definition: ir_Teco.h:53
kTecoReset
const uint64_t kTecoReset
Definition: ir_Teco.h:58
IRTecoAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Teco.cpp:272
IRTecoAc::off
void off(void)
Set the requested power state of the A/C to off.
Definition: ir_Teco.cpp:82
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:61
IRTecoAc::getLight
bool getLight(void) const
Get the Light (LED/Display) setting of the A/C.
Definition: ir_Teco.cpp:184
IRTecoAc::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Teco.cpp:245
TecoProtocol::Swing
uint8_t Swing
Definition: ir_Teco.h:29
IRTecoAc::getMode
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition: ir_Teco.cpp:148
TecoProtocol::Humid
uint8_t Humid
Definition: ir_Teco.h:36
IRTecoAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Teco.h:73
IRsend.h
TecoProtocol::Save
uint8_t Save
Definition: ir_Teco.h:39
kTecoMinTemp
const uint8_t kTecoMinTemp
Definition: ir_Teco.h:55
IRTecoAc::setRaw
void setRaw(const uint64_t new_code)
Set the internal state from a valid code for this protocol.
Definition: ir_Teco.cpp:76
IRTecoAc::IRTecoAc
IRTecoAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Teco.cpp:49
kTecoMaxTemp
const uint8_t kTecoMaxTemp
Definition: ir_Teco.h:56
TecoProtocol::UnitHours
uint8_t UnitHours
Definition: ir_Teco.h:35
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:237
IRTecoAc::on
void on(void)
Set the requested power state of the A/C to on.
Definition: ir_Teco.cpp:79
kTecoDry
const uint8_t kTecoDry
Definition: ir_Teco.h:48
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
kTecoHeat
const uint8_t kTecoHeat
Definition: ir_Teco.h:50
IRTecoAc::getTimer
uint16_t getTimer(void) const
Get the timer time for when the A/C unit will switch power state.
Definition: ir_Teco.cpp:220
String
std::string String
Definition: IRremoteESP8266.h:1521
TecoProtocol
Native representation of a Teco A/C message.
Definition: ir_Teco.h:23
IRTecoAc::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Teco.cpp:86
IRTecoAc::setSwing
void setSwing(const bool on)
Set the (vertical) swing setting of the A/C.
Definition: ir_Teco.cpp:154
IRremoteESP8266.h
IRTecoAc::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_Teco.cpp:107
IRTecoAc::getSleep
bool getSleep(void) const
Get the Sleep setting of the A/C.
Definition: ir_Teco.cpp:172
IRTecoAc::setHumid
void setHumid(const bool on)
Set the Humid setting of the A/C.
Definition: ir_Teco.cpp:190
IRTecoAc::getPower
bool getPower(void) const
Get the value of the current power setting.
Definition: ir_Teco.cpp:92
IRTecoAc::setTimer
void setTimer(const uint16_t mins)
Set the timer for when the A/C unit will switch power state.
Definition: ir_Teco.cpp:233
kTecoFanLow
const uint8_t kTecoFanLow
Definition: ir_Teco.h:52
IRTecoAc::setSleep
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition: ir_Teco.cpp:166
IRTecoAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Teco.cpp:54
kTecoDefaultRepeat
const uint16_t kTecoDefaultRepeat
Definition: IRremoteESP8266.h:1396
TecoProtocol::Temp
uint8_t Temp
Definition: ir_Teco.h:31
kTecoFanAuto
const uint8_t kTecoFanAuto
Definition: ir_Teco.h:51
TecoProtocol::Fan
uint8_t Fan
Definition: ir_Teco.h:28
IRTecoAc::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_Teco.cpp:127
kTecoCool
const uint8_t kTecoCool
Definition: ir_Teco.h:47
IRTecoAc::getTimerEnabled
bool getTimerEnabled(void) const
Is the timer function enabled?
Definition: ir_Teco.cpp:214
IRTecoAc::getSwing
bool getSwing(void) const
Get the (vertical) swing setting of the A/C.
Definition: ir_Teco.cpp:160
IRTecoAc::setTemp
void setTemp(const uint8_t temp)
Set the temperature.
Definition: ir_Teco.cpp:98
IRTecoAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Teco.cpp:133
IRTecoAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Teco.cpp:285
IRTecoAc::getHumid
bool getHumid(void) const
Get the Humid setting of the A/C.
Definition: ir_Teco.cpp:196
IRTecoAc::setSave
void setSave(const bool on)
Set the Save setting of the A/C.
Definition: ir_Teco.cpp:202
IRTecoAc::stateReset
void stateReset(void)
Reset the internal state of the emulation.
Definition: ir_Teco.cpp:66
IRTecoAc::_
TecoProtocol _
Definition: ir_Teco.h:127
TecoProtocol::HalfHour
uint8_t HalfHour
Definition: ir_Teco.h:32
IRTecoAc::getRaw
uint64_t getRaw(void) const
Get a copy of the internal state/code for this protocol.
Definition: ir_Teco.cpp:72
kTecoFan
const uint8_t kTecoFan
Definition: ir_Teco.h:49
TecoProtocol::Light
uint8_t Light
Definition: ir_Teco.h:37
IRTecoAc::getSave
bool getSave(void) const
Get the Save setting of the A/C.
Definition: ir_Teco.cpp:208
TecoProtocol::Power
uint8_t Power
Definition: ir_Teco.h:27
IRTecoAc
Class for handling detailed Teco A/C messages.
Definition: ir_Teco.h:62
IRTecoAc::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Teco.cpp:258
TecoProtocol::Sleep
uint8_t Sleep
Definition: ir_Teco.h:30
TecoProtocol::Mode
uint8_t Mode
Definition: ir_Teco.h:26
IRTecoAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Teco.h:121
TecoProtocol::raw
uint64_t raw
The state of the IR remote in IR code form.
Definition: ir_Teco.h:24
IRTecoAc::setLight
void setLight(const bool on)
Set the Light (LED/Display) setting of the A/C.
Definition: ir_Teco.cpp:178
IRTecoAc::send
void send(const uint16_t repeat=kTecoDefaultRepeat)
Send the current internal state as an IR message.
Definition: ir_Teco.cpp:59
kTecoFanHigh
const uint8_t kTecoFanHigh
Definition: ir_Teco.h:54
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:114
IRTecoAc::toCommon
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Teco.cpp:296
kTecoAuto
const uint8_t kTecoAuto
Definition: ir_Teco.h:46
IRTecoAc::setFan
void setFan(const uint8_t fan)
Set the speed of the fan.
Definition: ir_Teco.cpp:113
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:49