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 
22 // Constants.
23 const uint8_t kTecoAuto = 0;
24 const uint8_t kTecoCool = 1;
25 const uint8_t kTecoDry = 2;
26 const uint8_t kTecoFan = 3;
27 const uint8_t kTecoHeat = 4;
28 const uint8_t kTecoFanAuto = 0; // 0b00
29 const uint8_t kTecoFanLow = 1; // 0b01
30 const uint8_t kTecoFanMed = 2; // 0b10
31 const uint8_t kTecoFanHigh = 3; // 0b11
32 const uint8_t kTecoMinTemp = 16; // 16C
33 const uint8_t kTecoMaxTemp = 30; // 30C
34 
35 const uint8_t kTecoModeOffset = 0;
36 const uint8_t kTecoPowerOffset = 3;
37 const uint8_t kTecoFanOffset = 4;
38 const uint8_t kTecoFanSize = 2; // Nr. of bits
39 const uint8_t kTecoSwingOffset = 6;
40 const uint8_t kTecoSleepOffset = 7;
41 const uint8_t kTecoTempOffset = 8;
42 const uint8_t kTecoTempSize = 4; // Nr. of bits
43 const uint8_t kTecoTimerHalfHourOffset = 12;
44 const uint8_t kTecoTimerTensHoursOffset = 13;
45 const uint8_t kTecoTimerTensHoursSize = 2; // Nr. of bits
46 const uint8_t kTecoTimerOnOffset = 15;
47 const uint8_t kTecoTimerUnitHoursOffset = 16;
48 const uint8_t kTecoTimerUnitHoursSize = 4; // Nr. of bits
49 const uint8_t kTecoHumidOffset = 20;
50 const uint8_t kTecoLightOffset = 21;
51 const uint8_t kTecoSaveOffset = 23;
52 const uint64_t kTecoReset = 0b01001010000000000000010000000000000;
53 /*
54  (header mark and space)
55  Teco AC map read and to be sent in LSB with number of bits
56 
57  byte 0 = Cst 0x02
58  byte 1 = Cst 0x50
59  b6-7 = "AIR" 0, 1, 2 (Not Implemented)
60  byte 2:
61  b0 = Save
62  b1 = "Tree with bubbles" / Filter?? (Not Implemented)
63  b2 = Light/LED.
64  b3 = Humid
65  b4-7 = Timer hours (unit, not thenth)
66  hours:
67  0000 (0) = +0 hour
68  0001 (1) = +1 hour
69  ...
70  1001 (9) = +9 hours
71  byte 3: = timer and Temperature
72  b0 = Timer (1 = On, 0 = Off)
73  b1-2 = Timer - number of 10hours
74  10Hours:
75  00 = 0 * 10hours of timer
76  01 = 1 * 10 hours of timer
77  10 = 2 * 10hours of timer
78  b3 = Timer - half hour (1=half hour on, 0 = round hour)
79  b4-7: Degrees C.
80  0000 (0) = 16C
81  0001 (1) = 17C
82  0010 (2) = 18C
83  ...
84  1101 (13) = 29C
85  1110 (14) = 30C
86  byte 4: Basics
87  b0 = Sleep Mode (1 = On, 0 = Off)
88  b1 = Vent swing (1 = On, 0 = Off)
89  b2-3 = Fan
90  Fan:
91  00 = Auto
92  01 = Fan 1
93  10 = Fan 2
94  11 = Fan 3 or higher
95  b4 = Power Status (1 = On, 0 = Off)
96  b5-7 = Modes LSB first
97  Modes:
98  000 = Auto (temp = 25C)
99  001 = Cool
100  010 = Dry (temp = 25C, but not shown)
101  011 = Fan
102  100 = Heat
103 */
104 
105 // Classes
107 class IRTecoAc {
108  public:
109  explicit IRTecoAc(const uint16_t pin, const bool inverted = false,
110  const bool use_modulation = true);
111  void stateReset(void);
112 #if SEND_TECO
113  void send(const uint16_t repeat = kTecoDefaultRepeat);
118  int8_t calibrate(void) { return _irsend.calibrate(); }
119 #endif // SEND_TECO
120  void begin(void);
121  void on(void);
122  void off(void);
123 
124  void setPower(const bool on);
125  bool getPower(void);
126 
127  void setTemp(const uint8_t temp);
128  uint8_t getTemp(void);
129 
130  void setFan(const uint8_t fan);
131  uint8_t getFan(void);
132 
133  void setMode(const uint8_t mode);
134  uint8_t getMode(void);
135 
136  void setSwing(const bool on);
137  bool getSwing(void);
138 
139  void setSleep(const bool on);
140  bool getSleep(void);
141 
142  void setLight(const bool on);
143  bool getLight(void);
144 
145  void setHumid(const bool on);
146  bool getHumid(void);
147 
148  void setSave(const bool on);
149  bool getSave(void);
150 
151  uint16_t getTimer(void);
152  void setTimer(const uint16_t mins);
153 
154  uint64_t getRaw(void);
155  void setRaw(const uint64_t new_code);
156 
157  uint8_t convertMode(const stdAc::opmode_t mode);
158  uint8_t convertFan(const stdAc::fanspeed_t speed);
159  static stdAc::opmode_t toCommonMode(const uint8_t mode);
160  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
161  stdAc::state_t toCommon(void);
162  String toString(void);
163 #ifndef UNIT_TEST
164 
165  private:
167 #else // UNIT_TEST
168  IRsendTest _irsend;
170 #endif // UNIT_TEST
172  uint64_t remote_state;
173  bool getTimerEnabled(void);
174 };
175 
176 #endif // IR_TECO_H_
IRTecoAc::getSwing
bool getSwing(void)
Get the (vertical) swing setting of the A/C.
Definition: ir_Teco.cpp:163
kTecoFanMed
const uint8_t kTecoFanMed
Definition: ir_Teco.h:30
IRTecoAc::getHumid
bool getHumid(void)
Get the Humid setting of the A/C.
Definition: ir_Teco.cpp:199
kTecoTempOffset
const uint8_t kTecoTempOffset
Definition: ir_Teco.h:41
IRTecoAc::getPower
bool getPower(void)
Get the value of the current power setting.
Definition: ir_Teco.cpp:94
kTecoPowerOffset
const uint8_t kTecoPowerOffset
Definition: ir_Teco.h:36
kTecoReset
const uint64_t kTecoReset
Definition: ir_Teco.h:52
IRTecoAc::getTimerEnabled
bool getTimerEnabled(void)
Is the timer function enabled?
Definition: ir_Teco.cpp:217
IRTecoAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivilant.
Definition: ir_Teco.cpp:283
IRTecoAc::off
void off(void)
Set the requested power state of the A/C to off.
Definition: ir_Teco.cpp:84
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
IRTecoAc::getSleep
bool getSleep(void)
Get the Sleep setting of the A/C.
Definition: ir_Teco.cpp:175
kTecoModeOffset
const uint8_t kTecoModeOffset
Definition: ir_Teco.h:35
IRTecoAc::convertMode
uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Teco.cpp:256
IRTecoAc::getTimer
uint16_t getTimer(void)
Get the timer time for when the A/C unit will switch power state.
Definition: ir_Teco.cpp:223
kTecoTempSize
const uint8_t kTecoTempSize
Definition: ir_Teco.h:42
kTecoSleepOffset
const uint8_t kTecoSleepOffset
Definition: ir_Teco.h:40
IRTecoAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Teco.h:118
IRsend.h
kTecoMinTemp
const uint8_t kTecoMinTemp
Definition: ir_Teco.h:32
IRTecoAc::setRaw
void setRaw(const uint64_t new_code)
Set the internal state from a valid code for this protocol.
Definition: ir_Teco.cpp:78
IRTecoAc::IRTecoAc
IRTecoAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Teco.cpp:51
kTecoMaxTemp
const uint8_t kTecoMaxTemp
Definition: ir_Teco.h:33
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:176
IRTecoAc::on
void on(void)
Set the requested power state of the A/C to on.
Definition: ir_Teco.cpp:81
kTecoDry
const uint8_t kTecoDry
Definition: ir_Teco.h:25
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:27
kTecoTimerTensHoursOffset
const uint8_t kTecoTimerTensHoursOffset
Definition: ir_Teco.h:44
kTecoFanOffset
const uint8_t kTecoFanOffset
Definition: ir_Teco.h:37
String
std::string String
Definition: IRremoteESP8266.h:1128
IRTecoAc::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Teco.cpp:88
IRTecoAc::setSwing
void setSwing(const bool on)
Set the (vertical) swing setting of the A/C.
Definition: ir_Teco.cpp:157
kTecoSaveOffset
const uint8_t kTecoSaveOffset
Definition: ir_Teco.h:51
kTecoTimerUnitHoursOffset
const uint8_t kTecoTimerUnitHoursOffset
Definition: ir_Teco.h:47
IRremoteESP8266.h
IRTecoAc::setHumid
void setHumid(const bool on)
Set the Humid setting of the A/C.
Definition: ir_Teco.cpp:193
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:239
kTecoFanLow
const uint8_t kTecoFanLow
Definition: ir_Teco.h:29
IRTecoAc::setSleep
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition: ir_Teco.cpp:169
IRTecoAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Teco.cpp:56
kTecoDefaultRepeat
const uint16_t kTecoDefaultRepeat
Definition: IRremoteESP8266.h:1027
kTecoFanSize
const uint8_t kTecoFanSize
Definition: ir_Teco.h:38
kTecoFanAuto
const uint8_t kTecoFanAuto
Definition: ir_Teco.h:28
IRTecoAc::getLight
bool getLight(void)
Get the Light (LED/Display) setting of the A/C.
Definition: ir_Teco.cpp:187
kTecoCool
const uint8_t kTecoCool
Definition: ir_Teco.h:24
kTecoTimerTensHoursSize
const uint8_t kTecoTimerTensHoursSize
Definition: ir_Teco.h:45
IRTecoAc::getSave
bool getSave(void)
Get the Save setting of the A/C.
Definition: ir_Teco.cpp:211
IRTecoAc::toString
String toString(void)
Convert the current internal state into a human readable string.
Definition: ir_Teco.cpp:334
IRTecoAc::getTemp
uint8_t getTemp(void)
Get the current temperature setting.
Definition: ir_Teco.cpp:110
kTecoTimerUnitHoursSize
const uint8_t kTecoTimerUnitHoursSize
Definition: ir_Teco.h:48
IRTecoAc::setTemp
void setTemp(const uint8_t temp)
Set the temperature.
Definition: ir_Teco.cpp:100
IRTecoAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Teco.cpp:136
IRTecoAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivilant.
Definition: ir_Teco.cpp:296
IRTecoAc::setSave
void setSave(const bool on)
Set the Save setting of the A/C.
Definition: ir_Teco.cpp:205
kTecoHumidOffset
const uint8_t kTecoHumidOffset
Definition: ir_Teco.h:49
kTecoSwingOffset
const uint8_t kTecoSwingOffset
Definition: ir_Teco.h:39
IRTecoAc::stateReset
void stateReset(void)
Reset the internal state of the emulation.
Definition: ir_Teco.cpp:68
IRTecoAc::getRaw
uint64_t getRaw(void)
Get a copy of the internal state/code for this protocol.
Definition: ir_Teco.cpp:74
kTecoLightOffset
const uint8_t kTecoLightOffset
Definition: ir_Teco.h:50
IRTecoAc::getFan
uint8_t getFan(void)
Get the current fan speed setting.
Definition: ir_Teco.cpp:130
kTecoFan
const uint8_t kTecoFan
Definition: ir_Teco.h:26
kTecoTimerOnOffset
const uint8_t kTecoTimerOnOffset
Definition: ir_Teco.h:46
IRTecoAc::getMode
uint8_t getMode(void)
Get the operating mode setting of the A/C.
Definition: ir_Teco.cpp:151
IRTecoAc
Class for handling detailed Teco A/C messages.
Definition: ir_Teco.h:107
IRTecoAc::remote_state
uint64_t remote_state
The state of the IR remote in IR code form.
Definition: ir_Teco.h:172
IRTecoAc::convertFan
uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Teco.cpp:269
IRTecoAc::toCommon
stdAc::state_t toCommon(void)
Convert the current internal state into its stdAc::state_t equivilant.
Definition: ir_Teco.cpp:307
IRTecoAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Teco.h:166
IRTecoAc::setLight
void setLight(const bool on)
Set the Light (LED/Display) setting of the A/C.
Definition: ir_Teco.cpp:181
IRTecoAc::send
void send(const uint16_t repeat=kTecoDefaultRepeat)
Send the current internal state as an IR message.
Definition: ir_Teco.cpp:61
kTecoFanHigh
const uint8_t kTecoFanHigh
Definition: ir_Teco.h:31
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
kTecoAuto
const uint8_t kTecoAuto
Definition: ir_Teco.h:23
IRTecoAc::setFan
void setFan(const uint8_t fan)
Set the speed of the fan.
Definition: ir_Teco.cpp:116
kTecoTimerHalfHourOffset
const uint8_t kTecoTimerHalfHourOffset
Definition: ir_Teco.h:43
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46