# IRremoteESP8266: src/ir_Teco.h Source File

ir_Teco.h
Go to the documentation of this file.
// Copyright 2019 Fabien Valthier
// Supports:
// Brand: Alaska, Model: SAC9010QC A/C
// Brand: Alaska, Model: SAC9010QC remote
#ifndef IR_TECO_H_
#define IR_TECO_H_
#ifndef UNIT_TEST
#include <Arduino.h>
#endif
#include "IRremoteESP8266.h"
#include "IRsend.h"
#ifdef UNIT_TEST
#include "IRsend_test.h"
#endif
// Constants.
const uint8_t kTecoAuto = 0;
const uint8_t kTecoCool = 1;
const uint8_t kTecoDry = 2;
const uint8_t kTecoFan = 3;
const uint8_t kTecoHeat = 4;
const uint8_t kTecoFanAuto = 0; // 0b00
const uint8_t kTecoFanLow = 1; // 0b01
const uint8_t kTecoFanMed = 2; // 0b10
const uint8_t kTecoFanHigh = 3; // 0b11
const uint8_t kTecoMinTemp = 16; // 16C
const uint8_t kTecoMaxTemp = 30; // 30C
const uint8_t kTecoModeOffset = 0;
const uint8_t kTecoPowerOffset = 3;
const uint8_t kTecoFanOffset = 4;
const uint8_t kTecoFanSize = 2; // Nr. of bits
const uint8_t kTecoSwingOffset = 6;
const uint8_t kTecoSleepOffset = 7;
const uint8_t kTecoTempOffset = 8;
const uint8_t kTecoTempSize = 4; // Nr. of bits
const uint8_t kTecoTimerHalfHourOffset = 12;
const uint8_t kTecoTimerTensHoursOffset = 13;
const uint8_t kTecoTimerTensHoursSize = 2; // Nr. of bits
const uint8_t kTecoTimerOnOffset = 15;
const uint8_t kTecoTimerUnitHoursOffset = 16;
const uint8_t kTecoTimerUnitHoursSize = 4; // Nr. of bits
const uint8_t kTecoHumidOffset = 20;
const uint8_t kTecoLightOffset = 21;
const uint8_t kTecoSaveOffset = 23;
const uint64_t kTecoReset = 0b01001010000000000000010000000000000;
/*
(header mark and space)
Teco AC map read and to be sent in LSB with number of bits
byte 0 = Cst 0x02
byte 1 = Cst 0x50
b6-7 = "AIR" 0, 1, 2 (Not Implemented)
byte 2:
b0 = Save
b1 = "Tree with bubbles" / Filter?? (Not Implemented)
b2 = Light/LED.
b3 = Humid
b4-7 = Timer hours (unit, not thenth)
hours:
0000 (0) = +0 hour
0001 (1) = +1 hour
...
1001 (9) = +9 hours
byte 3: = timer and Temperature
b0 = Timer (1 = On, 0 = Off)
b1-2 = Timer - number of 10hours
10Hours:
00 = 0 * 10hours of timer
01 = 1 * 10 hours of timer
10 = 2 * 10hours of timer
b3 = Timer - half hour (1=half hour on, 0 = round hour)
b4-7: Degrees C.
0000 (0) = 16C
0001 (1) = 17C
0010 (2) = 18C
...
1101 (13) = 29C
1110 (14) = 30C
byte 4: Basics
b0 = Sleep Mode (1 = On, 0 = Off)
b1 = Vent swing (1 = On, 0 = Off)
b2-3 = Fan
Fan:
00 = Auto
01 = Fan 1
10 = Fan 2
11 = Fan 3 or higher
b4 = Power Status (1 = On, 0 = Off)
b5-7 = Modes LSB first
Modes:
000 = Auto (temp = 25C)
001 = Cool
010 = Dry (temp = 25C, but not shown)
011 = Fan
100 = Heat
*/
// Classes
class IRTecoAc {
public:
explicit IRTecoAc(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
void stateReset(void);
#if SEND_TECO
void send(const uint16_t repeat = kTecoDefaultRepeat);
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif // SEND_TECO
void begin(void);
void on(void);
void off(void);
void setPower(const bool on);
bool getPower(void);
void setTemp(const uint8_t temp);
uint8_t getTemp(void);
void setFan(const uint8_t fan);
uint8_t getFan(void);
void setMode(const uint8_t mode);
uint8_t getMode(void);
void setSwing(const bool on);
bool getSwing(void);
void setSleep(const bool on);
bool getSleep(void);
void setLight(const bool on);
bool getLight(void);
void setHumid(const bool on);
bool getHumid(void);
void setSave(const bool on);
bool getSave(void);
uint16_t getTimer(void);
void setTimer(const uint16_t mins);
uint64_t getRaw(void);
void setRaw(const uint64_t new_code);
uint8_t convertMode(const stdAc::opmode_t mode);
uint8_t convertFan(const stdAc::fanspeed_t speed);
static stdAc::opmode_t toCommonMode(const uint8_t mode);
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
stdAc::state_t toCommon(void);
String toString(void);
#ifndef UNIT_TEST
private:
IRsend _irsend;
#else // UNIT_TEST
IRsendTest _irsend;
#endif // UNIT_TEST
uint64_t remote_state;
bool getTimerEnabled(void);
};
#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 equivalent.
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:182
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:1178
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:1075
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 equivalent.
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 equivalent.
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