# IRremoteESP8266: src/ir_Toshiba.h Source File

ir_Toshiba.h
Go to the documentation of this file.
// Copyright 2017 David Conran
// Supports:
// Brand: Toshiba, Model: RAS-B13N3KV2
// Brand: Toshiba, Model: Akita EVO II
// Brand: Toshiba, Model: RAS-B13N3KVP-E
// Brand: Toshiba, Model: RAS 18SKP-ES
// Brand: Toshiba, Model: WH-TA04NE
// Brand: Toshiba, Model: WC-L03SE
// Brand: Carrier, Model: 42NQV060M2 / 38NYV060M2 A/C
// Brand: Carrier, Model: 42NQV050M2 / 38NYV050M2 A/C
// Brand: Carrier, Model: 42NQV035M2 / 38NYV035M2 A/C
// Brand: Carrier, Model: 42NQV025M2 / 38NYV025M2 A/C
#ifndef IR_TOSHIBA_H_
#define IR_TOSHIBA_H_
#define __STDC_LIMIT_MACROS
#include <stdint.h>
#ifdef ARDUINO
#include <Arduino.h>
#endif
#include "IRremoteESP8266.h"
#include "IRsend.h"
#ifdef UNIT_TEST
#include "IRsend_test.h"
#endif
// Constants
// Byte[0] - 0xF2
// Byte[1] - 0x0D (inverted previous byte's value)
// Byte[2] - The expected payload length (in bytes) past the Byte[4].
const uint8_t kToshibaAcLengthByte = 2;
const uint8_t kToshibaAcMinLength = 6;
// Byte[3] - The bit-inverted value of the "length" byte.
const uint16_t kToshibaAcInvertedLength = 4;
// Byte[4]
const uint8_t kToshibaAcShortMsgBit = 5;
const uint8_t kToshibaAcLongMsgBit = 3;
// Byte[5]
const uint8_t kToshibaAcSwingOffset = 0;
const uint8_t kToshibaAcSwingSize = 2;
const uint8_t kToshibaAcSwingStep = 0;
const uint8_t kToshibaAcSwingOn = 1;
const uint8_t kToshibaAcSwingOff = 2;
const uint8_t kToshibaAcTempOffset = 4;
const uint8_t kToshibaAcTempSize = 4;
const uint8_t kToshibaAcMinTemp = 17;
const uint8_t kToshibaAcMaxTemp = 30;
// Byte[6]
const uint8_t kToshibaAcModeOffset = 0;
const uint8_t kToshibaAcModeSize = 3; // Mask 0b00000xxx
const uint8_t kToshibaAcAuto = 0; // 0b000
const uint8_t kToshibaAcCool = 1; // 0b001
const uint8_t kToshibaAcDry = 2; // 0b010
const uint8_t kToshibaAcHeat = 3; // 0b011
const uint8_t kToshibaAcFan = 4; // 0b100
const uint8_t kToshibaAcOff = 7; // 0b111
const uint8_t kToshibaAcFanOffset = 5;
const uint8_t kToshibaAcFanSize = 3; // Mask 0bxxx00000
const uint8_t kToshibaAcFanAuto = 0; // 0b000
const uint8_t kToshibaAcFanMin = 1; // 0b001
const uint8_t kToshibaAcFanMed = 3; // 0b011
const uint8_t kToshibaAcFanMax = 5; // 0b101
// Byte[8] (Checksum for 72 bit messages, Eco/Turbo for long 80 bit messages)
const uint8_t kToshibaAcEcoTurboOffset = 0;
const uint8_t kToshibaAcEcoTurboSize = 2; // Mask 0b000000xx
const uint8_t kToshibaAcTurboOn = 1; // 0b01
const uint8_t kToshibaAcEconoOn = 3; // 0b11
// Byte[last] - Checksum (xor)
// Legacy defines. (Deprecated)
#define TOSHIBA_AC_AUTO kToshibaAcAuto
#define TOSHIBA_AC_COOL kToshibaAcCool
#define TOSHIBA_AC_DRY kToshibaAcDry
#define TOSHIBA_AC_HEAT kToshibaAcHeat
#define TOSHIBA_AC_POWER kToshibaAcPower
#define TOSHIBA_AC_FAN_AUTO kToshibaAcFanAuto
#define TOSHIBA_AC_FAN_MAX kToshibaAcFanMax
#define TOSHIBA_AC_MIN_TEMP kToshibaAcMinTemp
#define TOSHIBA_AC_MAX_TEMP kToshibaAcMaxTemp
// Classes
class IRToshibaAC {
public:
explicit IRToshibaAC(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
void stateReset(void);
#if SEND_TOSHIBA_AC
void send(const uint16_t repeat = kToshibaACMinRepeat);
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif // SEND_TOSHIBA_AC
void begin(void);
void on(void);
void off(void);
void setPower(const bool on);
bool getPower(void);
void setTemp(const uint8_t degrees);
uint8_t getTemp(void);
void setFan(const uint8_t speed);
uint8_t getFan(void);
void setTurbo(const bool on);
bool getTurbo(void);
void setEcono(const bool on);
bool getEcono(void);
void setMode(const uint8_t mode);
uint8_t getMode(const bool raw = false);
void setRaw(const uint8_t newState[]);
uint8_t* getRaw(void);
static uint16_t getInternalStateLength(const uint8_t state[],
const uint16_t size);
uint16_t getStateLength(void);
static bool validChecksum(const uint8_t state[],
const uint16_t length = kToshibaACStateLength);
uint8_t getSwing(const bool raw = true);
void setSwing(const uint8_t setting);
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(void);
String toString(void);
#ifndef UNIT_TEST
private:
IRsend _irsend;
#else // UNIT_TEST
IRsendTest _irsend;
#endif // UNIT_TEST
uint8_t remote_state[kToshibaACStateLengthLong];
uint8_t backup[kToshibaACStateLengthLong];
uint8_t prev_mode;
bool _send_swing;
uint8_t _swing_mode;
void checksum(const uint16_t length = kToshibaACStateLength);
static uint8_t calcChecksum(const uint8_t state[],
const uint16_t length = kToshibaACStateLength);
void setStateLength(const uint16_t size);
void _backupState(void);
void _restoreState(void);
};
#endif // IR_TOSHIBA_H_
IRToshibaAC::off
void off(void)
Set the requested power state of the A/C to off.
Definition: ir_Toshiba.cpp:190
IRToshibaAC::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Toshiba.cpp:377
IRToshibaAC
Class for handling detailed Toshiba A/C messages.
Definition: ir_Toshiba.h:100
IRToshibaAC::getStateLength
uint16_t getStateLength(void)
Get the length of the current internal state per the protocol structure.
Definition: ir_Toshiba.cpp:112
kToshibaAcSwingSize
const uint8_t kToshibaAcSwingSize
Mask 0b000000xx.
Definition: ir_Toshiba.h:56
IRToshibaAC::setSwing
void setSwing(const uint8_t setting)
Set the swing setting of the A/C.
Definition: ir_Toshiba.cpp:255
kToshibaAcCool
const uint8_t kToshibaAcCool
Definition: ir_Toshiba.h:69
IRToshibaAC::setTurbo
void setTurbo(const bool on)
Set the Turbo (Powerful) setting of the A/C.
Definition: ir_Toshiba.cpp:317
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:153
IRToshibaAC::_swing_mode
uint8_t _swing_mode
The saved swing state/mode/command.
Definition: ir_Toshiba.h:156
IRToshibaAC::on
void on(void)
Set the requested power state of the A/C to on.
Definition: ir_Toshiba.cpp:187
IRToshibaAC::_backupState
void _backupState(void)
Make a copy of the internal code-form A/C state.
Definition: ir_Toshiba.cpp:124
IRToshibaAC::convertMode
uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Toshiba.cpp:349
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
IRToshibaAC::getInternalStateLength
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:103
kToshibaAcFanAuto
const uint8_t kToshibaAcFanAuto
Definition: ir_Toshiba.h:76
IRToshibaAC::send
void send(const uint16_t repeat=kToshibaACMinRepeat)
Send the current internal state as IR messages.
Definition: ir_Toshiba.cpp:83
IRToshibaAC::setEcono
void setEcono(const bool on)
Set the Economy mode setting of the A/C.
Definition: ir_Toshiba.cpp:337
kToshibaAcInvertedLength
const uint16_t kToshibaAcInvertedLength
Nr. of leading bytes in inverted pairs.
Definition: ir_Toshiba.h:49
kToshibaAcModeOffset
const uint8_t kToshibaAcModeOffset
Definition: ir_Toshiba.h:66
IRToshibaAC::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Toshiba.cpp:227
IRToshibaAC::toCommon
stdAc::state_t toCommon(void)
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Toshiba.cpp:404
kToshibaAcMinTemp
const uint8_t kToshibaAcMinTemp
17C
Definition: ir_Toshiba.h:63
IRToshibaAC::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Toshiba.h:146
IRToshibaAC::getSwing
uint8_t getSwing(const bool raw=true)
Get the swing setting of the A/C.
Definition: ir_Toshiba.cpp:248
IRToshibaAC::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Toshiba.h:111
IRsend.h
IRToshibaAC::getRaw
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol with all integrity checks passing.
Definition: ir_Toshiba.cpp:136
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:171
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:182
IRToshibaAC::getPower
bool getPower(void)
Get the value of the current power setting.
Definition: ir_Toshiba.cpp:205
IRToshibaAC::getMode
uint8_t getMode(const bool raw=false)
Get the operating mode setting of the A/C.
Definition: ir_Toshiba.cpp:271
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
kToshibaAcSwingOn
const uint8_t kToshibaAcSwingOn
0b01
Definition: ir_Toshiba.h:58
IRToshibaAC::toString
String toString(void)
Convert the current internal state into a human readable string.
Definition: ir_Toshiba.cpp:431
IRToshibaAC::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Toshiba.cpp:194
String
std::string String
Definition: IRremoteESP8266.h:1178
IRToshibaAC::IRToshibaAC
IRToshibaAC(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Toshiba.cpp:62
kToshibaAcSwingOff
const uint8_t kToshibaAcSwingOff
0b10
Definition: ir_Toshiba.h:59
kToshibaAcFanMed
const uint8_t kToshibaAcFanMed
Definition: ir_Toshiba.h:78
IRremoteESP8266.h
kToshibaAcLongMsgBit
const uint8_t kToshibaAcLongMsgBit
Mask 0b00001000.
Definition: ir_Toshiba.h:53
kToshibaAcEcoTurboSize
const uint8_t kToshibaAcEcoTurboSize
Definition: ir_Toshiba.h:82
IRToshibaAC::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Toshiba.cpp:78
kToshibaAcMinLength
const uint8_t kToshibaAcMinLength
Min Nr. of bytes in a message. Known lengths are: 1 (56 bit message) 3 (72 bit message) 4 (80 bit mes...
Definition: ir_Toshiba.h:43
kToshibaAcSwingStep
const uint8_t kToshibaAcSwingStep
0b00
Definition: ir_Toshiba.h:57
IRToshibaAC::stateReset
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition: ir_Toshiba.cpp:68
kToshibaAcTempSize
const uint8_t kToshibaAcTempSize
Mask 0bxxxx0000.
Definition: ir_Toshiba.h:62
IRToshibaAC::_restoreState
void _restoreState(void)
Recover the internal code-form A/C state from the backup.
Definition: ir_Toshiba.cpp:129
IRToshibaAC::getTemp
uint8_t getTemp(void)
Get the current temperature setting.
Definition: ir_Toshiba.cpp:220
kToshibaAcFan
const uint8_t kToshibaAcFan
Definition: ir_Toshiba.h:72
IRToshibaAC::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Toshiba.cpp:391
kToshibaAcHeat
const uint8_t kToshibaAcHeat
Definition: ir_Toshiba.h:71
IRToshibaAC::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Toshiba.cpp:285
IRToshibaAC::prev_mode
uint8_t prev_mode
Store of the previously set mode.
Definition: ir_Toshiba.h:154
IRToshibaAC::getEcono
bool getEcono(void)
Get the Economy mode setting of the A/C.
Definition: ir_Toshiba.cpp:328
kToshibaAcTurboOn
const uint8_t kToshibaAcTurboOn
Definition: ir_Toshiba.h:83
kToshibaAcModeSize
const uint8_t kToshibaAcModeSize
Definition: ir_Toshiba.h:67
IRToshibaAC::setRaw
void setRaw(const uint8_t newState[])
Set the internal state from a valid code for this protocol.
Definition: ir_Toshiba.cpp:143
kToshibaAcLengthByte
const uint8_t kToshibaAcLengthByte
Byte pos of the "length" attribute.
Definition: ir_Toshiba.h:42
kToshibaACMinRepeat
const uint16_t kToshibaACMinRepeat
Definition: IRremoteESP8266.h:1078
kToshibaACStateLength
const uint16_t kToshibaACStateLength
Definition: IRremoteESP8266.h:1076
IRToshibaAC::_send_swing
bool _send_swing
Flag indicating if we need to send a swing message.
Definition: ir_Toshiba.h:155
kToshibaACStateLengthLong
const uint16_t kToshibaACStateLengthLong
Definition: IRremoteESP8266.h:1081
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:162
kToshibaAcFanSize
const uint8_t kToshibaAcFanSize
Definition: ir_Toshiba.h:75
kToshibaAcFanOffset
const uint8_t kToshibaAcFanOffset
Definition: ir_Toshiba.h:74
kToshibaAcDry
const uint8_t kToshibaAcDry
Definition: ir_Toshiba.h:70
IRToshibaAC::backup
uint8_t backup[kToshibaACStateLengthLong]
A backup copy of the state.
Definition: ir_Toshiba.h:153
kToshibaAcAuto
const uint8_t kToshibaAcAuto
Definition: ir_Toshiba.h:68
kToshibaAcShortMsgBit
const uint8_t kToshibaAcShortMsgBit
Mask 0b00x00000.
Definition: ir_Toshiba.h:52
kToshibaAcMaxTemp
const uint8_t kToshibaAcMaxTemp
30C
Definition: ir_Toshiba.h:64
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:363
IRToshibaAC::setTemp
void setTemp(const uint8_t degrees)
Set the temperature.
Definition: ir_Toshiba.cpp:211
IRToshibaAC::getTurbo
bool getTurbo(void)
Get the Turbo (Powerful) setting of the A/C.
Definition: ir_Toshiba.cpp:308
IRToshibaAC::remote_state
uint8_t remote_state[kToshibaACStateLengthLong]
The state in code form.
Definition: ir_Toshiba.h:152
kToshibaAcEcoTurboOffset
const uint8_t kToshibaAcEcoTurboOffset
Definition: ir_Toshiba.h:81
kToshibaAcTempOffset
const uint8_t kToshibaAcTempOffset
Bit offset.
Definition: ir_Toshiba.h:61
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:238
kToshibaAcFanMax
const uint8_t kToshibaAcFanMax
Definition: ir_Toshiba.h:79
kToshibaAcSwingOffset
const uint8_t kToshibaAcSwingOffset
Bit offset.
Definition: ir_Toshiba.h:55
kToshibaAcEconoOn
const uint8_t kToshibaAcEconoOn
Definition: ir_Toshiba.h:84
kToshibaAcFanMin
const uint8_t kToshibaAcFanMin
Definition: ir_Toshiba.h:77
IRToshibaAC::setStateLength
void setStateLength(const uint16_t size)
Set the internal length of the current internal state per the protocol.
Definition: ir_Toshiba.cpp:118
kToshibaAcOff
const uint8_t kToshibaAcOff
Definition: ir_Toshiba.h:73
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46