IRremoteESP8266
Loading...
Searching...
No Matches
ir_Toshiba.h
Go to the documentation of this file.
1// Copyright 2017 David Conran
2
12
13// Supports:
14// Brand: Toshiba, Model: RAS-B13N3KV2
15// Brand: Toshiba, Model: Akita EVO II
16// Brand: Toshiba, Model: RAS-B13N3KVP-E
17// Brand: Toshiba, Model: RAS 18SKP-ES
18// Brand: Toshiba, Model: WH-TA04NE
19// Brand: Toshiba, Model: WC-L03SE
20// Brand: Toshiba, Model: WH-UB03NJ remote
21// Brand: Toshiba, Model: RAS-2558V A/C
22// Brand: Toshiba, Model: WH-TA01JE remote
23// Brand: Toshiba, Model: RAS-25SKVP2-ND A/C
24// Brand: Carrier, Model: 42NQV060M2 / 38NYV060M2 A/C
25// Brand: Carrier, Model: 42NQV050M2 / 38NYV050M2 A/C
26// Brand: Carrier, Model: 42NQV035M2 / 38NYV035M2 A/C
27// Brand: Carrier, Model: 42NQV025M2 / 38NYV025M2 A/C
28
29#ifndef IR_TOSHIBA_H_
30#define IR_TOSHIBA_H_
31
32#define __STDC_LIMIT_MACROS
33#include <stdint.h>
34#ifdef ARDUINO
35#include <Arduino.h>
36#endif
37#include "IRremoteESP8266.h"
38#include "IRsend.h"
39#ifdef UNIT_TEST
40#include "IRsend_test.h"
41#endif
42
46 struct {
47 // Byte[0] - 0xF2
48 uint8_t :8;
49 // Byte[1] - 0x0D (inverted previous byte's value)
50 uint8_t :8;
51 // Byte[2] - The expected payload length (in bytes) past the Byte[4].
56 uint8_t Length :4;
57 // Toshiba remote type
58 // 0 - Remote control A
59 // 1 - Remote control B
60 uint8_t Model :4;
61 // Byte[3] - The bit-inverted value of the "length" byte.
62 uint8_t :8;
63 // Byte[4]
64 uint8_t :3;
65 uint8_t LongMsg :1;
66 uint8_t :1;
67 uint8_t ShortMsg :1;
68 uint8_t :2;
69 // Byte[5]
70 uint8_t Swing :3;
71 uint8_t :1;
72 uint8_t Temp :4;
73 // Byte[6]
74 uint8_t Mode :3;
75 uint8_t :2;
76 uint8_t Fan :3;
77 // Byte[7]
78 uint8_t :4;
79 uint8_t Filter :1;
80 uint8_t :3;
81
82 // Byte[8]
83 // (Checksum for 72 bit messages, Eco/Turbo for long 80 bit messages)
84 uint8_t EcoTurbo :8;
85 };
86};
87
88// Constants
89
90const uint8_t kToshibaAcLengthByte = 2;
91const uint8_t kToshibaAcMinLength = 6;
92
93const uint16_t kToshibaAcInvertedLength = 4;
95
96const uint8_t kToshibaAcSwingStep = 0;
97const uint8_t kToshibaAcSwingOn = 1;
98const uint8_t kToshibaAcSwingOff = 2;
99const uint8_t kToshibaAcSwingToggle = 4;
100
101const uint8_t kToshibaAcMinTemp = 17;
102const uint8_t kToshibaAcMaxTemp = 30;
103
104const uint8_t kToshibaAcAuto = 0; // 0b000
105const uint8_t kToshibaAcCool = 1; // 0b001
106const uint8_t kToshibaAcDry = 2; // 0b010
107const uint8_t kToshibaAcHeat = 3; // 0b011
108const uint8_t kToshibaAcFan = 4; // 0b100
109const uint8_t kToshibaAcOff = 7; // 0b111
110const uint8_t kToshibaAcFanAuto = 0; // 0b000
111const uint8_t kToshibaAcFanMin = 1; // 0b001
112const uint8_t kToshibaAcFanMed = 3; // 0b011
113const uint8_t kToshibaAcFanMax = 5; // 0b101
114
115const uint8_t kToshibaAcTurboOn = 1; // 0b01
116const uint8_t kToshibaAcEconoOn = 3; // 0b11
117
118const uint8_t kToshibaAcRemoteA = 0; // 0b0000
119const uint8_t kToshibaAcRemoteB = 1; // 0b0001
120
121// Legacy defines. (Deprecated)
122#define TOSHIBA_AC_AUTO kToshibaAcAuto
123#define TOSHIBA_AC_COOL kToshibaAcCool
124#define TOSHIBA_AC_DRY kToshibaAcDry
125#define TOSHIBA_AC_HEAT kToshibaAcHeat
126#define TOSHIBA_AC_POWER kToshibaAcPower
127#define TOSHIBA_AC_FAN_AUTO kToshibaAcFanAuto
128#define TOSHIBA_AC_FAN_MAX kToshibaAcFanMax
129#define TOSHIBA_AC_MIN_TEMP kToshibaAcMinTemp
130#define TOSHIBA_AC_MAX_TEMP kToshibaAcMaxTemp
131
132// Classes
135 public:
136 explicit IRToshibaAC(const uint16_t pin, const bool inverted = false,
137 const bool use_modulation = true);
138 void stateReset(void);
139#if SEND_TOSHIBA_AC
140 void send(const uint16_t repeat = kToshibaACMinRepeat);
145 int8_t calibrate(void) { return _irsend.calibrate(); }
146#endif // SEND_TOSHIBA_AC
147 void begin(void);
148 void on(void);
149 void off(void);
150 void setModel(const toshiba_ac_remote_model_t model);
152 void setPower(const bool on);
153 bool getPower(void) const;
154 void setTemp(const uint8_t degrees);
155 uint8_t getTemp(void) const;
156 void setFan(const uint8_t speed);
157 uint8_t getFan(void) const;
158 void setTurbo(const bool on);
159 bool getTurbo(void) const;
160 void setEcono(const bool on);
161 bool getEcono(void) const;
162 void setFilter(const bool on);
163 bool getFilter(void) const;
164 void setMode(const uint8_t mode);
165 uint8_t getMode(const bool raw = false) const;
166 void setRaw(const uint8_t newState[],
167 const uint16_t length = kToshibaACStateLength);
168 uint8_t* getRaw(void);
169 static uint16_t getInternalStateLength(const uint8_t state[],
170 const uint16_t size);
171 uint16_t getStateLength(void) const;
172 static bool validChecksum(const uint8_t state[],
173 const uint16_t length = kToshibaACStateLength);
174 uint8_t getSwing(const bool raw = true) const;
175 void setSwing(const uint8_t setting);
176 static uint8_t convertMode(const stdAc::opmode_t mode);
177 static uint8_t convertFan(const stdAc::fanspeed_t speed);
178 static stdAc::opmode_t toCommonMode(const uint8_t mode);
179 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
180 stdAc::state_t toCommon(const stdAc::state_t *prev = NULL) const;
181 String toString(void) const;
182#ifndef UNIT_TEST
183
184 private:
186#else // UNIT_TEST
188 IRsendTest _irsend;
190#endif // UNIT_TEST
193 uint8_t _prev_mode;
195 uint8_t _swing_mode;
196 void checksum(const uint16_t length = kToshibaACStateLength);
197 static uint8_t calcChecksum(const uint8_t state[],
198 const uint16_t length = kToshibaACStateLength);
199 void setStateLength(const uint16_t size);
200 void _backupState(void);
201 void _restoreState(void);
202};
203
204#endif // IR_TOSHIBA_H_
const uint16_t kToshibaACStateLengthLong
Definition IRremoteESP8266.h:1434
const uint16_t kToshibaACMinRepeat
Definition IRremoteESP8266.h:1431
const uint16_t kToshibaACStateLength
Definition IRremoteESP8266.h:1429
std::string String
Definition IRremoteESP8266.h:1564
toshiba_ac_remote_model_t
Toshiba A/C model numbers.
Definition IRsend.h:237
Class for handling detailed Toshiba A/C messages.
Definition ir_Toshiba.h:134
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition ir_Toshiba.cpp:225
static uint8_t calcChecksum(const uint8_t state[], const uint16_t length=kToshibaACStateLength)
Calculate the checksum for a given state.
Definition ir_Toshiba.cpp:157
void setPower(const bool on)
Change the power setting.
Definition ir_Toshiba.cpp:196
void _backupState(void)
Make a copy of the internal code-form A/C state.
Definition ir_Toshiba.cpp:127
bool getEcono(void) const
Get the Economy mode setting of the A/C.
Definition ir_Toshiba.cpp:324
static uint16_t getInternalStateLength(const uint8_t state[], const uint16_t size)
Get the length of the supplied Toshiba state per it's protocol structure.
Definition ir_Toshiba.cpp:105
void send(const uint16_t repeat=kToshibaACMinRepeat)
Send the current internal state as IR messages.
Definition ir_Toshiba.cpp:85
uint8_t getSwing(const bool raw=true) const
Get the swing setting of the A/C.
Definition ir_Toshiba.cpp:245
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition ir_Toshiba.cpp:358
void _restoreState(void)
Recover the internal code-form A/C state from the backup.
Definition ir_Toshiba.cpp:132
String toString(void) const
Convert the current internal state into a human readable string.
Definition ir_Toshiba.cpp:464
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol with all integrity checks passing.
Definition ir_Toshiba.cpp:139
bool _send_swing
Flag indicating if we need to send a swing message.
Definition ir_Toshiba.h:194
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition ir_Toshiba.cpp:70
uint8_t _swing_mode
The saved swing state/mode/command.
Definition ir_Toshiba.h:195
void begin(void)
Set up hardware to be able to send a message.
Definition ir_Toshiba.cpp:80
stdAc::state_t toCommon(const stdAc::state_t *prev=NULL) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition ir_Toshiba.cpp:413
void setRaw(const uint8_t newState[], const uint16_t length=kToshibaACStateLength)
Set the internal state from a valid code for this protocol.
Definition ir_Toshiba.cpp:147
void checksum(const uint16_t length=kToshibaACStateLength)
Calculate & set the checksum for the current internal state of the remote.
Definition ir_Toshiba.cpp:175
void setTurbo(const bool on)
Set the Turbo (Powerful) setting of the A/C.
Definition ir_Toshiba.cpp:313
IRsend _irsend
Instance of the IR send class.
Definition ir_Toshiba.h:185
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition ir_Toshiba.cpp:400
void off(void)
Set the requested power state of the A/C to off.
Definition ir_Toshiba.cpp:192
uint8_t getMode(const bool raw=false) const
Get the operating mode setting of the A/C.
Definition ir_Toshiba.cpp:267
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition ir_Toshiba.h:145
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition ir_Toshiba.cpp:386
void setEcono(const bool on)
Set the Economy mode setting of the A/C.
Definition ir_Toshiba.cpp:333
bool getFilter(void) const
Get the filter (Pure/Ion Filter) setting of the A/C.
Definition ir_Toshiba.cpp:344
void setTemp(const uint8_t degrees)
Set the temperature.
Definition ir_Toshiba.cpp:213
void setStateLength(const uint16_t size)
Set the internal length of the current internal state per the protocol.
Definition ir_Toshiba.cpp:121
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition ir_Toshiba.cpp:280
void setFilter(const bool on)
Set the filter (Pure/Ion Filter) setting of the A/C.
Definition ir_Toshiba.cpp:350
bool getPower(void) const
Get the value of the current power setting.
Definition ir_Toshiba.cpp:207
bool getTurbo(void) const
Get the Turbo (Powerful) setting of the A/C.
Definition ir_Toshiba.cpp:304
uint8_t getFan(void) const
Get the current fan speed setting.
Definition ir_Toshiba.cpp:236
void on(void)
Set the requested power state of the A/C to on.
Definition ir_Toshiba.cpp:189
void setModel(const toshiba_ac_remote_model_t model)
Set the current model for the remote.
Definition ir_Toshiba.cpp:512
static bool validChecksum(const uint8_t state[], const uint16_t length=kToshibaACStateLength)
Verify the checksum is valid for a given state.
Definition ir_Toshiba.cpp:166
uint8_t backup[kToshibaACStateLengthLong]
A backup copy of the state.
Definition ir_Toshiba.h:192
toshiba_ac_remote_model_t getModel() const
Get the model information currently known.
Definition ir_Toshiba.cpp:501
ToshibaProtocol _
Definition ir_Toshiba.h:191
void setSwing(const uint8_t setting)
Set the swing setting of the A/C.
Definition ir_Toshiba.cpp:251
uint8_t _prev_mode
Store of the previously set mode.
Definition ir_Toshiba.h:193
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition ir_Toshiba.cpp:372
uint16_t getStateLength(void) const
Get the length of the current internal state per the protocol structure.
Definition ir_Toshiba.cpp:115
uint8_t getTemp(void) const
Get the current temperature setting.
Definition ir_Toshiba.cpp:221
Class for sending all basic IR protocols.
Definition IRsend.h:249
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition IRsend.cpp:209
const uint8_t kToshibaAcSwingToggle
0b100
Definition ir_Toshiba.h:99
const uint8_t kToshibaAcFanMax
Definition ir_Toshiba.h:113
const uint8_t kToshibaAcMinLength
Min Nr. of bytes in a message.
Definition ir_Toshiba.h:91
const uint8_t kToshibaAcDry
Definition ir_Toshiba.h:106
const uint8_t kToshibaAcCool
Definition ir_Toshiba.h:105
const uint8_t kToshibaAcFanMed
Definition ir_Toshiba.h:112
const uint8_t kToshibaAcAuto
Definition ir_Toshiba.h:104
const uint8_t kToshibaAcMaxTemp
30C
Definition ir_Toshiba.h:102
const uint8_t kToshibaAcLengthByte
Byte pos of the "length" attribute.
Definition ir_Toshiba.h:90
const uint8_t kToshibaAcFan
Definition ir_Toshiba.h:108
const uint8_t kToshibaAcRemoteB
Definition ir_Toshiba.h:119
const uint8_t kToshibaAcOff
Definition ir_Toshiba.h:109
const uint8_t kToshibaAcFanAuto
Definition ir_Toshiba.h:110
const uint8_t kToshibaAcRemoteA
Definition ir_Toshiba.h:118
const uint8_t kToshibaAcTurboOn
Definition ir_Toshiba.h:115
const uint8_t kToshibaAcHeat
Definition ir_Toshiba.h:107
const uint8_t kToshibaAcFanMin
Definition ir_Toshiba.h:111
const uint8_t kToshibaAcSwingOff
0b010
Definition ir_Toshiba.h:98
const uint8_t kToshibaAcEconoOn
Definition ir_Toshiba.h:116
const uint8_t kToshibaAcSwingOn
0b001
Definition ir_Toshiba.h:97
const uint8_t kToshibaAcMinTemp
17C
Definition ir_Toshiba.h:101
const uint16_t kToshibaAcInvertedLength
Nr. of leading bytes in inverted pairs.
Definition ir_Toshiba.h:93
const uint8_t kToshibaAcSwingStep
0b000
Definition ir_Toshiba.h:96
fanspeed_t
Common A/C settings for Fan Speeds.
Definition IRsend.h:61
opmode_t
Common A/C settings for A/C operating modes.
Definition IRsend.h:49
Structure to hold a common A/C state.
Definition IRsend.h:114
Native representation of a Toshiba A/C message.
Definition ir_Toshiba.h:44
uint8_t raw[kToshibaACStateLengthLong]
The state in code form.
Definition ir_Toshiba.h:45
uint8_t Model
Definition ir_Toshiba.h:60
uint8_t EcoTurbo
Definition ir_Toshiba.h:84
uint8_t Swing
Definition ir_Toshiba.h:70
uint8_t Filter
Definition ir_Toshiba.h:79
uint8_t Length
< Known lengths are: 1 (56 bit message) 3 (72 bit message) 4 (80 bit message)
Definition ir_Toshiba.h:56
uint8_t Temp
Definition ir_Toshiba.h:72
uint8_t LongMsg
Definition ir_Toshiba.h:65
uint8_t ShortMsg
Definition ir_Toshiba.h:67
uint8_t Fan
Definition ir_Toshiba.h:76
uint8_t Mode
Definition ir_Toshiba.h:74