-
Notifications
You must be signed in to change notification settings - Fork 851
/
Copy pathir_Transcold.h
174 lines (152 loc) · 6.74 KB
/
ir_Transcold.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// Copyright 2020 Chandrashekar Shetty (iamDshetty)
// Copyright 2020 crankyoldgit
// Copyright 2021 siriuslzx
/// @file
/// @brief Support for Transcold A/C protocols.
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/1256
/// @see https://docs.google.com/spreadsheets/d/1qdoyB0FyJm85HPP9oXcfui0n4ztXBFlik6kiNlkO2IM/edit?usp=sharing
// 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
/// Native representation of a Transcold A/C message.
union TranscoldProtocol{
uint32_t raw; ///< The state of the IR remote in IR code form.
struct {
uint8_t :8;
uint8_t Temp :4;
uint8_t Mode :4;
uint8_t Fan :4;
uint8_t :4;
uint8_t :8;
};
};
// 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;
// Fan Control
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 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 for handling detailed Transcold A/C messages.
class IRTranscoldAc {
public:
explicit IRTranscoldAc(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
void stateReset(void);
#if SEND_TRANSCOLD
void send(const uint16_t repeat = kTranscoldDefaultRepeat);
/// Run the calibration to calculate uSec timing offsets for this platform.
/// @return The uSec timing offset needed per modulation of the IR Led.
/// @note This will produce a 65ms IR signal pulse at 38kHz.
/// Only ever needs to be run once per object instantiation, if at all.
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif // SEND_TRANSCOLD
void begin(void);
void on(void);
void off(void);
void setPower(const bool state);
bool getPower(void) const;
void setTemp(const uint8_t temp);
uint8_t getTemp(void) const;
void setFan(const uint8_t speed, const bool modecheck = true);
uint8_t getFan(void) const;
void setMode(const uint8_t mode);
uint8_t getMode(void) const;
void setSwing(void);
bool getSwing(void) const;
uint32_t getRaw(void) const;
void setRaw(const uint32_t new_code);
static uint8_t convertMode(const stdAc::opmode_t mode);
static 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) const;
String toString(void) const;
#ifndef UNIT_TEST
private:
IRsend _irsend; ///< Instance of the IR send class
#else
/// @cond IGNORE
IRsendTest _irsend; ///< Instance of the testing IR send class
/// @endcond
#endif
// internal state
bool swingFlag;
bool swingHFlag;
bool swingVFlag;
TranscoldProtocol _;
uint32_t special_state; ///< special mode.
bool isSpecialState(void) const;
bool handleSpecialState(const uint32_t data);
};
#endif // IR_TRANSCOLD_H_