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

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

#include <ir_Gree.h>

Collaboration diagram for IRGreeAC:
Collaboration graph
[legend]

Public Member Functions

 IRGreeAC (const uint16_t pin, const gree_ac_remote_model_t model=gree_ac_remote_model_t::YAW1F, const bool inverted=false, const bool use_modulation=true)
 Class constructor. More...
 
void stateReset (void)
 Reset the internal state to a fixed known good state. More...
 
void send (const uint16_t repeat=kGreeDefaultRepeat)
 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 on (void)
 Change the power setting to On. More...
 
void off (void)
 Change the power setting to Off. More...
 
void setModel (const gree_ac_remote_model_t model)
 Set the model of the A/C to emulate. More...
 
gree_ac_remote_model_t getModel (void) const
 Get/Detect the model of the A/C. 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 temp, const bool fahrenheit=false)
 Set the temp. in degrees. More...
 
uint8_t getTemp (void) const
 Get the set temperature. More...
 
void setUseFahrenheit (const bool on)
 Set the default temperature units to use. More...
 
bool getUseFahrenheit (void) const
 Get the default temperature units in use. 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 setMode (const uint8_t new_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 setLight (const bool on)
 Set the Light (LED) setting of the A/C. More...
 
bool getLight (void) const
 Get the Light (LED) setting of the A/C. More...
 
void setXFan (const bool on)
 Set the XFan (Mould) setting of the A/C. More...
 
bool getXFan (void) const
 Get the XFan (Mould) setting of the A/C. More...
 
void setSleep (const bool on)
 Set the Sleep setting of the A/C. More...
 
bool getSleep (void) const
 Get the Sleep setting of the A/C. More...
 
void setTurbo (const bool on)
 Set the Turbo setting of the A/C. More...
 
bool getTurbo (void) const
 Get the Turbo setting of the A/C. More...
 
void setIFeel (const bool on)
 Set the IFeel setting of the A/C. More...
 
bool getIFeel (void) const
 Get the IFeel setting of the A/C. More...
 
void setWiFi (const bool on)
 Set the Wifi (enabled) setting of the A/C. More...
 
bool getWiFi (void) const
 Get the Wifi (enabled) setting of the A/C. More...
 
void setSwingVertical (const bool automatic, const uint8_t position)
 Set the Vertical Swing mode of the A/C. More...
 
bool getSwingVerticalAuto (void) const
 Get the Vertical Swing Automatic mode setting of the A/C. More...
 
uint8_t getSwingVerticalPosition (void) const
 Get the Vertical Swing position setting of the A/C. More...
 
uint16_t getTimer (void) const
 Get the timer time value from the A/C. More...
 
void setTimer (const uint16_t minutes)
 Set the A/C's timer to turn off in X many minutes. More...
 
void setDisplayTempSource (const uint8_t mode)
 Set temperature display mode. i.e. Internal, External temperature sensing. More...
 
uint8_t getDisplayTempSource (void) const
 Get the temperature display mode. i.e. Internal, External temperature sensing. More...
 
stdAc::state_t toCommon (void)
 Convert the current internal state into its stdAc::state_t equivalent. More...
 
uint8_t * getRaw (void)
 Get a PTR to the internal state/code for this protocol. More...
 
void setRaw (const uint8_t new_code[])
 Set the internal state from a valid code for this protocol. More...
 
String toString (void)
 Convert the current internal state into a human readable string. More...
 

Static Public Member Functions

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 uint8_t convertSwingV (const stdAc::swingv_t swingv)
 Convert a stdAc::swingv_t enum into it's native setting. 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...
 
static stdAc::swingv_t toCommonSwingV (const uint8_t pos)
 Convert a stdAc::swingv_t enum into it's native setting. More...
 
static bool validChecksum (const uint8_t state[], const uint16_t length=kGreeStateLength)
 Verify the checksum is valid for a given state. More...
 

Private Member Functions

void checksum (const uint16_t length=kGreeStateLength)
 Calculate and set the checksum values for the internal state. More...
 
void fixup (void)
 Fix up the internal state so it is correct. More...
 
void setTimerEnabled (const bool on)
 Set the timer enable setting of the A/C. More...
 
bool getTimerEnabled (void) const
 Get the timer enabled setting of the A/C. More...
 

Private Attributes

IRsend _irsend
 Instance of the IR send class. More...
 
GreeProtocol _
 
gree_ac_remote_model_t _model
 

Detailed Description

Class for handling detailed Gree A/C messages.

Constructor & Destructor Documentation

◆ IRGreeAC()

IRGreeAC::IRGreeAC ( const uint16_t  pin,
const gree_ac_remote_model_t  model = gree_ac_remote_model_t::YAW1F,
const bool  inverted = false,
const bool  use_modulation = true 
)
explicit

Class constructor.

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

Member Function Documentation

◆ begin()

void IRGreeAC::begin ( void  )

Set up hardware to be able to send a message.

◆ calibrate()

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

Calculate and set the checksum values for the internal state.

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

◆ convertFan()

uint8_t IRGreeAC::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 IRGreeAC::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 IRGreeAC::convertSwingV ( const stdAc::swingv_t  swingv)
static

Convert a stdAc::swingv_t enum into it's native setting.

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

◆ fixup()

void IRGreeAC::fixup ( void  )
private

Fix up the internal state so it is correct.

Note
Internal use only.

◆ getDisplayTempSource()

uint8_t IRGreeAC::getDisplayTempSource ( void  ) const

Get the temperature display mode. i.e. Internal, External temperature sensing.

Returns
The current temp source being displayed.

◆ getFan()

uint8_t IRGreeAC::getFan ( void  ) const

Get the current fan speed setting.

Returns
The current fan speed.

◆ getIFeel()

bool IRGreeAC::getIFeel ( void  ) const

Get the IFeel setting of the A/C.

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

◆ getLight()

bool IRGreeAC::getLight ( void  ) const

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

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

◆ getMode()

uint8_t IRGreeAC::getMode ( void  ) const

Get the operating mode setting of the A/C.

Returns
The current operating mode setting.

◆ getModel()

gree_ac_remote_model_t IRGreeAC::getModel ( void  ) const

Get/Detect the model of the A/C.

Returns
The enum of the compatible model.

◆ getPower()

bool IRGreeAC::getPower ( void  ) const

Get the value of the current power setting.

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

◆ getRaw()

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

◆ getSleep()

bool IRGreeAC::getSleep ( void  ) const

Get the Sleep setting of the A/C.

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

◆ getSwingVerticalAuto()

bool IRGreeAC::getSwingVerticalAuto ( void  ) const

Get the Vertical Swing Automatic mode setting of the A/C.

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

◆ getSwingVerticalPosition()

uint8_t IRGreeAC::getSwingVerticalPosition ( void  ) const

Get the Vertical Swing position setting of the A/C.

Returns
The native position/mode.

◆ getTemp()

uint8_t IRGreeAC::getTemp ( void  ) const

Get the set temperature.

Returns
The temperature in degrees in the current units (C/F) set.

◆ getTimer()

uint16_t IRGreeAC::getTimer ( void  ) const

Get the timer time value from the A/C.

Returns
The number of minutes the timer is set for.

◆ getTimerEnabled()

bool IRGreeAC::getTimerEnabled ( void  ) const
private

Get the timer enabled setting of the A/C.

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

◆ getTurbo()

bool IRGreeAC::getTurbo ( void  ) const

Get the Turbo setting of the A/C.

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

◆ getUseFahrenheit()

bool IRGreeAC::getUseFahrenheit ( void  ) const

Get the default temperature units in use.

Returns
true is Fahrenheit, false is Celsius.

◆ getWiFi()

bool IRGreeAC::getWiFi ( void  ) const

Get the Wifi (enabled) setting of the A/C.

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

◆ getXFan()

bool IRGreeAC::getXFan ( void  ) const

Get the XFan (Mould) setting of the A/C.

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

◆ off()

void IRGreeAC::off ( void  )

Change the power setting to Off.

◆ on()

void IRGreeAC::on ( void  )

Change the power setting to On.

◆ send()

void IRGreeAC::send ( const uint16_t  repeat = kGreeDefaultRepeat)

Send the current internal state as an IR message.

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

◆ setDisplayTempSource()

void IRGreeAC::setDisplayTempSource ( const uint8_t  mode)

Set temperature display mode. i.e. Internal, External temperature sensing.

Parameters
[in]modeThe desired temp source to display.
Note
In order for the A/C unit properly accept these settings. You must cycle (send) in the following order: kGreeDisplayTempOff(0) -> kGreeDisplayTempSet(1) -> kGreeDisplayTempInside(2) ->kGreeDisplayTempOutside(3) -> kGreeDisplayTempOff(0). The unit will no behave correctly if the changes of this setting are sent out of order.
See also
https://github.com/crankyoldgit/IRremoteESP8266/issues/1118#issuecomment-628242152

◆ setFan()

void IRGreeAC::setFan ( const uint8_t  speed)

Set the speed of the fan.

Parameters
[in]speedThe desired setting. 0 is auto, 1-3 is the speed.

◆ setIFeel()

void IRGreeAC::setIFeel ( const bool  on)

Set the IFeel setting of the A/C.

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

◆ setLight()

void IRGreeAC::setLight ( const bool  on)

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

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

◆ setMode()

void IRGreeAC::setMode ( const uint8_t  new_mode)

Set the operating mode of the A/C.

Parameters
[in]new_modeThe desired operating mode.

◆ setModel()

void IRGreeAC::setModel ( const gree_ac_remote_model_t  model)

Set the model of the A/C to emulate.

Parameters
[in]modelThe enum of the appropriate model.

◆ setPower()

void IRGreeAC::setPower ( const bool  on)

Change the power setting.

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

◆ setRaw()

void IRGreeAC::setRaw ( const uint8_t  new_code[])

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

Parameters
[in]new_codeA valid code for this protocol.

◆ setSleep()

void IRGreeAC::setSleep ( const bool  on)

Set the Sleep setting of the A/C.

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

◆ setSwingVertical()

void IRGreeAC::setSwingVertical ( const bool  automatic,
const uint8_t  position 
)

Set the Vertical Swing mode of the A/C.

Parameters
[in]automaticDo we use the automatic setting?
[in]positionThe position/mode to set the vanes to.

◆ setTemp()

void IRGreeAC::setTemp ( const uint8_t  temp,
const bool  fahrenheit = false 
)

Set the temp. in degrees.

Parameters
[in]tempDesired temperature in Degrees.
[in]fahrenheitUse units of Fahrenheit and set that as units used. false is Celsius (Default), true is Fahrenheit.
Note
The unit actually works in Celsius with a special optional "extra degree" when sending Fahrenheit.

◆ setTimer()

void IRGreeAC::setTimer ( const uint16_t  minutes)

Set the A/C's timer to turn off in X many minutes.

Parameters
[in]minutesThe number of minutes the timer should be set for.
Note
Stores time internally in 30 min units. e.g. 5 mins means 0 (& Off), 95 mins is 90 mins (& On). Max is 24 hours.

◆ setTimerEnabled()

void IRGreeAC::setTimerEnabled ( const bool  on)
private

Set the timer enable setting of the A/C.

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

◆ setTurbo()

void IRGreeAC::setTurbo ( const bool  on)

Set the Turbo setting of the A/C.

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

◆ setUseFahrenheit()

void IRGreeAC::setUseFahrenheit ( const bool  on)

Set the default temperature units to use.

Parameters
[in]onUse Fahrenheit as the units. true is Fahrenheit, false is Celsius.

◆ setWiFi()

void IRGreeAC::setWiFi ( const bool  on)

Set the Wifi (enabled) setting of the A/C.

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

◆ setXFan()

void IRGreeAC::setXFan ( const bool  on)

Set the XFan (Mould) setting of the A/C.

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

◆ stateReset()

void IRGreeAC::stateReset ( void  )

Reset the internal state to a fixed known good state.

◆ toCommon()

stdAc::state_t IRGreeAC::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 IRGreeAC::toCommonFanSpeed ( const uint8_t  speed)
static

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 IRGreeAC::toCommonMode ( const uint8_t  mode)
static

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 IRGreeAC::toCommonSwingV ( const uint8_t  pos)
static

Convert a stdAc::swingv_t enum into it's native setting.

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

◆ toString()

String IRGreeAC::toString ( void  )

Convert the current internal state into a human readable string.

Returns
A human readable string.

◆ validChecksum()

bool IRGreeAC::validChecksum ( const uint8_t  state[],
const uint16_t  length = kGreeStateLength 
)
static

Verify the checksum is valid for a given state.

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

Member Data Documentation

◆ _

GreeProtocol IRGreeAC::_
private

◆ _irsend

IRsend IRGreeAC::_irsend
private

Instance of the IR send class.

◆ _model

gree_ac_remote_model_t IRGreeAC::_model
private

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