IRremoteESP8266
ir_Transcold.h
Go to the documentation of this file.
1 // Copyright 2020 Chandrashekar Shetty (iamDshetty)
2 // Copyright 2020 crankyoldgit
3 // Copyright 2021 siriuslzx
4 
9 
10 // Supports:
11 // Brand: Transcold, Model: M1-F-NO-6 A/C
12 
13 /***************************************************************************************************************
14 
15  Raw Data Calculation: (UR 12)
16 //ON button
17 ON 24 Auto cool close (right) 111011110001000001100001100111100101010010101011
18 
19 //OFF button
20 OFF 24 Auto cool close (right) 111011110001000001110001100011100101010010101011
21 
22 // MODE
23 Hot mode 24 auto hot close (right) 111010010001011010100001010111100101010010101011
24 Fan mode 0 (prev24) low fan close (right) "11101001 0001011000100001110111100101010010101011"
25 Dry mode 24 low dry close (right) "11101001 0001011011000001 00111110 0101010010101011"
26 Auto Mode 0(prev24) low auto close (right) "11101001 0001011011100001 00011110 0101010010101011"
27 Cool Mode 24 low cool close (right) "11101001 0001011001100001 10011110 0101010010101011"
28 
29 //FAN SPEED
30 fan Speed low 24 low cool close (right) "11101001 0001011001100001 10011110 0101010010101011"
31 fan Speed medium 24 medium cool close (right) "11101101 000100100110000110011110 0101010010101011"
32 fan Speed high 24 high cool close (right) "11101011 000101000110000110011110 0101010010101011"
33 fan Speed auto 24 auto cool close (right) "11101111 000100000110000110011110 0101010010101011"
34 
35 //SWING
36 Swing open 24 auto cool open (left) "11110111 000010000110000110011110 0101010010101011"
37 Swing close 24 auto cool close (right) "11101111 000100000110000110011110 0101010010101011"
38 
39 //TEMPERATURE
40 temp 30degC Auto cool close (right) 111011110001000001100100100100010101010010101011
41 temp 29 Auto cool close (right) 111011110001000001101100100100010101010010101011
42 temp 28 Auto cool close (right) 111011110001000001100010100100010101010010101011
43 temp 27 Auto cool close (right) 111011110001000001101010100100010101010010101011
44 temp 26 Auto cool close (right) 111011110001000001100110100100010101010010101011
45 temp 25 Auto cool close (right) 111011110001000001101110100100010101010010101011
46 temp 24 Auto cool close (right) 111011110001000001100001100111100101010010101011
47 temp 23 Auto cool close (right) 111011110001000001101001100101100101010010101011
48 temp 22 Auto cool close (right) 111011110001000001100101100101100101010010101011
49 temp 21 Auto cool close (right) 111011110001000001101101100101100101010010101011
50 temp 20 Auto cool close (right) 111011110001000001100011100101100101010010101011
51 temp 19 Auto cool close (right) 111011110001000001101011100101100101010010101011
52 temp 18 Auto cool close (right) 111011110001000001100111100110000101010010101011
53 temp 17 Auto cool close (right) 111011110001000001100111100110000101010010101011
54 temp 16 Auto cool close (right) 111011110001000001100111100110000101010010101011
55 
56  **************************************************************************************************************/
57 
58 #ifndef IR_TRANSCOLD_H_
59 #define IR_TRANSCOLD_H_
60 
61 #define __STDC_LIMIT_MACROS
62 #include <stdint.h>
63 #ifndef UNIT_TEST
64 #include <Arduino.h>
65 #endif
66 #include "IRremoteESP8266.h"
67 #include "IRsend.h"
68 #ifdef UNIT_TEST
69 #include "IRsend_test.h"
70 #endif
71 
74  uint32_t raw;
75  struct {
76  uint8_t :8;
77  uint8_t Temp :4;
78  uint8_t Mode :4;
79  uint8_t Fan :4;
80  uint8_t :4;
81  uint8_t :8;
82  };
83 };
84 
85 // Constants
86 // Modes
87 const uint8_t kTranscoldCool = 0b0110;
88 const uint8_t kTranscoldDry = 0b1100;
89 const uint8_t kTranscoldAuto = 0b1110;
90 const uint8_t kTranscoldHeat = 0b1010;
91 const uint8_t kTranscoldFan = 0b0010;
92 
93 // Fan Control
94 const uint8_t kTranscoldFanMin = 0b1001;
95 const uint8_t kTranscoldFanMed = 0b1101;
96 const uint8_t kTranscoldFanMax = 0b1011;
97 const uint8_t kTranscoldFanAuto = 0b1111;
98 const uint8_t kTranscoldFanAuto0 = 0b0110;
99 const uint8_t kTranscoldFanZoneFollow = 0b0000;
100 const uint8_t kTranscoldFanFixed = 0b1100;
101 
102 // Temperature
103 const uint8_t kTranscoldTempMin = 18; // Celsius
104 const uint8_t kTranscoldTempMax = 30; // Celsius
105 const uint8_t kTranscoldFanTempCode = 0b1111; // Part of Fan Mode.
106 const uint8_t kTranscoldTempSize = 4;
107 
108 const uint8_t kTranscoldPrefix = 0b0000;
109 const uint8_t kTranscoldUnknown = 0xFF;
110 const uint32_t kTranscoldOff = 0b111011110111100101010100;
111 const uint32_t kTranscoldSwing = 0b111001110110000101010100;
112 const uint32_t kTranscoldSwingH = 0b111101110110000101010100; // NA
113 const uint32_t kTranscoldSwingV = 0b111001110110000101010100; // NA
114 const uint32_t kTranscoldCmdFan = 0b111011110110000101010100; // NA
115 
116 const uint32_t kTranscoldKnownGoodState = 0xE96554;
117 
118 // Classes
121  public:
122  explicit IRTranscoldAc(const uint16_t pin, const bool inverted = false,
123  const bool use_modulation = true);
124  void stateReset(void);
125 #if SEND_TRANSCOLD
126  void send(const uint16_t repeat = kTranscoldDefaultRepeat);
131  int8_t calibrate(void) { return _irsend.calibrate(); }
132 #endif // SEND_TRANSCOLD
133  void begin(void);
134  void on(void);
135  void off(void);
136  void setPower(const bool state);
137  bool getPower(void) const;
138  void setTemp(const uint8_t temp);
139  uint8_t getTemp(void) const;
140  void setFan(const uint8_t speed, const bool modecheck = true);
141  uint8_t getFan(void) const;
142  void setMode(const uint8_t mode);
143  uint8_t getMode(void) const;
144  void setSwing(void);
145  bool getSwing(void) const;
146  uint32_t getRaw(void) const;
147  void setRaw(const uint32_t new_code);
148  static uint8_t convertMode(const stdAc::opmode_t mode);
149  static uint8_t convertFan(const stdAc::fanspeed_t speed);
150  static stdAc::opmode_t toCommonMode(const uint8_t mode);
151  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
152  stdAc::state_t toCommon(const stdAc::state_t *prev = NULL) const;
153  String toString(void) const;
154 #ifndef UNIT_TEST
155 
156  private:
158 #else
159  IRsendTest _irsend;
161 #endif
163  // internal state
164  bool swingFlag;
167 
169  uint32_t special_state;
170  bool isSpecialState(void) const;
171  bool handleSpecialState(const uint32_t data);
172 };
173 
174 #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:316
kTranscoldFanFixed
const uint8_t kTranscoldFanFixed
Definition: ir_Transcold.h:100
IRTranscoldAc::toString
String toString(void) const
Convert the internal state into a human readable string.
Definition: ir_Transcold.cpp:388
IRTranscoldAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Transcold.cpp:88
IRTranscoldAc::stateReset
void stateReset(void)
Reset the internal state to a fixed known good state.
Definition: ir_Transcold.cpp:79
kTranscoldSwing
const uint32_t kTranscoldSwing
Definition: ir_Transcold.h:111
IRTranscoldAc::IRTranscoldAc
IRTranscoldAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Transcold.cpp:74
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:61
kTranscoldFanMed
const uint8_t kTranscoldFanMed
Definition: ir_Transcold.h:95
kTranscoldOff
const uint32_t kTranscoldOff
Definition: ir_Transcold.h:110
IRTranscoldAc::getSwing
bool getSwing(void) const
Get the Swing setting of the A/C.
Definition: ir_Transcold.cpp:201
kTranscoldUnknown
const uint8_t kTranscoldUnknown
Definition: ir_Transcold.h:109
IRTranscoldAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Transcold.cpp:213
TranscoldProtocol::raw
uint32_t raw
The state of the IR remote in IR code form.
Definition: ir_Transcold.h:74
IRTranscoldAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Transcold.cpp:329
kTranscoldSwingH
const uint32_t kTranscoldSwingH
Definition: ir_Transcold.h:112
IRTranscoldAc::setRaw
void setRaw(const uint32_t new_code)
Set the internal state from a valid code for this protocol.
Definition: ir_Transcold.cpp:114
kTranscoldDefaultRepeat
const uint16_t kTranscoldDefaultRepeat
Definition: IRremoteESP8266.h:1411
IRTranscoldAc::setPower
void setPower(const bool state)
Change the power setting.
Definition: ir_Transcold.cpp:185
kTranscoldPrefix
const uint8_t kTranscoldPrefix
Definition: ir_Transcold.h:108
IRsend.h
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:237
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:256
IRTranscoldAc::on
void on(void)
Change the power setting to On.
Definition: ir_Transcold.cpp:194
String
std::string String
Definition: IRremoteESP8266.h:1521
kTranscoldCool
const uint8_t kTranscoldCool
Definition: ir_Transcold.h:87
kTranscoldHeat
const uint8_t kTranscoldHeat
Definition: ir_Transcold.h:90
kTranscoldFanAuto0
const uint8_t kTranscoldFanAuto0
Definition: ir_Transcold.h:98
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:146
IRTranscoldAc::getRaw
uint32_t getRaw(void) const
Get a copy of the internal state as a valid code for this protocol.
Definition: ir_Transcold.cpp:105
IRremoteESP8266.h
IRTranscoldAc::swingHFlag
bool swingHFlag
Definition: ir_Transcold.h:165
kTranscoldFanZoneFollow
const uint8_t kTranscoldFanZoneFollow
Definition: ir_Transcold.h:99
TranscoldProtocol::Mode
uint8_t Mode
Definition: ir_Transcold.h:78
IRTranscoldAc::_
TranscoldProtocol _
Definition: ir_Transcold.h:168
IRTranscoldAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Transcold.h:157
kTranscoldTempSize
const uint8_t kTranscoldTempSize
Definition: ir_Transcold.h:106
IRTranscoldAc::isSpecialState
bool isSpecialState(void) const
Is the current state is a special state?
Definition: ir_Transcold.cpp:132
kTranscoldKnownGoodState
const uint32_t kTranscoldKnownGoodState
Definition: ir_Transcold.h:116
kTranscoldFanAuto
const uint8_t kTranscoldFanAuto
Definition: ir_Transcold.h:97
IRTranscoldAc::setTemp
void setTemp(const uint8_t temp)
Set the temperature.
Definition: ir_Transcold.cpp:161
TranscoldProtocol
Native representation of a Transcold A/C message.
Definition: ir_Transcold.h:73
IRTranscoldAc::swingFlag
bool swingFlag
Definition: ir_Transcold.h:164
IRTranscoldAc::getPower
bool getPower(void) const
Get the value of the current power setting.
Definition: ir_Transcold.cpp:178
kTranscoldFanTempCode
const uint8_t kTranscoldFanTempCode
Definition: ir_Transcold.h:105
kTranscoldFanMax
const uint8_t kTranscoldFanMax
Definition: ir_Transcold.h:96
IRTranscoldAc::off
void off(void)
Change the power setting to Off.
Definition: ir_Transcold.cpp:197
IRTranscoldAc::setSwing
void setSwing(void)
Toggle the Swing mode of the A/C.
Definition: ir_Transcold.cpp:204
kTranscoldTempMin
const uint8_t kTranscoldTempMin
Definition: ir_Transcold.h:103
IRTranscoldAc::swingVFlag
bool swingVFlag
Definition: ir_Transcold.h:166
TranscoldProtocol::Temp
uint8_t Temp
Definition: ir_Transcold.h:77
IRTranscoldAc::toCommon
stdAc::state_t toCommon(const stdAc::state_t *prev=NULL) const
Convert the A/C state to it's common stdAc::state_t equivalent.
Definition: ir_Transcold.cpp:341
IRTranscoldAc
Class for handling detailed Transcold A/C messages.
Definition: ir_Transcold.h:120
kTranscoldSwingV
const uint32_t kTranscoldSwingV
Definition: ir_Transcold.h:113
IRTranscoldAc::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_Transcold.cpp:249
IRTranscoldAc::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Transcold.cpp:302
IRTranscoldAc::special_state
uint32_t special_state
special mode.
Definition: ir_Transcold.h:169
kTranscoldAuto
const uint8_t kTranscoldAuto
Definition: ir_Transcold.h:89
IRTranscoldAc::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_Transcold.cpp:171
IRTranscoldAc::send
void send(const uint16_t repeat=kTranscoldDefaultRepeat)
Send the current internal state as an IR message.
Definition: ir_Transcold.cpp:93
IRTranscoldAc::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a standard A/C mode into its native mode.
Definition: ir_Transcold.cpp:289
kTranscoldCmdFan
const uint32_t kTranscoldCmdFan
Definition: ir_Transcold.h:114
kTranscoldFanMin
const uint8_t kTranscoldFanMin
Definition: ir_Transcold.h:94
kTranscoldFan
const uint8_t kTranscoldFan
Definition: ir_Transcold.h:91
IRTranscoldAc::getMode
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition: ir_Transcold.cpp:240
kTranscoldTempMax
const uint8_t kTranscoldTempMax
Definition: ir_Transcold.h:104
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:114
kTranscoldDry
const uint8_t kTranscoldDry
Definition: ir_Transcold.h:88
IRTranscoldAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Transcold.h:131
TranscoldProtocol::Fan
uint8_t Fan
Definition: ir_Transcold.h:79
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:49