IRremoteESP8266
ir_Toshiba.h
Go to the documentation of this file.
1 // Copyright 2017 David Conran
2 
7 
8 // Supports:
9 // Brand: Toshiba, Model: RAS-B13N3KV2
10 // Brand: Toshiba, Model: Akita EVO II
11 // Brand: Toshiba, Model: RAS-B13N3KVP-E
12 // Brand: Toshiba, Model: RAS 18SKP-ES
13 // Brand: Toshiba, Model: WH-TA04NE
14 // Brand: Toshiba, Model: WC-L03SE
15 
16 #ifndef IR_TOSHIBA_H_
17 #define IR_TOSHIBA_H_
18 
19 #define __STDC_LIMIT_MACROS
20 #include <stdint.h>
21 #ifdef ARDUINO
22 #include <Arduino.h>
23 #endif
24 #include "IRremoteESP8266.h"
25 #include "IRsend.h"
26 #ifdef UNIT_TEST
27 #include "IRsend_test.h"
28 #endif
29 
30 // Constants
31 const uint8_t kToshibaAcModeOffset = 0;
32 const uint8_t kToshibaAcModeSize = 2; // Nr. of bits
33 const uint8_t kToshibaAcAuto = 0;
34 const uint8_t kToshibaAcCool = 1;
35 const uint8_t kToshibaAcDry = 2;
36 const uint8_t kToshibaAcHeat = 3;
37 const uint8_t kToshibaAcPowerOffset = 2;
38 const uint8_t kToshibaAcFanOffset = 5;
39 const uint8_t kToshibaAcFanSize = 3; // Nr. of bits
40 const uint8_t kToshibaAcFanAuto = 0b000;
41 const uint8_t kToshibaAcFanMin = 0b001;
42 const uint8_t kToshibaAcFanMed = 0b011;
43 const uint8_t kToshibaAcFanMax = 0b101;
44 const uint8_t kToshibaAcTempOffset = 4;
45 const uint8_t kToshibaAcTempSize = 4; // Nr. of bits
46 const uint8_t kToshibaAcMinTemp = 17; // 17C
47 const uint8_t kToshibaAcMaxTemp = 30; // 30C
48 
49 // Legacy defines. (Deperecated)
50 #define TOSHIBA_AC_AUTO kToshibaAcAuto
51 #define TOSHIBA_AC_COOL kToshibaAcCool
52 #define TOSHIBA_AC_DRY kToshibaAcDry
53 #define TOSHIBA_AC_HEAT kToshibaAcHeat
54 #define TOSHIBA_AC_POWER kToshibaAcPower
55 #define TOSHIBA_AC_FAN_AUTO kToshibaAcFanAuto
56 #define TOSHIBA_AC_FAN_MAX kToshibaAcFanMax
57 #define TOSHIBA_AC_MIN_TEMP kToshibaAcMinTemp
58 #define TOSHIBA_AC_MAX_TEMP kToshibaAcMaxTemp
59 
60 // Classes
62 class IRToshibaAC {
63  public:
64  explicit IRToshibaAC(const uint16_t pin, const bool inverted = false,
65  const bool use_modulation = true);
66  void stateReset(void);
67 #if SEND_TOSHIBA_AC
68  void send(const uint16_t repeat = kToshibaACMinRepeat);
73  int8_t calibrate(void) { return _irsend.calibrate(); }
74 #endif // SEND_TOSHIBA_AC
75  void begin(void);
76  void on(void);
77  void off(void);
78  void setPower(const bool on);
79  bool getPower(void);
80  void setTemp(const uint8_t degrees);
81  uint8_t getTemp(void);
82  void setFan(const uint8_t speed);
83  uint8_t getFan(void);
84  void setMode(const uint8_t mode);
85  uint8_t getMode(const bool useRaw = false);
86  void setRaw(const uint8_t newState[]);
87  uint8_t* getRaw(void);
88  static bool validChecksum(const uint8_t state[],
89  const uint16_t length = kToshibaACStateLength);
90  uint8_t convertMode(const stdAc::opmode_t mode);
91  uint8_t convertFan(const stdAc::fanspeed_t speed);
92  static stdAc::opmode_t toCommonMode(const uint8_t mode);
93  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
95  String toString(void);
96 #ifndef UNIT_TEST
97 
98  private:
100 #else // UNIT_TEST
101  IRsendTest _irsend;
103 #endif // UNIT_TEST
106  void checksum(const uint16_t length = kToshibaACStateLength);
107  static uint8_t calcChecksum(const uint8_t state[],
108  const uint16_t length = kToshibaACStateLength);
109  uint8_t mode_state;
110 };
111 
112 #endif // IR_TOSHIBA_H_
IRToshibaAC::off
void off(void)
Set the requested power state of the A/C to off.
Definition: ir_Toshiba.cpp:134
IRToshibaAC::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivilant.
Definition: ir_Toshiba.cpp:249
IRToshibaAC
Class for handling detailed Toshiba A/C messages.
Definition: ir_Toshiba.h:62
kToshibaAcCool
const uint8_t kToshibaAcCool
Definition: ir_Toshiba.h:34
IRToshibaAC::calcChecksum
static uint8_t calcChecksum(const uint8_t state[], const uint16_t length=kToshibaACStateLength)
Calculate the checksum for a given state.
Definition: ir_Toshiba.cpp:101
IRToshibaAC::on
void on(void)
Set the requested power state of the A/C to on.
Definition: ir_Toshiba.cpp:131
IRToshibaAC::convertMode
uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Toshiba.cpp:222
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
kToshibaAcFanAuto
const uint8_t kToshibaAcFanAuto
Definition: ir_Toshiba.h:40
IRToshibaAC::send
void send(const uint16_t repeat=kToshibaACMinRepeat)
Send the current internal state as an IR message.
Definition: ir_Toshiba.cpp:78
kToshibaAcModeOffset
const uint8_t kToshibaAcModeOffset
Definition: ir_Toshiba.h:31
IRToshibaAC::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Toshiba.cpp:172
IRToshibaAC::toCommon
stdAc::state_t toCommon(void)
Convert the current internal state into its stdAc::state_t equivilant.
Definition: ir_Toshiba.cpp:274
kToshibaAcMinTemp
const uint8_t kToshibaAcMinTemp
Definition: ir_Toshiba.h:46
IRToshibaAC::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Toshiba.h:99
IRToshibaAC::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Toshiba.h:73
IRsend.h
IRToshibaAC::getRaw
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol.
Definition: ir_Toshiba.cpp:85
IRToshibaAC::checksum
void checksum(const uint16_t length=kToshibaACStateLength)
Calculate & set the checksum for the current internal state of the remote.
Definition: ir_Toshiba.cpp:124
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:170
IRToshibaAC::getPower
bool getPower(void)
Get the value of the current power setting.
Definition: ir_Toshiba.cpp:150
kToshibaAcPowerOffset
const uint8_t kToshibaAcPowerOffset
Definition: ir_Toshiba.h:37
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
IRToshibaAC::toString
String toString(void)
Convert the current internal state into a human readable string.
Definition: ir_Toshiba.cpp:300
IRToshibaAC::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Toshiba.cpp:138
String
std::string String
Definition: IRremoteESP8266.h:1093
IRToshibaAC::IRToshibaAC
IRToshibaAC(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Toshiba.cpp:59
kToshibaAcFanMed
const uint8_t kToshibaAcFanMed
Definition: ir_Toshiba.h:42
IRremoteESP8266.h
IRToshibaAC::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Toshiba.cpp:73
IRToshibaAC::stateReset
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition: ir_Toshiba.cpp:65
kToshibaAcTempSize
const uint8_t kToshibaAcTempSize
Definition: ir_Toshiba.h:45
IRToshibaAC::getTemp
uint8_t getTemp(void)
Get the current temperature setting.
Definition: ir_Toshiba.cpp:165
IRToshibaAC::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivilant.
Definition: ir_Toshiba.cpp:261
kToshibaAcHeat
const uint8_t kToshibaAcHeat
Definition: ir_Toshiba.h:36
IRToshibaAC::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Toshiba.cpp:203
kToshibaAcModeSize
const uint8_t kToshibaAcModeSize
Definition: ir_Toshiba.h:32
IRToshibaAC::setRaw
void setRaw(const uint8_t newState[])
Set the internal state from a valid code for this protocol.
Definition: ir_Toshiba.cpp:92
kToshibaACMinRepeat
const uint16_t kToshibaACMinRepeat
Definition: IRremoteESP8266.h:1001
IRToshibaAC::getMode
uint8_t getMode(const bool useRaw=false)
Get the operating mode setting of the A/C.
Definition: ir_Toshiba.cpp:193
kToshibaACStateLength
const uint16_t kToshibaACStateLength
Definition: IRremoteESP8266.h:999
IRToshibaAC::validChecksum
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:116
kToshibaAcFanSize
const uint8_t kToshibaAcFanSize
Definition: ir_Toshiba.h:39
kToshibaAcFanOffset
const uint8_t kToshibaAcFanOffset
Definition: ir_Toshiba.h:38
IRToshibaAC::remote_state
uint8_t remote_state[kToshibaACStateLength]
The state in IR code form.
Definition: ir_Toshiba.h:105
kToshibaAcDry
const uint8_t kToshibaAcDry
Definition: ir_Toshiba.h:35
IRToshibaAC::mode_state
uint8_t mode_state
Definition: ir_Toshiba.h:109
kToshibaAcAuto
const uint8_t kToshibaAcAuto
Definition: ir_Toshiba.h:33
kToshibaAcMaxTemp
const uint8_t kToshibaAcMaxTemp
Definition: ir_Toshiba.h:47
IRToshibaAC::convertFan
uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Toshiba.cpp:235
IRToshibaAC::setTemp
void setTemp(const uint8_t degrees)
Set the temperature.
Definition: ir_Toshiba.cpp:156
kToshibaAcTempOffset
const uint8_t kToshibaAcTempOffset
Definition: ir_Toshiba.h:44
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
IRToshibaAC::getFan
uint8_t getFan(void)
Get the current fan speed setting.
Definition: ir_Toshiba.cpp:183
kToshibaAcFanMax
const uint8_t kToshibaAcFanMax
Definition: ir_Toshiba.h:43
kToshibaAcFanMin
const uint8_t kToshibaAcFanMin
Definition: ir_Toshiba.h:41
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46