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) const
 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) const
 Get the value of the current power setting. More...
 
bool isPowerSpecial (void) const
 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) const
 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) const
 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) const
 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) const
 Get the value of the Special (button/command?) setting. More...
 
bool getTurbo (void) const
 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) const
 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...
 
uint8_t getSwingV (void) const
 Get the Vertical Swing setting of the A/C. More...
 
void setSwingV (const uint8_t position, const bool force=false)
 Set the Vertical Swing setting of the A/C. More...
 
bool getIon (void) const
 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) const
 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) const
 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) const
 Get how long the timer is set for, in minutes. More...
 
bool getTimerEnabled (void) const
 Is the Timer enabled? More...
 
bool getTimerType (void) const
 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) const
 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) const
 Convert a native mode into its stdAc equivalent. More...
 
stdAc::fanspeed_t toCommonFanSpeed (const uint8_t speed) const
 Convert a native fan speed into its stdAc equivalent. More...
 
stdAc::swingv_t toCommonSwingV (const uint8_t pos, const stdAc::opmode_t mode=stdAc::opmode_t::kHeat) const
 Convert a native vertical swing postion to it's common equivalent. 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 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, const sharp_ac_remote_model_t model=sharp_ac_remote_model_t::A907)
 Convert a stdAc::fanspeed_t enum into it's native speed. More...
 
static uint8_t convertSwingV (const stdAc::swingv_t position)
 Convert a standard A/C vertical swing into its native setting. 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) const
 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) const
 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...
 
SharpProtocol _
 
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  ) const
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,
const sharp_ac_remote_model_t  model = sharp_ac_remote_model_t::A907 
)
static

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

Parameters
[in]speedThe enum to be converted.
[in]modelThe enum of the appropriate model.
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.

◆ convertSwingV()

uint8_t IRSharpAc::convertSwingV ( const stdAc::swingv_t  position)
static

Convert a standard A/C vertical swing into its native setting.

Parameters
[in]positionA stdAc::swingv_t position to convert.
Returns
The equivalent native horizontal swing position.

◆ getClean()

bool IRSharpAc::getClean ( void  ) const

Get the Clean setting of the A/C.

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

◆ getEconoToggle()

bool IRSharpAc::getEconoToggle ( void  ) const

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

Returns
true, the setting is on. false, the setting is off.
Note
Available on the A907 models.

◆ getFan()

uint8_t IRSharpAc::getFan ( void  ) const

Get the current fan speed setting.

Returns
The current fan speed/mode.

◆ getIon()

bool IRSharpAc::getIon ( void  ) const

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  ) const

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  ) const

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) const

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  ) const

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  ) const
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  ) const

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

Returns
The setting's value.

◆ getSwingToggle()

bool IRSharpAc::getSwingToggle ( void  ) const

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

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

◆ getSwingV()

uint8_t IRSharpAc::getSwingV ( void  ) const

Get the Vertical Swing setting of the A/C.

Returns
The position of the Vertical Swing setting.

◆ getTemp()

uint8_t IRSharpAc::getTemp ( void  ) const

Get the current temperature setting.

Returns
The current setting for temp. in degrees celsius.

◆ getTimerEnabled()

bool IRSharpAc::getTimerEnabled ( void  ) const

Is the Timer enabled?

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

◆ getTimerTime()

uint16_t IRSharpAc::getTimerTime ( void  ) const

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

Returns
The time in nr of minutes.

◆ getTimerType()

bool IRSharpAc::getTimerType ( void  ) const

Get the current timer type.

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

◆ getTurbo()

bool IRSharpAc::getTurbo ( void  ) const

Get the Turbo setting of the A/C.

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

◆ isPowerSpecial()

bool IRSharpAc::isPowerSpecial ( void  ) const

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
Available on the A907 models.

◆ 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)
inlineprivate

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.

◆ setSwingV()

void IRSharpAc::setSwingV ( const uint8_t  position,
const bool  force = false 
)

Set the Vertical Swing setting of the A/C.

Note
Some positions may not work on all models.
Parameters
[in]positionThe desired position/setting.
Note
setSwingV(kSharpAcSwingVLowest) will only allow the Lowest setting in Heat mode, it will default to kSharpAcSwingVLow otherwise. If you want to set this value in other modes e.g. Cool, you must use setSwingVs optional force parameter.
Parameters
[in]forceDo we override the safety checks and just do it?

◆ 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 ( const stdAc::state_t prev = NULL) const

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

Parameters
[in]prevPtr to the previous state if required.
Returns
The stdAc equivalent of the native settings.

◆ toCommonFanSpeed()

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

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) const

Convert a native mode into its stdAc equivalent.

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

◆ toCommonSwingV()

stdAc::swingv_t IRSharpAc::toCommonSwingV ( const uint8_t  pos,
const stdAc::opmode_t  mode = stdAc::opmode_t::kHeat 
) const

Convert a native vertical swing postion to it's common equivalent.

Parameters
[in]posA native position to convert.
[in]modeWhat operating mode are we in?
Returns
The common vertical swing position.

◆ toString()

String IRSharpAc::toString ( void  ) const

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

◆ _

SharpProtocol IRSharpAc::_
private

◆ _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.


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