# IRremoteESP8266: src/ir_Transcold.h Source File

ir_Transcold.h
Go to the documentation of this file.
// Copyright 2020 Chandrashekar Shetty (iamDshetty)
// Copyright 2020 crankyoldgit
// Supports:
// Brand: Transcold, Model: M1-F-NO-6 A/C
/***************************************************************************************************************
Raw Data Calculation: (UR 12)
//ON button
ON 24 Auto cool close (right) 111011110001000001100001100111100101010010101011
//OFF button
OFF 24 Auto cool close (right) 111011110001000001110001100011100101010010101011
// MODE
Hot mode 24 auto hot close (right) 111010010001011010100001010111100101010010101011
Fan mode 0 (prev24) low fan close (right) "11101001 0001011000100001110111100101010010101011"
Dry mode 24 low dry close (right) "11101001 0001011011000001 00111110 0101010010101011"
Auto Mode 0(prev24) low auto close (right) "11101001 0001011011100001 00011110 0101010010101011"
Cool Mode 24 low cool close (right) "11101001 0001011001100001 10011110 0101010010101011"
//FAN SPEED
fan Speed low 24 low cool close (right) "11101001 0001011001100001 10011110 0101010010101011"
fan Speed medium 24 medium cool close (right) "11101101 000100100110000110011110 0101010010101011"
fan Speed high 24 high cool close (right) "11101011 000101000110000110011110 0101010010101011"
fan Speed auto 24 auto cool close (right) "11101111 000100000110000110011110 0101010010101011"
//SWING
Swing open 24 auto cool open (left) "11110111 000010000110000110011110 0101010010101011"
Swing close 24 auto cool close (right) "11101111 000100000110000110011110 0101010010101011"
//TEMPERATURE
temp 30degC Auto cool close (right) 111011110001000001100100100100010101010010101011
temp 29 Auto cool close (right) 111011110001000001101100100100010101010010101011
temp 28 Auto cool close (right) 111011110001000001100010100100010101010010101011
temp 27 Auto cool close (right) 111011110001000001101010100100010101010010101011
temp 26 Auto cool close (right) 111011110001000001100110100100010101010010101011
temp 25 Auto cool close (right) 111011110001000001101110100100010101010010101011
temp 24 Auto cool close (right) 111011110001000001100001100111100101010010101011
temp 23 Auto cool close (right) 111011110001000001101001100101100101010010101011
temp 22 Auto cool close (right) 111011110001000001100101100101100101010010101011
temp 21 Auto cool close (right) 111011110001000001101101100101100101010010101011
temp 20 Auto cool close (right) 111011110001000001100011100101100101010010101011
temp 19 Auto cool close (right) 111011110001000001101011100101100101010010101011
temp 18 Auto cool close (right) 111011110001000001100111100110000101010010101011
temp 17 Auto cool close (right) 111011110001000001100111100110000101010010101011
temp 16 Auto cool close (right) 111011110001000001100111100110000101010010101011
**************************************************************************************************************/
#ifndef IR_TRANSCOLD_H_
#define IR_TRANSCOLD_H_
#define __STDC_LIMIT_MACROS
#include <stdint.h>
#ifndef UNIT_TEST
#include <Arduino.h>
#endif
#include "IRremoteESP8266.h"
#include "IRsend.h"
#ifdef UNIT_TEST
#include "IRsend_test.h"
#endif
// Constants
// Modes
const uint8_t kTranscoldCool = 0b0110;
const uint8_t kTranscoldDry = 0b1100;
const uint8_t kTranscoldAuto = 0b1110;
const uint8_t kTranscoldHeat = 0b1010;
const uint8_t kTranscoldFan = 0b0010;
const uint8_t kTranscoldModeOffset = 12;
const uint8_t kTranscoldModeSize = 4;
// Fan Control
const uint8_t kTranscoldFanOffset = 16;
const uint8_t kTranscoldFanSize = 4;
const uint8_t kTranscoldFanMin = 0b1001;
const uint8_t kTranscoldFanMed = 0b1101;
const uint8_t kTranscoldFanMax = 0b1011;
const uint8_t kTranscoldFanAuto = 0b1111;
const uint8_t kTranscoldFanAuto0 = 0b0110;
const uint8_t kTranscoldFanZoneFollow = 0b0000;
const uint8_t kTranscoldFanFixed = 0b1100;
// Temperature
const uint8_t kTranscoldTempMin = 18; // Celsius
const uint8_t kTranscoldTempMax = 30; // Celsius
const uint8_t kTranscoldFanTempCode = 0b1111; // Part of Fan Mode.
const uint8_t kTranscoldTempOffset = 8;
const uint8_t kTranscoldTempSize = 4;
const uint8_t kTranscoldPrefix = 0b0000;
const uint8_t kTranscoldUnknown = 0xFF;
const uint32_t kTranscoldOff = 0b111011110111100101010100;
const uint32_t kTranscoldSwing = 0b111001110110000101010100;
const uint32_t kTranscoldSwingH = 0b111101110110000101010100; // NA
const uint32_t kTranscoldSwingV = 0b111001110110000101010100; // NA
const uint32_t kTranscoldCmdFan = 0b111011110110000101010100; // NA
const uint32_t kTranscoldKnownGoodState = 0xE96554;
// Classes
class IRTranscoldAc {
public:
explicit IRTranscoldAc(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
void stateReset();
#if SEND_TRANSCOLD
void send(const uint16_t repeat = kTranscoldDefaultRepeat);
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif // SEND_TRANSCOLD
void begin();
void on();
void off();
void setPower(const bool state);
bool getPower();
void setTemp(const uint8_t temp);
uint8_t getTemp();
void setFan(const uint8_t speed, const bool modecheck = true);
uint8_t getFan();
void setMode(const uint8_t mode);
uint8_t getMode();
void setSwing();
bool getSwing();
uint32_t getRaw();
void setRaw(const uint32_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(const stdAc::state_t *prev = NULL);
String toString();
#ifndef UNIT_TEST
private:
IRsend _irsend;
#else
IRsendTest _irsend;
#endif
// internal state
bool powerFlag;
bool swingFlag;
bool swingHFlag;
bool swingVFlag;
uint32_t remote_state;
uint32_t saved_state;
void setTempRaw(const uint8_t code);
uint8_t getTempRaw();
bool isSpecialState(void);
bool handleSpecialState(const uint32_t data);
void updateSavedState(void);
void recoverSavedState(void);
uint32_t getNormalState(void);
};
#endif // IR_TRANSCOLD_H_
IRTranscoldAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode to it's common stdAc::opmode_t equivalent.
Definition: ir_Transcold.cpp:351
IRTranscoldAc::toCommon
stdAc::state_t toCommon(const stdAc::state_t *prev=NULL)
Convert the A/C state to it's common stdAc::state_t equivalent.
Definition: ir_Transcold.cpp:376
IRTranscoldAc::getSwing
bool getSwing()
Get the Swing setting of the A/C.
Definition: ir_Transcold.cpp:229
kTranscoldFanFixed
const uint8_t kTranscoldFanFixed
Definition: ir_Transcold.h:90
kTranscoldSwing
const uint32_t kTranscoldSwing
Definition: ir_Transcold.h:102
IRTranscoldAc::saved_state
uint32_t saved_state
Copy of the state if we required a special mode.
Definition: ir_Transcold.h:161
IRTranscoldAc::stateReset
void stateReset()
Reset the internal state to a fixed known good state.
Definition: ir_Transcold.cpp:80
IRTranscoldAc::IRTranscoldAc
IRTranscoldAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Transcold.cpp:75
IRTranscoldAc::getRaw
uint32_t getRaw()
Get a copy of the internal state as a valid code for this protocol.
Definition: ir_Transcold.cpp:105
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
kTranscoldFanMed
const uint8_t kTranscoldFanMed
Definition: ir_Transcold.h:85
kTranscoldFanSize
const uint8_t kTranscoldFanSize
Definition: ir_Transcold.h:83
IRTranscoldAc::getFan
uint8_t getFan()
Get the current fan speed setting.
Definition: ir_Transcold.cpp:279
kTranscoldOff
const uint32_t kTranscoldOff
Definition: ir_Transcold.h:101
IRTranscoldAc::setTempRaw
void setTempRaw(const uint8_t code)
Set the raw (native) temperature value.
Definition: ir_Transcold.cpp:173
kTranscoldUnknown
const uint8_t kTranscoldUnknown
Definition: ir_Transcold.h:100
IRTranscoldAc::getTempRaw
uint8_t getTempRaw()
Get the raw (native) temperature value.
Definition: ir_Transcold.cpp:179
IRTranscoldAc::getPower
bool getPower()
Get the value of the current power setting.
Definition: ir_Transcold.cpp:202
IRTranscoldAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Transcold.cpp:241
IRTranscoldAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Transcold.cpp:364
kTranscoldSwingH
const uint32_t kTranscoldSwingH
Definition: ir_Transcold.h:103
IRTranscoldAc::setRaw
void setRaw(const uint32_t new_code)
Set the internal state from a valid code for this protocol.
Definition: ir_Transcold.cpp:109
kTranscoldDefaultRepeat
const uint16_t kTranscoldDefaultRepeat
Definition: IRremoteESP8266.h:1084
IRTranscoldAc::setPower
void setPower(const bool state)
Change the power setting.
Definition: ir_Transcold.cpp:209
kTranscoldPrefix
const uint8_t kTranscoldPrefix
Definition: ir_Transcold.h:99
IRsend.h
IRTranscoldAc::on
void on()
Change the power setting to On.
Definition: ir_Transcold.cpp:222
IRTranscoldAc::recoverSavedState
void recoverSavedState(void)
Restore the current internal state from backup as long as it isn't a special state.
Definition: ir_Transcold.cpp:162
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:182
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
IRTranscoldAc::setFan
void setFan(const uint8_t speed, const bool modecheck=true)
Set the speed of the fan.
Definition: ir_Transcold.cpp:286
String
std::string String
Definition: IRremoteESP8266.h:1178
kTranscoldCool
const uint8_t kTranscoldCool
Definition: ir_Transcold.h:73
kTranscoldHeat
const uint8_t kTranscoldHeat
Definition: ir_Transcold.h:76
kTranscoldFanAuto0
const uint8_t kTranscoldFanAuto0
Definition: ir_Transcold.h:88
kTranscoldModeOffset
const uint8_t kTranscoldModeOffset
Definition: ir_Transcold.h:78
IRTranscoldAc::handleSpecialState
bool handleSpecialState(const uint32_t data)
Adjust any internal settings based on the type of special state we are supplied. Does nothing if it i...
Definition: ir_Transcold.cpp:139
IRremoteESP8266.h
IRTranscoldAc::swingHFlag
bool swingHFlag
Definition: ir_Transcold.h:157
IRTranscoldAc::getTemp
uint8_t getTemp()
Get the current temperature setting.
Definition: ir_Transcold.cpp:195
IRTranscoldAc::off
void off()
Change the power setting to Off.
Definition: ir_Transcold.cpp:225
IRTranscoldAc::getMode
uint8_t getMode()
Get the operating mode setting of the A/C.
Definition: ir_Transcold.cpp:269
kTranscoldModeSize
const uint8_t kTranscoldModeSize
Definition: ir_Transcold.h:79
kTranscoldFanZoneFollow
const uint8_t kTranscoldFanZoneFollow
Definition: ir_Transcold.h:89
IRTranscoldAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Transcold.h:148
kTranscoldTempSize
const uint8_t kTranscoldTempSize
Definition: ir_Transcold.h:97
kTranscoldKnownGoodState
const uint32_t kTranscoldKnownGoodState
Definition: ir_Transcold.h:107
kTranscoldFanAuto
const uint8_t kTranscoldFanAuto
Definition: ir_Transcold.h:87
IRTranscoldAc::toString
String toString()
Convert the internal state into a human readable string.
Definition: ir_Transcold.cpp:423
IRTranscoldAc::setTemp
void setTemp(const uint8_t temp)
Set the temperature.
Definition: ir_Transcold.cpp:185
IRTranscoldAc::swingFlag
bool swingFlag
Definition: ir_Transcold.h:156
kTranscoldFanTempCode
const uint8_t kTranscoldFanTempCode
Definition: ir_Transcold.h:95
kTranscoldFanMax
const uint8_t kTranscoldFanMax
Definition: ir_Transcold.h:86
IRTranscoldAc::remote_state
uint32_t remote_state
The state of the IR remote in IR code form.
Definition: ir_Transcold.h:160
IRTranscoldAc::isSpecialState
bool isSpecialState(void)
Is the current state is a special state?
Definition: ir_Transcold.cpp:125
kTranscoldTempMin
const uint8_t kTranscoldTempMin
Definition: ir_Transcold.h:93
IRTranscoldAc::swingVFlag
bool swingVFlag
Definition: ir_Transcold.h:158
kTranscoldFanOffset
const uint8_t kTranscoldFanOffset
Definition: ir_Transcold.h:82
IRTranscoldAc::updateSavedState
void updateSavedState(void)
Backup the current internal state as long as it isn't a special state.
Definition: ir_Transcold.cpp:156
IRTranscoldAc
Class for handling detailed Transcold A/C messages.
Definition: ir_Transcold.h:111
kTranscoldSwingV
const uint32_t kTranscoldSwingV
Definition: ir_Transcold.h:104
IRTranscoldAc::convertFan
uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Transcold.cpp:337
IRTranscoldAc::begin
void begin()
Set up hardware to be able to send a message.
Definition: ir_Transcold.cpp:90
kTranscoldAuto
const uint8_t kTranscoldAuto
Definition: ir_Transcold.h:75
IRTranscoldAc::powerFlag
bool powerFlag
Definition: ir_Transcold.h:155
IRTranscoldAc::getNormalState
uint32_t getNormalState(void)
IRTranscoldAc::setSwing
void setSwing()
Toggle the Swing mode of the A/C.
Definition: ir_Transcold.cpp:232
IRTranscoldAc::send
void send(const uint16_t repeat=kTranscoldDefaultRepeat)
Send the current internal state as an IR message.
Definition: ir_Transcold.cpp:95
IRTranscoldAc::convertMode
uint8_t convertMode(const stdAc::opmode_t mode)
Convert a standard A/C mode into its native mode.
Definition: ir_Transcold.cpp:324
kTranscoldTempOffset
const uint8_t kTranscoldTempOffset
Definition: ir_Transcold.h:96
kTranscoldCmdFan
const uint32_t kTranscoldCmdFan
Definition: ir_Transcold.h:105
kTranscoldFanMin
const uint8_t kTranscoldFanMin
Definition: ir_Transcold.h:84
kTranscoldFan
const uint8_t kTranscoldFan
Definition: ir_Transcold.h:77
kTranscoldTempMax
const uint8_t kTranscoldTempMax
Definition: ir_Transcold.h:94
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
kTranscoldDry
const uint8_t kTranscoldDry
Definition: ir_Transcold.h:74
IRTranscoldAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Transcold.h:122
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46