IRremoteESP8266

Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
IRToshibaAC Class Reference

Class for handling detailed Toshiba A/C messages. More...

`#include <ir_Toshiba.h>`

Collaboration diagram for IRToshibaAC:
[legend]

## Public Member Functions
| IRToshibaAC (const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
| Class constructor. More...
void | stateReset (void)
| Reset the state of the remote to a known good state/sequence. More...
void | send (const uint16_t repeat=kToshibaACMinRepeat)
| Send the current internal state as IR messages. More...
int8_t | calibrate (void)
| Run the calibration to calculate uSec timing offsets for this platform. More...
void | begin (void)
| Set up hardware to be able to send a message. More...
void | on (void)
| Set the requested power state of the A/C to on. More...
void | off (void)
| Set the requested power state of the A/C to off. More...
void | setPower (const bool on)
| Change the power setting. More...
bool | getPower (void) const
| Get the value of the current power setting. More...
void | setTemp (const uint8_t degrees)
| Set the temperature. More...
uint8_t | getTemp (void) const
| Get the current temperature setting. More...
void | setFan (const uint8_t speed)
| Set the speed of the fan. More...
uint8_t | getFan (void) const
| Get the current fan speed setting. More...
void | setTurbo (const bool on)
| Set the Turbo (Powerful) setting of the A/C. More...
bool | getTurbo (void) const
| Get the Turbo (Powerful) setting of the A/C. More...
void | setEcono (const bool on)
| Set the Economy mode setting of the A/C. More...
bool | getEcono (void) const
| Get the Economy mode setting of the A/C. More...
void | setFilter (const bool on)
| Set the filter (Pure/Ion Filter) setting of the A/C. More...
bool | getFilter (void) const
| Get the filter (Pure/Ion Filter) setting of the A/C. More...
void | setMode (const uint8_t mode)
| Set the operating mode of the A/C. More...
uint8_t | getMode (const bool raw=false) const
| Get the operating mode setting of the A/C. More...
void | setRaw (const uint8_t newState[], const uint16_t length=kToshibaACStateLength)
| Set the internal state from a valid code for this protocol. More...
uint8_t * | getRaw (void)
| Get a PTR to the internal state/code for this protocol with all integrity checks passing. More...
uint16_t | getStateLength (void) const
| Get the length of the current internal state per the protocol structure. More...
uint8_t | getSwing (const bool raw=true) const
| Get the swing setting of the A/C. More...
void | setSwing (const uint8_t setting)
| Set the swing setting of the A/C. More...
stdAc::state_t | toCommon (const stdAc::state_t *prev=NULL) const
| Convert the current internal state into its stdAc::state_t equivalent. More...
String | toString (void) const
| Convert the current internal state into a human readable string. More...

## Static Public Member Functions
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. More...
static bool | validChecksum (const uint8_t state[], const uint16_t length=kToshibaACStateLength)
| Verify the checksum is valid for a given state. More...
static uint8_t | convertMode (const stdAc::opmode_t mode)
| Convert a stdAc::opmode_t enum into its native mode. More...
static uint8_t | convertFan (const stdAc::fanspeed_t speed)
| Convert a stdAc::fanspeed_t enum into it's native speed. More...
static stdAc::opmode_t | toCommonMode (const uint8_t mode)
| Convert a native mode into its stdAc equivalent. More...
static stdAc::fanspeed_t | toCommonFanSpeed (const uint8_t speed)
| Convert a native fan speed into its stdAc equivalent. More...

## Private Member Functions
void | checksum (const uint16_t length=kToshibaACStateLength)
| Calculate & set the checksum for the current internal state of the remote. More...
void | setStateLength (const uint16_t size)
| Set the internal length of the current internal state per the protocol. More...
void | _backupState (void)
| Make a copy of the internal code-form A/C state. More...
void | _restoreState (void)
| Recover the internal code-form A/C state from the backup. More...

## Static Private Member Functions
static uint8_t | calcChecksum (const uint8_t state[], const uint16_t length=kToshibaACStateLength)
| Calculate the checksum for a given state. More...

## Private Attributes
IRsend | _irsend
| Instance of the IR send class. More...
ToshibaProtocol | _
uint8_t | backup [kToshibaACStateLengthLong]
| A backup copy of the state. More...
uint8_t | _prev_mode
| Store of the previously set mode. More...
bool | _send_swing
| Flag indicating if we need to send a swing message. More...
uint8_t | _swing_mode
| The saved swing state/mode/command. More...

## Detailed Description

Class for handling detailed Toshiba A/C messages.

## Constructor & Destructor Documentation

## ◆ IRToshibaAC()

IRToshibaAC::IRToshibaAC | ( | const uint16_t | pin,
|  | const bool | inverted = `false`,
|  | const bool | use_modulation = `true`
| ) |  |
| explicit

Class constructor.

Parameters

  [in] | pin | GPIO to be used when sending.
  [in] | inverted | Is the output signal to be inverted?
  [in] | use_modulation | Is frequency modulation to be used?

## Member Function Documentation

## ◆ _backupState()

void IRToshibaAC::_backupState | ( | void |  | ) |
| private

Make a copy of the internal code-form A/C state.

## ◆ _restoreState()

void IRToshibaAC::_restoreState | ( | void |  | ) |
| private

Recover the internal code-form A/C state from the backup.

## ◆ begin()

void IRToshibaAC::begin | ( | void |  | ) |

Set up hardware to be able to send a message.

## ◆ calcChecksum()

uint8_t IRToshibaAC::calcChecksum | ( | const uint8_t | state[],
|  | const uint16_t | length = `kToshibaACStateLength`
| ) |  |
| static private

Calculate the checksum for a given state.

Parameters

  [in] | state | The array to calc the checksum of.
  [in] | length | The length/size of the array.

Returns
  The calculated checksum value.

## ◆ calibrate()

int8_t IRToshibaAC::calibrate | ( | void |  | ) |
| inline

Run the calibration to calculate uSec timing offsets for this platform.

Returns
  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.

## ◆ checksum()

void IRToshibaAC::checksum | ( | const uint16_t | length = `kToshibaACStateLength` | ) |
| private

Calculate & set the checksum for the current internal state of the remote.

Parameters

  [in] | length | The length/size of the internal array to checksum.

## ◆ convertFan()

uint8_t IRToshibaAC::convertFan | ( | const stdAc::fanspeed_t | speed | ) |
| static

Convert a stdAc::fanspeed_t enum into it's native speed.

Parameters

  [in] | speed | The enum to be converted.

Returns
  The native equivalent of the enum.

## ◆ convertMode()

uint8_t IRToshibaAC::convertMode | ( | const stdAc::opmode_t | mode | ) |
| static

Convert a stdAc::opmode_t enum into its native mode.

Parameters

  [in] | mode | The enum to be converted.

Returns
  The native equivalent of the enum.

## ◆ getEcono()

bool IRToshibaAC::getEcono | ( | void |  | ) | const

Get the Economy mode setting of the A/C.

Returns
  true, if the current setting is on. Otherwise, false.

## ◆ getFan()

uint8_t IRToshibaAC::getFan | ( | void |  | ) | const

Get the current fan speed setting.

Returns
  The current fan speed/mode.

## ◆ getFilter()

bool IRToshibaAC::getFilter | ( | void |  | ) | const

Get the filter (Pure/Ion Filter) setting of the A/C.

Returns
  true, if the current setting is on. Otherwise, false.

## ◆ getInternalStateLength()

uint16_t IRToshibaAC::getInternalStateLength | ( | const uint8_t | state[],
|  | const uint16_t | size
| ) |  |
| static

Get the length of the supplied Toshiba state per it's protocol structure.

Parameters

  [in] | state | The array to get the built-in length from.
  [in] | size | The physical size of the state array.

Returns
  Nr. of bytes in use for the provided state message.

## ◆ getMode()

uint8_t IRToshibaAC::getMode | ( | const bool | raw = `false` | ) | const

Get the operating mode setting of the A/C.

Parameters

  [in] | raw | Get the value without any intelligent processing.

Returns
  The current operating mode setting.

## ◆ getPower()

bool IRToshibaAC::getPower | ( | void |  | ) | const

Get the value of the current power setting.

Returns
  true, the setting is on. false, the setting is off.

## ◆ getRaw()

uint8_t * IRToshibaAC::getRaw | ( | void |  | ) |

Get a PTR to the internal state/code for this protocol with all integrity checks passing.

Returns
  PTR to a code for this protocol based on the current internal state.

## ◆ getStateLength()

uint16_t IRToshibaAC::getStateLength | ( | void |  | ) | const

Get the length of the current internal state per the protocol structure.

Returns
  Nr. of bytes in use for the current internal state message.

## ◆ getSwing()

uint8_t IRToshibaAC::getSwing | ( | const bool | raw = `true` | ) | const

Get the swing setting of the A/C.

Parameters

  [in] | raw | Calculate the answer from just the state data.

Returns
  The current swing mode setting.

## ◆ getTemp()

uint8_t IRToshibaAC::getTemp | ( | void |  | ) | const

Get the current temperature setting.

Returns
  The current setting for temp. in degrees celsius.

## ◆ getTurbo()

bool IRToshibaAC::getTurbo | ( | void |  | ) | const

Get the Turbo (Powerful) setting of the A/C.

Returns
  true, if the current setting is on. Otherwise, false.

## ◆ off()

void IRToshibaAC::off | ( | void |  | ) |

Set the requested power state of the A/C to off.

## ◆ on()

void IRToshibaAC::on | ( | void |  | ) |

Set the requested power state of the A/C to on.

## ◆ send()

void IRToshibaAC::send | ( | const uint16_t | repeat = `kToshibaACMinRepeat` | ) |

Send the current internal state as IR messages.

Parameters

  [in] | repeat | Nr. of times the message will be repeated.

## ◆ setEcono()

void IRToshibaAC::setEcono | ( | const bool | on | ) |

Set the Economy mode setting of the A/C.

Parameters

  [in] | on | true, the setting is on. false, the setting is off. Note: Economy mode is mutually exclusive with Turbo mode.

## ◆ setFan()

void IRToshibaAC::setFan | ( | const uint8_t | speed | ) |

Set the speed of the fan.

Parameters

  [in] | speed | The desired setting (0 is Auto, 1-5 is the speed, 5 is Max)

## ◆ setFilter()

void IRToshibaAC::setFilter | ( | const bool | on | ) |

Set the filter (Pure/Ion Filter) setting of the A/C.

Parameters

  [in] | on | true, the setting is on. false, the setting is off.

## ◆ setMode()

void IRToshibaAC::setMode | ( | const uint8_t | mode | ) |

Set the operating mode of the A/C.

Parameters

  [in] | mode | The desired operating mode.

Note
  If we get an unexpected mode, default to AUTO.

See also
  https://github.com/crankyoldgit/IRremoteESP8266/issues/1205#issuecomment-654446771

## ◆ setPower()

void IRToshibaAC::setPower | ( | const bool | on | ) |

Change the power setting.

Parameters

  [in] | on | true, the setting is on. false, the setting is off.

## ◆ setRaw()

void IRToshibaAC::setRaw | ( | const uint8_t | newState[],
|  | const uint16_t | length = `kToshibaACStateLength`
| ) |  |

Set the internal state from a valid code for this protocol.

Parameters

  [in] | newState | A valid code for this protocol.
  [in] | length | The length/size of the array.

## ◆ setStateLength()

void IRToshibaAC::setStateLength | ( | const uint16_t | size | ) |
| private

Set the internal length of the current internal state per the protocol.

Parameters

  [in] | size | Nr. of bytes in use for the current internal state message.

## ◆ setSwing()

void IRToshibaAC::setSwing | ( | const uint8_t | setting | ) |

Set the swing setting of the A/C.

Parameters

  [in] | setting | The value of the desired setting.

## ◆ setTemp()

void IRToshibaAC::setTemp | ( | const uint8_t | degrees | ) |

Set the temperature.

Parameters

  [in] | degrees | The temperature in degrees celsius.

## ◆ setTurbo()

void IRToshibaAC::setTurbo | ( | const bool | on | ) |

Set the Turbo (Powerful) setting of the A/C.

Parameters

  [in] | on | true, the setting is on. false, the setting is off. Note: Turbo mode is mutually exclusive with Economy mode.

## ◆ stateReset()

void IRToshibaAC::stateReset | ( | void |  | ) |

Reset the state of the remote to a known good state/sequence.

See also
  https://github.com/r45635/HVAC-IR-Control/blob/master/HVAC_ESP8266/HVAC_ESP8266T.ino#L103

## ◆ toCommon()

stdAc::state_t IRToshibaAC::toCommon | ( | const stdAc::state_t * | prev = `NULL` | ) | const

Convert the current internal state into its stdAc::state_t equivalent.

Returns
  The stdAc equivalent of the native settings.

## ◆ toCommonFanSpeed()

stdAc::fanspeed_t IRToshibaAC::toCommonFanSpeed | ( | const uint8_t | spd | ) |
| static

Convert a native fan speed into its stdAc equivalent.

Parameters

  [in] | spd | The native setting to be converted.

Returns
  The stdAc equivalent of the native setting.

## ◆ toCommonMode()

stdAc::opmode_t IRToshibaAC::toCommonMode | ( | const uint8_t | mode | ) |
| static

Convert a native mode into its stdAc equivalent.

Parameters

  [in] | mode | The native setting to be converted.

Returns
  The stdAc equivalent of the native setting.

## ◆ toString()

String IRToshibaAC::toString | ( | void |  | ) | const

Convert the current internal state into a human readable string.

Returns
  A human readable string.

## ◆ validChecksum()

bool IRToshibaAC::validChecksum | ( | const uint8_t | state[],
|  | const uint16_t | length = `kToshibaACStateLength`
| ) |  |
| static

Verify the checksum is valid for a given state.

Parameters

  [in] | state | The array to verify the checksum of.
  [in] | length | The length/size of the array.

Returns
  true, if the state has a valid checksum. Otherwise, false.

## Member Data Documentation

## ◆ _

ToshibaProtocol IRToshibaAC::_
| private

## ◆ _irsend

IRsend IRToshibaAC::_irsend
| private

Instance of the IR send class.

## ◆ _prev_mode

uint8_t IRToshibaAC::_prev_mode
| private

Store of the previously set mode.

## ◆ _send_swing

bool IRToshibaAC::_send_swing
| private

Flag indicating if we need to send a swing message.

## ◆ _swing_mode

uint8_t IRToshibaAC::_swing_mode
| private

The saved swing state/mode/command.

## ◆ backup

uint8_t IRToshibaAC::backup[kToshibaACStateLengthLong]
| private

A backup copy of the state.

The documentation for this class was generated from the following files:

- src/ir_Toshiba.h
- src/ir_Toshiba.cpp