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

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

#include <ir_Sharp.h>

Collaboration diagram for IRSharpAc:
Collaboration graph
[legend]

Public Member Functions

 IRSharpAc (const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
 Class constructor. More...
 
void send (const uint16_t repeat=kSharpAcDefaultRepeat)
 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 (void)
 Set up hardware to be able to send a message. More...
 
void setModel (const sharp_ac_remote_model_t model)
 Set the model of the A/C to emulate. More...
 
sharp_ac_remote_model_t getModel (const bool raw=false)
 Get/Detect the model of the A/C. 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, const bool prev_on=true)
 Change the power setting, including the previous power state. More...
 
bool getPower (void)
 Get the value of the current power setting. More...
 
bool isPowerSpecial (void)
 Is one of the special power states in use? More...
 
void setTemp (const uint8_t temp, const bool save=true)
 Set the temperature. More...
 
uint8_t getTemp (void)
 Get the current temperature setting. More...
 
void setFan (const uint8_t fan, const bool save=true)
 Set the speed of the fan. More...
 
uint8_t getFan (void)
 Get the current fan speed setting. More...
 
void setMode (const uint8_t mode, const bool save=true)
 Set the operating mode of the A/C. More...
 
uint8_t getMode (void)
 Get the operating mode setting of the A/C. More...
 
void setSpecial (const uint8_t mode)
 Set the value of the Special (button/command?) setting. More...
 
uint8_t getSpecial (void)
 Get the value of the Special (button/command?) setting. More...
 
bool getTurbo (void)
 Get the Turbo setting of the A/C. More...
 
void setTurbo (const bool on)
 Set the Turbo setting of the A/C. More...
 
bool getSwingToggle (void)
 Get the (vertical) Swing Toggle setting of the A/C. More...
 
void setSwingToggle (const bool on)
 Set the (vertical) Swing Toggle setting of the A/C. More...
 
bool getIon (void)
 Get the Ion (Filter) setting of the A/C. More...
 
void setIon (const bool on)
 Set the Ion (Filter) setting of the A/C. More...
 
bool getEconoToggle (void)
 Get the Economical mode toggle setting of the A/C. More...
 
void setEconoToggle (const bool on)
 Set the Economical mode toggle setting of the A/C. More...
 
bool getLightToggle (void)
 Get the Light toggle setting of the A/C. More...
 
void setLightToggle (const bool on)
 Set the Light mode toggle setting of the A/C. More...
 
uint16_t getTimerTime (void)
 Get how long the timer is set for, in minutes. More...
 
bool getTimerEnabled (void)
 Is the Timer enabled? More...
 
bool getTimerType (void)
 Get the current timer type. More...
 
void setTimer (bool enable, bool timer_type, uint16_t mins)
 Set or cancel the timer function. More...
 
bool getClean (void)
 Get the Clean setting of the A/C. More...
 
void setClean (const bool on)
 Set the Economical mode toggle setting of the A/C. More...
 
uint8_t * getRaw (void)
 Get a PTR to the internal state/code for this protocol. More...
 
void setRaw (const uint8_t new_code[], const uint16_t length=kSharpAcStateLength)
 Set the internal state from a valid code for this protocol. More...
 
stdAc::opmode_t toCommonMode (const uint8_t mode)
 Convert a native mode into its stdAc equivalent. More...
 
stdAc::fanspeed_t toCommonFanSpeed (const uint8_t speed)
 Convert a native fan speed into its stdAc equivalent. More...
 
stdAc::state_t toCommon (void)
 Convert the current internal state into its stdAc::state_t equivalent. More...
 
String toString (void)
 Convert the current internal state into a human readable string. More...
 

Static Public Member Functions

static bool validChecksum (uint8_t state[], const uint16_t length=kSharpAcStateLength)
 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...
 

Private Member Functions

void stateReset (void)
 Reset the state of the remote to a known good state/sequence. More...
 
void checksum (void)
 Calculate and set the checksum values for the internal state. More...
 
void setPowerSpecial (const uint8_t value)
 Set the value of the Power Special setting without any checks. More...
 
uint8_t getPowerSpecial (void)
 Get the value of the Power Special setting. More...
 
void clearPowerSpecial (void)
 Clear the "special"/non-normal bits in the power section. e.g. for normal/common command modes. More...
 
bool _getEconoToggle (void)
 Get the Economical mode toggle setting of the A/C. More...
 
void _setEconoToggle (const bool on)
 Set the Economical mode toggle setting of the A/C. More...
 

Static Private Member Functions

static uint8_t calcChecksum (uint8_t state[], const uint16_t length=kSharpAcStateLength)
 Calculate the checksum for a given state. More...
 

Private Attributes

IRsend _irsend
 Instance of the IR send class. More...
 
uint8_t remote [kSharpAcStateLength]
 State of the remote in IR code form. More...
 
uint8_t _temp
 Saved copy of the desired temp. More...
 
uint8_t _mode
 Saved copy of the desired mode. More...
 
uint8_t _fan
 Saved copy of the desired fan speed. More...
 
sharp_ac_remote_model_t _model
 Saved copy of the model. More...
 

Detailed Description

Class for handling detailed Sharp A/C messages.

Constructor & Destructor Documentation

◆ IRSharpAc()

IRSharpAc::IRSharpAc ( const uint16_t  pin,
const bool  inverted = false,
const bool  use_modulation = true 
)
explicit

Class constructor.

Parameters
[in]pinGPIO to be used when sending.
[in]invertedIs the output signal to be inverted?
[in]use_modulationIs frequency modulation to be used?

Member Function Documentation

◆ _getEconoToggle()

bool IRSharpAc::_getEconoToggle ( void  )
private

Get the Economical mode toggle setting of the A/C.

Returns
true, the setting is on. false, the setting is off.
Note
Shares the same location as the Light setting on A705.

◆ _setEconoToggle()

void IRSharpAc::_setEconoToggle ( const bool  on)
private

Set the Economical mode toggle setting of the A/C.

Parameters
[in]ontrue, the setting is on. false, the setting is off.
Warning
Probably incompatible with setTurbo()
Note
Shares the same location as the Light setting on A705.

◆ begin()

void IRSharpAc::begin ( void  )

Set up hardware to be able to send a message.

◆ calcChecksum()

uint8_t IRSharpAc::calcChecksum ( uint8_t  state[],
const uint16_t  length = kSharpAcStateLength 
)
staticprivate

Calculate the checksum for a given state.

Parameters
[in]stateThe array to calc the checksum of.
[in]lengthThe length/size of the array.
Returns
The calculated 4-bit checksum value.

◆ calibrate()

int8_t IRSharpAc::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 IRSharpAc::checksum ( void  )
private

Calculate and set the checksum values for the internal state.

◆ clearPowerSpecial()

void IRSharpAc::clearPowerSpecial ( void  )
private

Clear the "special"/non-normal bits in the power section. e.g. for normal/common command modes.

◆ convertFan()

uint8_t IRSharpAc::convertFan ( const stdAc::fanspeed_t  speed)
static

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

Parameters
[in]speedThe enum to be converted.
Returns
The native equivalent of the enum.

◆ convertMode()

uint8_t IRSharpAc::convertMode ( const stdAc::opmode_t  mode)
static

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

Parameters
[in]modeThe enum to be converted.
Returns
The native equivalent of the enum.

◆ getClean()

bool IRSharpAc::getClean ( void  )

Get the Clean setting of the A/C.

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

◆ getEconoToggle()

bool IRSharpAc::getEconoToggle ( void  )

Get the Economical mode toggle setting of the A/C.

Returns
true, the setting is on. false, the setting is off.
Note
Not available on the A705 model.

◆ getFan()

uint8_t IRSharpAc::getFan ( void  )

Get the current fan speed setting.

Returns
The current fan speed/mode.

◆ getIon()

bool IRSharpAc::getIon ( void  )

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

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

◆ getLightToggle()

bool IRSharpAc::getLightToggle ( void  )

Get the Light toggle setting of the A/C.

Returns
true, the setting is on. false, the setting is off.
Note
Not available on the A907 model.

◆ getMode()

uint8_t IRSharpAc::getMode ( void  )

Get the operating mode setting of the A/C.

Returns
The current operating mode setting.

◆ getModel()

sharp_ac_remote_model_t IRSharpAc::getModel ( const bool  raw = false)

Get/Detect the model of the A/C.

Parameters
[in]rawTry to determine the model from the raw code only.
Returns
The enum of the compatible model.

◆ getPower()

bool IRSharpAc::getPower ( void  )

Get the value of the current power setting.

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

◆ getPowerSpecial()

uint8_t IRSharpAc::getPowerSpecial ( void  )
private

Get the value of the Power Special setting.

Returns
The setting's value.

◆ getRaw()

uint8_t * IRSharpAc::getRaw ( void  )

Get a PTR to the internal state/code for this protocol.

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

◆ getSpecial()

uint8_t IRSharpAc::getSpecial ( void  )

Get the value of the Special (button/command?) setting.

Returns
The setting's value.

◆ getSwingToggle()

bool IRSharpAc::getSwingToggle ( void  )

Get the (vertical) Swing Toggle setting of the A/C.

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

◆ getTemp()

uint8_t IRSharpAc::getTemp ( void  )

Get the current temperature setting.

Returns
The current setting for temp. in degrees celsius.

◆ getTimerEnabled()

bool IRSharpAc::getTimerEnabled ( void  )

Is the Timer enabled?

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

◆ getTimerTime()

uint16_t IRSharpAc::getTimerTime ( void  )

Get how long the timer is set for, in minutes.

Returns
The time in nr of minutes.

◆ getTimerType()

bool IRSharpAc::getTimerType ( void  )

Get the current timer type.

Returns
true, It's an "On" timer. false, It's an "Off" timer.

◆ getTurbo()

bool IRSharpAc::getTurbo ( void  )

Get the Turbo setting of the A/C.

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

◆ isPowerSpecial()

bool IRSharpAc::isPowerSpecial ( void  )

Is one of the special power states in use?

Returns
true, it is. false, it isn't.

◆ off()

void IRSharpAc::off ( void  )

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

◆ on()

void IRSharpAc::on ( void  )

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

◆ send()

void IRSharpAc::send ( const uint16_t  repeat = kSharpAcDefaultRepeat)

Send the current internal state as an IR message.

Parameters
[in]repeatNr. of times the message will be repeated.

◆ setClean()

void IRSharpAc::setClean ( const bool  on)

Set the Economical mode toggle setting of the A/C.

Parameters
[in]ontrue, the setting is on. false, the setting is off.
Note
Officially A/C unit needs to be "Off" before clean mode can be entered

◆ setEconoToggle()

void IRSharpAc::setEconoToggle ( const bool  on)

Set the Economical mode toggle setting of the A/C.

Parameters
[in]ontrue, the setting is on. false, the setting is off.
Warning
Probably incompatible with setTurbo()
Note
Not available on the A705 model.

◆ setFan()

void IRSharpAc::setFan ( const uint8_t  speed,
const bool  save = true 
)

Set the speed of the fan.

Parameters
[in]speedThe desired setting.
[in]saveDo we save this setting as a user set one?

◆ setIon()

void IRSharpAc::setIon ( const bool  on)

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

Parameters
[in]ontrue, the setting is on. false, the setting is off.

◆ setLightToggle()

void IRSharpAc::setLightToggle ( const bool  on)

Set the Light mode toggle setting of the A/C.

Parameters
[in]ontrue, the setting is on. false, the setting is off.
Warning
Probably incompatible with setTurbo()
Note
Not available on the A907 model.

◆ setMode()

void IRSharpAc::setMode ( const uint8_t  mode,
const bool  save = true 
)

Set the operating mode of the A/C.

Parameters
[in]modeThe desired operating mode.
[in]saveDo we save this setting as a user set one?

◆ setModel()

void IRSharpAc::setModel ( const sharp_ac_remote_model_t  model)

Set the model of the A/C to emulate.

Parameters
[in]modelThe enum of the appropriate model.

◆ setPower()

void IRSharpAc::setPower ( const bool  on,
const bool  prev_on = true 
)

Change the power setting, including the previous power state.

Parameters
[in]ontrue, the setting is on. false, the setting is off.
[in]prev_ontrue, the setting is on. false, the setting is off.

◆ setPowerSpecial()

void IRSharpAc::setPowerSpecial ( const uint8_t  value)
private

Set the value of the Power Special setting without any checks.

Parameters
[in]valueThe value to set Power Special to.

◆ setRaw()

void IRSharpAc::setRaw ( const uint8_t  new_code[],
const uint16_t  length = kSharpAcStateLength 
)

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

Parameters
[in]new_codeA valid code for this protocol.
[in]lengthThe length/size of the new_code array.

◆ setSpecial()

void IRSharpAc::setSpecial ( const uint8_t  mode)

Set the value of the Special (button/command?) setting.

Parameters
[in]modeThe value to set Special to.

◆ setSwingToggle()

void IRSharpAc::setSwingToggle ( const bool  on)

Set the (vertical) Swing Toggle setting of the A/C.

Parameters
[in]ontrue, the setting is on. false, the setting is off.

◆ setTemp()

void IRSharpAc::setTemp ( const uint8_t  temp,
const bool  save = true 
)

Set the temperature.

Parameters
[in]tempThe temperature in degrees celsius.
[in]saveDo we save this setting as a user set one?

◆ setTimer()

void IRSharpAc::setTimer ( bool  enable,
bool  timer_type,
uint16_t  mins 
)

Set or cancel the timer function.

Parameters
[in]enableIs the timer to be enabled (true) or canceled(false)?
[in]timer_typeAn On (true) or an Off (false). Ignored if canceled.
[in]minsNr. of minutes the timer is to be set to.
Note
Rounds down to 30 min increments. (max: 720 mins (12h), 0 is Off)

◆ setTurbo()

void IRSharpAc::setTurbo ( const bool  on)

Set the Turbo setting of the A/C.

Parameters
[in]ontrue, the setting is on. false, the setting is off.
Note
If you use this method, you will need to send it before making other changes to the settings, as they may overwrite some of the bits used by this setting.

◆ stateReset()

void IRSharpAc::stateReset ( void  )
private

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

◆ toCommon()

stdAc::state_t IRSharpAc::toCommon ( void  )

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

Returns
The stdAc equivalent of the native settings.

◆ toCommonFanSpeed()

stdAc::fanspeed_t IRSharpAc::toCommonFanSpeed ( const uint8_t  speed)

Convert a native fan speed into its stdAc equivalent.

Parameters
[in]speedThe native setting to be converted.
Returns
The stdAc equivalent of the native setting.

◆ toCommonMode()

stdAc::opmode_t IRSharpAc::toCommonMode ( const uint8_t  mode)

Convert a native mode into its stdAc equivalent.

Parameters
[in]modeThe native setting to be converted.
Returns
The stdAc equivalent of the native setting.

◆ toString()

String IRSharpAc::toString ( void  )

Convert the current internal state into a human readable string.

Returns
A human readable string.

◆ validChecksum()

bool IRSharpAc::validChecksum ( uint8_t  state[],
const uint16_t  length = kSharpAcStateLength 
)
static

Verify the checksum is valid for a given state.

Parameters
[in]stateThe array to verify the checksum of.
[in]lengthThe length/size of the array.
Returns
true, if the state has a valid checksum. Otherwise, false.

Member Data Documentation

◆ _fan

uint8_t IRSharpAc::_fan
private

Saved copy of the desired fan speed.

◆ _irsend

IRsend IRSharpAc::_irsend
private

Instance of the IR send class.

◆ _mode

uint8_t IRSharpAc::_mode
private

Saved copy of the desired mode.

◆ _model

sharp_ac_remote_model_t IRSharpAc::_model
private

Saved copy of the model.

◆ _temp

uint8_t IRSharpAc::_temp
private

Saved copy of the desired temp.

◆ remote

uint8_t IRSharpAc::remote[kSharpAcStateLength]
private

State of the remote in IR code form.


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