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

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

#include <ir_Samsung.h>

Collaboration diagram for IRSamsungAc:
Collaboration graph
[legend]

Public Member Functions

 IRSamsungAc (const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
 Class constructor. More...
 
void stateReset (const bool forcepower=true, const bool initialPower=true)
 Reset the internal state of the emulation. More...
 
void send (const uint16_t repeat=kSamsungAcDefaultRepeat, const bool calcchecksum=true)
 Send the current internal state as an IR message. More...
 
void sendExtended (const uint16_t repeat=kSamsungAcDefaultRepeat, const bool calcchecksum=true)
 Send the extended current internal state as an IR message. More...
 
void sendOn (const uint16_t repeat=kSamsungAcDefaultRepeat)
 Send the special extended "On" message as the library can't seem to reproduce this message automatically. More...
 
void sendOff (const uint16_t repeat=kSamsungAcDefaultRepeat)
 Send the special extended "Off" message as the library can't seem to reproduce this message automatically. 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)
 Get the value of the current power setting. More...
 
void setTemp (const uint8_t temp)
 Set the temperature. More...
 
uint8_t getTemp (void)
 Get the current temperature setting. More...
 
void setFan (const uint8_t speed)
 Set the speed of the fan. More...
 
uint8_t getFan (void)
 Get the current fan speed setting. More...
 
void setMode (const uint8_t mode)
 Set the operating mode of the A/C. More...
 
uint8_t getMode (void)
 Get the operating mode setting of the A/C. More...
 
void setSwing (const bool on)
 Set the vertical swing setting of the A/C. More...
 
bool getSwing (void)
 Get the vertical swing setting of the A/C. More...
 
void setBeep (const bool on)
 Set the Beep setting of the A/C. More...
 
bool getBeep (void)
 Get the Beep setting of the A/C. More...
 
void setClean (const bool on)
 Set the Clean setting of the A/C. More...
 
bool getClean (void)
 Get the Clean setting of the A/C. More...
 
void setQuiet (const bool on)
 Set the Quiet setting of the A/C. More...
 
bool getQuiet (void)
 Get the Quiet setting of the A/C. More...
 
void setPowerful (const bool on)
 Set the Powerful (Turbo) setting of the A/C. More...
 
bool getPowerful (void)
 Get the Powerful (Turbo) setting of the A/C. More...
 
void setBreeze (const bool on)
 Closes the vanes over the fan outlet, to stop direct wind. Aka. WindFree. More...
 
bool getBreeze (void)
 Are the vanes closed over the fan outlet, to stop direct wind? Aka. WindFree. More...
 
void setDisplay (const bool on)
 Set the Display (Light/LED) setting of the A/C. More...
 
bool getDisplay (void)
 Get the Display (Light/LED) setting of the A/C. More...
 
void setIon (const bool on)
 Set the Ion (Filter) setting of the A/C. More...
 
bool getIon (void)
 Get the Ion (Filter) 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=kSamsungAcStateLength)
 Set the internal state from a valid code for this protocol. More...
 
uint8_t convertMode (const stdAc::opmode_t mode)
 Convert a stdAc::opmode_t enum into its native mode. More...
 
uint8_t convertFan (const stdAc::fanspeed_t speed)
 Convert a stdAc::fanspeed_t enum into it's native speed. More...
 
stdAc::state_t toCommon (void)
 Convert the current internal state into its stdAc::state_t equivilant. More...
 
String toString (void)
 Convert the current internal state into a human readable string. More...
 

Static Public Member Functions

static bool validChecksum (const uint8_t state[], const uint16_t length=kSamsungAcStateLength)
 Verify the checksum is valid for a given state. More...
 
static uint8_t calcChecksum (const uint8_t state[], const uint16_t length=kSamsungAcStateLength)
 Calculate the checksum for a given state. More...
 
static stdAc::opmode_t toCommonMode (const uint8_t mode)
 Convert a native mode into its stdAc equivilant. More...
 
static stdAc::fanspeed_t toCommonFanSpeed (const uint8_t speed)
 Convert a native fan speed into its stdAc equivilant. More...
 

Private Member Functions

void checksum (const uint16_t length=kSamsungAcStateLength)
 Update the checksum for the internal state. More...
 

Private Attributes

IRsend _irsend
 Instance of the IR send class. More...
 
uint8_t remote_state [kSamsungAcExtendedStateLength]
 State in code form. More...
 
bool _forcepower
 Hack to know when we need to send a special power mesg. More...
 
bool _lastsentpowerstate
 

Detailed Description

Class for handling detailed Samsung A/C messages.

Constructor & Destructor Documentation

◆ IRSamsungAc()

IRSamsungAc::IRSamsungAc ( 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

◆ begin()

void IRSamsungAc::begin ( void  )

Set up hardware to be able to send a message.

◆ calcChecksum()

uint8_t IRSamsungAc::calcChecksum ( const uint8_t  state[],
const uint16_t  length = kSamsungAcStateLength 
)
static

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 checksum value.

◆ calibrate()

int8_t IRSamsungAc::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 IRSamsungAc::checksum ( const uint16_t  length = kSamsungAcStateLength)
private

Update the checksum for the internal state.

Parameters
[in]lengthThe length/size of the internal array to checksum.

◆ convertFan()

uint8_t IRSamsungAc::convertFan ( const stdAc::fanspeed_t  speed)

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

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

◆ convertMode()

uint8_t IRSamsungAc::convertMode ( const stdAc::opmode_t  mode)

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

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

◆ getBeep()

bool IRSamsungAc::getBeep ( void  )

Get the Beep setting of the A/C.

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

◆ getBreeze()

bool IRSamsungAc::getBreeze ( void  )

Are the vanes closed over the fan outlet, to stop direct wind? Aka. WindFree.

Returns
true, the setting is on. false, the setting is off.
See also
https://github.com/crankyoldgit/IRremoteESP8266/issues/1062

◆ getClean()

bool IRSamsungAc::getClean ( void  )

Get the Clean setting of the A/C.

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

◆ getDisplay()

bool IRSamsungAc::getDisplay ( void  )

Get the Display (Light/LED) setting of the A/C.

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

◆ getFan()

uint8_t IRSamsungAc::getFan ( void  )

Get the current fan speed setting.

Returns
The current fan speed/mode.

◆ getIon()

bool IRSamsungAc::getIon ( void  )

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

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

◆ getMode()

uint8_t IRSamsungAc::getMode ( void  )

Get the operating mode setting of the A/C.

Returns
The current operating mode setting.

◆ getPower()

bool IRSamsungAc::getPower ( void  )

Get the value of the current power setting.

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

◆ getPowerful()

bool IRSamsungAc::getPowerful ( void  )

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

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

◆ getQuiet()

bool IRSamsungAc::getQuiet ( void  )

Get the Quiet setting of the A/C.

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

◆ getRaw()

uint8_t * IRSamsungAc::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.

◆ getSwing()

bool IRSamsungAc::getSwing ( void  )

Get the vertical swing setting of the A/C.

Returns
true, the setting is on. false, the setting is off.
Todo:
(Hollako) Explain why sometimes the LSB of remote_state[9] is a 1. e.g. 0xAE or 0XAF for swing move.

◆ getTemp()

uint8_t IRSamsungAc::getTemp ( void  )

Get the current temperature setting.

Returns
The current setting for temp. in degrees celsius.

◆ off()

void IRSamsungAc::off ( void  )

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

◆ on()

void IRSamsungAc::on ( void  )

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

◆ send()

void IRSamsungAc::send ( const uint16_t  repeat = kSamsungAcDefaultRepeat,
const bool  calcchecksum = true 
)

Send the current internal state as an IR message.

Parameters
[in]repeatNr. of times the message will be repeated.
[in]calcchecksumDo we update the checksum before sending?
Note
Use for most function/mode/settings changes to the unit. i.e. When the device is already running.

◆ sendExtended()

void IRSamsungAc::sendExtended ( const uint16_t  repeat = kSamsungAcDefaultRepeat,
const bool  calcchecksum = true 
)

Send the extended current internal state as an IR message.

Parameters
[in]repeatNr. of times the message will be repeated.
[in]calcchecksumDo we update the checksum before sending?
Note
Use this for when you need to power on/off the device. Samsung A/C requires an extended length message when you want to change the power operating mode of the A/C unit.

◆ sendOff()

void IRSamsungAc::sendOff ( const uint16_t  repeat = kSamsungAcDefaultRepeat)

Send the special extended "Off" message as the library can't seem to reproduce this message automatically.

Parameters
[in]repeatNr. of times the message will be repeated.
See also
https://github.com/crankyoldgit/IRremoteESP8266/issues/604#issuecomment-475020036

◆ sendOn()

void IRSamsungAc::sendOn ( const uint16_t  repeat = kSamsungAcDefaultRepeat)

Send the special extended "On" message as the library can't seem to reproduce this message automatically.

Parameters
[in]repeatNr. of times the message will be repeated.
See also
https://github.com/crankyoldgit/IRremoteESP8266/issues/604#issuecomment-475020036

◆ setBeep()

void IRSamsungAc::setBeep ( const bool  on)

Set the Beep setting of the A/C.

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

◆ setBreeze()

void IRSamsungAc::setBreeze ( const bool  on)

Closes the vanes over the fan outlet, to stop direct wind. Aka. WindFree.

Parameters
[in]ontrue, the setting is on. false, the setting is off.
See also
https://github.com/crankyoldgit/IRremoteESP8266/issues/1062

◆ setClean()

void IRSamsungAc::setClean ( const bool  on)

Set the Clean setting of the A/C.

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

◆ setDisplay()

void IRSamsungAc::setDisplay ( const bool  on)

Set the Display (Light/LED) setting of the A/C.

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

◆ setFan()

void IRSamsungAc::setFan ( const uint8_t  speed)

Set the speed of the fan.

Parameters
[in]speedThe desired setting.

◆ setIon()

void IRSamsungAc::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.

◆ setMode()

void IRSamsungAc::setMode ( const uint8_t  mode)

Set the operating mode of the A/C.

Parameters
[in]modeThe desired operating mode.

◆ setPower()

void IRSamsungAc::setPower ( const bool  on)

Change the power setting.

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

◆ setPowerful()

void IRSamsungAc::setPowerful ( const bool  on)

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

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

◆ setQuiet()

void IRSamsungAc::setQuiet ( const bool  on)

Set the Quiet setting of the A/C.

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

◆ setRaw()

void IRSamsungAc::setRaw ( const uint8_t  new_code[],
const uint16_t  length = kSamsungAcStateLength 
)

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.

◆ setSwing()

void IRSamsungAc::setSwing ( const bool  on)

Set the vertical swing setting of the A/C.

Parameters
[in]ontrue, the setting is on. false, the setting is off.
Todo:
(Hollako) Explain why sometimes the LSB of remote_state[9] is a 1. e.g. 0xAE or 0XAF for swing move.

◆ setTemp()

void IRSamsungAc::setTemp ( const uint8_t  temp)

Set the temperature.

Parameters
[in]tempThe temperature in degrees celsius.

◆ stateReset()

void IRSamsungAc::stateReset ( const bool  forcepower = true,
const bool  initialPower = true 
)

Reset the internal state of the emulation.

Parameters
[in]forcepowerA flag indicating if force sending a special power message with the first send() call.
[in]initialPowerSet the initial power state. True, on. False, off.

◆ toCommon()

stdAc::state_t IRSamsungAc::toCommon ( void  )

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

Returns
The stdAc equivilant of the native settings.

◆ toCommonFanSpeed()

stdAc::fanspeed_t IRSamsungAc::toCommonFanSpeed ( const uint8_t  spd)
static

Convert a native fan speed into its stdAc equivilant.

Parameters
[in]spdThe native setting to be converted.
Returns
The stdAc equivilant of the native setting.

◆ toCommonMode()

stdAc::opmode_t IRSamsungAc::toCommonMode ( const uint8_t  mode)
static

Convert a native mode into its stdAc equivilant.

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

◆ toString()

String IRSamsungAc::toString ( void  )

Convert the current internal state into a human readable string.

Returns
A human readable string.

◆ validChecksum()

bool IRSamsungAc::validChecksum ( const uint8_t  state[],
const uint16_t  length = kSamsungAcStateLength 
)
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

◆ _forcepower

bool IRSamsungAc::_forcepower
private

Hack to know when we need to send a special power mesg.

◆ _irsend

IRsend IRSamsungAc::_irsend
private

Instance of the IR send class.

◆ _lastsentpowerstate

bool IRSamsungAc::_lastsentpowerstate
private

◆ remote_state

uint8_t IRSamsungAc::remote_state[kSamsungAcExtendedStateLength]
private

State in code form.


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