IRremoteESP8266: IRCoronaAc Class Reference

IRremoteESP8266

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

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

`#include <ir_Corona.h>`

Collaboration diagram for IRCoronaAc:
[legend]

## Public Member Functions

| IRCoronaAc (const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
| Class constructor for handling detailed Corona A/C messages. More...
void | stateReset ()
| Reset the internal state to a fixed known good state. More...
void | send (const uint16_t repeat=kNoRepeat)
| Send the current internal state as an IR message. More...
int8_t | calibrate (void)
| Run the calibration to calculate uSec timing offsets for this platform. More...
void | begin ()
| Set up hardware to be able to send a message. More...
void | setPower (const bool on)
| Change the power setting. (in practice Standby, remote power) More...
bool | getPower (void) const
| Get the current power setting. (in practice Standby, remote power) More...
bool | getPowerButton (void) const
| Get the value of the current power button setting. More...
void | on (void)
| Change the power setting to On. More...
void | off (void)
| Change the power setting to Off. More...
void | setTemp (const uint8_t temp)
| Set the temp in deg C. More...
uint8_t | getTemp (void) const
| Get the current temperature from the internal state. More...
void | setSwingVToggle (const bool on)
| Set the Vertical Swing toggle setting. More...
bool | getSwingVToggle (void) const
| Get the Vertical Swing toggle setting. More...
void | setFan (const uint8_t speed)
| Set the operating speed of the A/C Fan. More...
uint8_t | getFan (void) const
| Get the operating speed of the A/C Fan. More...
void | setMode (const uint8_t mode)
| Set the operating mode of the A/C. More...
uint8_t | getMode (void) const
| Get the operating mode setting of the A/C. More...
void | setEcono (const bool on)
| Change the powersave setting. More...
bool | getEcono (void) const
| Get the value of the current powersave setting. More...
void | setOnTimer (const uint16_t nr_of_mins)
| Set the On Timer time. More...
uint16_t | getOnTimer (void) const
| Get the current On Timer time. More...
void | setOffTimer (const uint16_t nr_of_mins)
| Set the Off Timer time. More...
uint16_t | getOffTimer (void) const
| Get the current Off Timer time. More...
uint8_t * | getRaw ()
| Get a copy of the internal state as a valid code for this protocol. More...
void | setRaw (const uint8_t new_code[], const uint16_t length=kCoronaAcStateLength)
| Set the internal state from a valid code for this protocol. More...
stdAc::state_t | toCommon (void) const
| Convert the A/C state to it's common stdAc::state_t equivalent. More...
String | toString (void) const
| Convert the internal state into a human readable string. More...

## Static Public Member Functions

static bool | validSection (const uint8_t state[], const uint16_t pos, const uint8_t section)
| Check that a CoronaAc Section part is valid with section byte and inverted. More...
static uint8_t | convertMode (const stdAc::opmode_t mode)
| Convert a standard A/C mode into its native mode. More...
static uint8_t | convertFan (const stdAc::fanspeed_t speed)
| Convert a standard A/C Fan speed into its native fan speed. More...
static stdAc::opmode_t | toCommonMode (const uint8_t mode)
| Convert a native mode to it's common stdAc::opmode_t equivalent. More...
static stdAc::fanspeed_t | toCommonFanSpeed (const uint8_t speed)
| Convert a native fan speed to it's common equivalent. More...

## Private Member Functions

void | setPowerButton (const bool on)
| Change the power button setting. More...
void | _setTimer (const uint8_t section, const uint16_t nr_of_mins)
| Set the Timer time. More...
uint16_t | _getTimer (const uint8_t section) const
| Get the current Timer time. More...

## Static Private Member Functions

static uint8_t | getSectionByte (const uint8_t section)
| Get the byte that identifies the section. More...
static void | checksum (uint8_t *data)
| Calculate and set the check values for the internal state. More...

## Private Attributes

IRsend | _irsend
| Instance of the IR send class. More...
CoronaProtocol | _

## Detailed Description

Class for handling detailed Corona A/C messages.

## Constructor & Destructor Documentation

## ◆ IRCoronaAc()

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

explicit

Class constructor for handling detailed Corona A/C messages.

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

## ◆ _getTimer()

uint16_t IRCoronaAc::_getTimer | ( | const uint8_t | section | ) | const

private

Get the current Timer time.

Returns
  The number of minutes it is set for. 0 means it's off.

Note
  The A/C protocol supports 2 second increments

## ◆ _setTimer()

void IRCoronaAc::_setTimer | ( | const uint8_t | section,
|  | const uint16_t | nr_of_mins
| ) |  |

private

Set the Timer time.

Parameters

  [in] | section | index of section, used for offset.
  [in] | nr_of_mins | Number of minutes to set the timer to. (non in range value is disable). Valid is from 1 minute to 12 hours

## ◆ begin()

void IRCoronaAc::begin | ( |  | ) |

Set up hardware to be able to send a message.

## ◆ calibrate()

int8_t IRCoronaAc::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 IRCoronaAc::checksum | ( | uint8_t * | data | ) |

staticprivate

Calculate and set the check values for the internal state.

Parameters

  [in,out] | data | The array to be modified

## ◆ convertFan()

uint8_t IRCoronaAc::convertFan | ( | const stdAc::fanspeed_t | speed | ) |

static

Convert a standard A/C Fan speed into its native fan speed.

Parameters

  [in] | speed | The desired stdAc::fanspeed_t fan speed

Returns
  The given fan speed in native format

## ◆ convertMode()

uint8_t IRCoronaAc::convertMode | ( | const stdAc::opmode_t | mode | ) |

static

Convert a standard A/C mode into its native mode.

Parameters

  [in] | mode | A stdAc::opmode_t mode to be converted to it's native equivalent

Returns
  The corresponding native mode.

## ◆ getEcono()

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

Get the value of the current powersave setting.

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

## ◆ getFan()

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

Get the operating speed of the A/C Fan.

Returns
  The current operating fan speed setting

## ◆ getMode()

uint8_t IRCoronaAc::getMode | ( | void |  | ) | const

Get the operating mode setting of the A/C.

Returns
  The current operating mode setting.

## ◆ getOffTimer()

uint16_t IRCoronaAc::getOffTimer | ( | void |  | ) | const

Get the current Off Timer time.

Returns
  The number of minutes it is set for. 0 means it's off.

## ◆ getOnTimer()

uint16_t IRCoronaAc::getOnTimer | ( | void |  | ) | const

Get the current On Timer time.

Returns
  The number of minutes it is set for. 0 means it's off.

## ◆ getPower()

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

Get the current power setting. (in practice Standby, remote power)

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

## ◆ getPowerButton()

bool IRCoronaAc::getPowerButton | ( | void |  | ) | const

Get the value of the current power button setting.

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

## ◆ getRaw()

uint8_t * IRCoronaAc::getRaw | ( |  | ) |

Get a copy of the internal state as a valid code for this protocol.

Returns
  A Ptr to a valid code for this protocol based on the current internal state.

Note
  To get stable AC state, if no timers, send once without PowerButton set, and once with

## ◆ getSectionByte()

uint8_t IRCoronaAc::getSectionByte | ( | const uint8_t | section | ) |

staticprivate

Get the byte that identifies the section.

Parameters

  [in] | section | Index of the section 0-2, 3 and above is used as the special case for short message

Returns
  The byte used for the section

## ◆ getSwingVToggle()

bool IRCoronaAc::getSwingVToggle | ( | void |  | ) | const

Get the Vertical Swing toggle setting.

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

## ◆ getTemp()

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

Get the current temperature from the internal state.

Returns
  The current temperature in Celsius.

## ◆ off()

void IRCoronaAc::off | ( | void |  | ) |

Change the power setting to Off.

## ◆ on()

void IRCoronaAc::on | ( | void |  | ) |

Change the power setting to On.

## ◆ send()

void IRCoronaAc::send | ( | const uint16_t | repeat = `kNoRepeat` | ) |

Send the current internal state as an IR message.

Parameters

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

## ◆ setEcono()

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

Change the powersave setting.

Parameters

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

## ◆ setFan()

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

Set the operating speed of the A/C Fan.

Parameters

  [in] | speed | The desired fan speed

## ◆ setMode()

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

Set the operating mode of the A/C.

Parameters

  [in] | mode | The desired operating mode.

## ◆ setOffTimer()

void IRCoronaAc::setOffTimer | ( | const uint16_t | nr_of_mins | ) |

Set the Off Timer time.

Parameters

  [in] | nr_of_mins | Number of minutes to set the timer to. (0 or kCoronaAcTimerOff is disable).

## ◆ setOnTimer()

void IRCoronaAc::setOnTimer | ( | const uint16_t | nr_of_mins | ) |

Set the On Timer time.

Parameters

  [in] | nr_of_mins | Number of minutes to set the timer to. (0 or kCoronaAcTimerOff is disable).

## ◆ setPower()

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

Change the power setting. (in practice Standby, remote power)

Parameters

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

Note
  If changed, setPowerButton is also needed, unless timer is or was active

## ◆ setPowerButton()

void IRCoronaAc::setPowerButton | ( | const bool | on | ) |

private

Change the power button setting.

Parameters

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

Note
  this sets that the AC should set power, use setPower to define if the AC should end up as on or off When no timer is active, the below is a truth table With AC On, a command with setPower and setPowerButton gives nothing With AC On, a command with setPower but not setPowerButton is ok With AC Off, a command with setPower but not setPowerButton gives nothing With AC Off, a command with setPower and setPowerButton is ok

## ◆ setRaw()

void IRCoronaAc::setRaw | ( | const uint8_t | new_code[],
|  | const uint16_t | length = `kCoronaAcStateLength`
| ) |  |

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

Parameters

  [in] | new_code | A valid state for this protocol.
  [in] | length | of the new_code array.

## ◆ setSwingVToggle()

void IRCoronaAc::setSwingVToggle | ( | const bool | on | ) |

Set the Vertical Swing toggle setting.

Parameters

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

Note
  This is a button press, and not a state after sending it once you should turn it off

## ◆ setTemp()

void IRCoronaAc::setTemp | ( | const uint8_t | temp | ) |

Set the temp in deg C.

Parameters

  [in] | temp | The desired temperature in Celsius.

## ◆ stateReset()

void IRCoronaAc::stateReset | ( |  | ) |

Reset the internal state to a fixed known good state.

Note
  The state is powered off.

## ◆ toCommon()

stdAc::state_t IRCoronaAc::toCommon | ( | void |  | ) | const

Convert the A/C state to it's common stdAc::state_t equivalent.

Returns
  A stdAc::state_t state.

## ◆ toCommonFanSpeed()

stdAc::fanspeed_t IRCoronaAc::toCommonFanSpeed | ( | const uint8_t | speed | ) |

static

Convert a native fan speed to it's common equivalent.

Parameters

  [in] | speed | The desired native fan speed

Returns
  The given fan speed in stdAc::fanspeed_t format

## ◆ toCommonMode()

stdAc::opmode_t IRCoronaAc::toCommonMode | ( | const uint8_t | mode | ) |

static

Convert a native mode to it's common stdAc::opmode_t equivalent.

Parameters

  [in] | mode | A native operation mode to be converted.

Returns
  The corresponding common stdAc::opmode_t mode.

## ◆ toString()

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

Convert the internal state into a human readable string.

Returns
  The current internal state expressed as a human readable String.

## ◆ validSection()

bool IRCoronaAc::validSection | ( | const uint8_t | state[],
|  | const uint16_t | pos,
|  | const uint8_t | section
| ) |  |

static

Check that a CoronaAc Section part is valid with section byte and inverted.

Parameters

  [in] | state | An array of bytes containing the section
  [in] | pos | Where to start in the state array
  [in] | section | Which section to work with Used to get the section byte, and is validated against pos

Returns
  true if section is valid, otherwise false

## Member Data Documentation

## ◆ _

CoronaProtocol IRCoronaAc::_

private

## ◆ _irsend

IRsend IRCoronaAc::_irsend

private

Instance of the IR send class.

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

- src/ir_Corona.h
- src/ir_Corona.cpp