# IRremoteESP8266: src/ir_Carrier.h Source File

ir_Carrier.h
Go to the documentation of this file.
// Copyright 2020 David Conran
// Supports:
// Brand: Carrier/Surrey, Model: 42QG5A55970 remote
// Brand: Carrier/Surrey, Model: 619EGX0090E0 A/C
// Brand: Carrier/Surrey, Model: 619EGX0120E0 A/C
// Brand: Carrier/Surrey, Model: 619EGX0180E0 A/C
// Brand: Carrier/Surrey, Model: 619EGX0220E0 A/C
// Brand: Carrier/Surrey, Model: 53NGK009/012 Inverter
#ifndef IR_CARRIER_H_
#define IR_CARRIER_H_
#define __STDC_LIMIT_MACROS
#include <stdint.h>
#ifndef UNIT_TEST
#include <Arduino.h>
#endif
#include "IRremoteESP8266.h"
#include "IRsend.h"
#ifdef UNIT_TEST
#include "IRsend_test.h"
#endif
union CarrierProtocol {
uint64_t raw;
struct {
// Byte 0
uint8_t :8;
// Byte 1
uint8_t :8;
// Byte 2
uint8_t Sum:4;
uint8_t Mode:2;
uint8_t Fan:2;
// Byte 3
uint8_t Temp:4;
uint8_t :1;
uint8_t SwingV:1;
uint8_t :2;
// Byte 4
uint8_t :4;
uint8_t Power:1;
uint8_t OffTimerEnable:1;
uint8_t OnTimerEnable:1;
uint8_t Sleep:1;
// Byte 5
uint8_t :8;
// Byte 6
uint8_t :4;
uint8_t OnTimer:4;
// Byte 7
uint8_t :4;
uint8_t OffTimer:4;
};
};
// Constants
// CARRIER_AC64
const uint8_t kCarrierAc64ChecksumOffset = 16;
const uint8_t kCarrierAc64ChecksumSize = 4;
const uint8_t kCarrierAc64Heat = 0b01; // 1
const uint8_t kCarrierAc64Cool = 0b10; // 2
const uint8_t kCarrierAc64Fan = 0b11; // 3
const uint8_t kCarrierAc64FanAuto = 0b00; // 0
const uint8_t kCarrierAc64FanLow = 0b01; // 1
const uint8_t kCarrierAc64FanMedium = 0b10; // 2
const uint8_t kCarrierAc64FanHigh = 0b11; // 3
const uint8_t kCarrierAc64MinTemp = 16; // Celsius
const uint8_t kCarrierAc64MaxTemp = 30; // Celsius
const uint8_t kCarrierAc64TimerMax = 9; // Hours.
const uint8_t kCarrierAc64TimerMin = 1; // Hours.
// Classes
class IRCarrierAc64 {
public:
explicit IRCarrierAc64(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
void stateReset();
#if SEND_CARRIER_AC64
void send(const uint16_t repeat = kCarrierAc64MinRepeat);
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif // SEND_CARRIER_AC64
void begin();
static uint8_t calcChecksum(const uint64_t state);
static bool validChecksum(const uint64_t state);
void setPower(const bool on);
bool getPower(void) const;
void on(void);
void off(void);
void setTemp(const uint8_t temp);
uint8_t getTemp(void) const;
void setSwingV(const bool on);
bool getSwingV(void) const;
void setSleep(const bool on);
bool getSleep(void) const;
void setFan(const uint8_t speed);
uint8_t getFan(void) const;
void setMode(const uint8_t mode);
uint8_t getMode(void) const;
void setOnTimer(const uint16_t nr_of_mins);
uint16_t getOnTimer(void) const;
void setOffTimer(const uint16_t nr_of_mins);
uint16_t getOffTimer(void) const;
uint64_t getRaw(void);
void setRaw(const uint64_t state);
static uint8_t convertMode(const stdAc::opmode_t mode);
static uint8_t convertFan(const stdAc::fanspeed_t speed);
static stdAc::opmode_t toCommonMode(const uint8_t mode);
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
stdAc::state_t toCommon(void) const;
String toString(void) const;
#ifndef UNIT_TEST
private:
IRsend _irsend;
#else
IRsendTest _irsend;
#endif
CarrierProtocol _;
void checksum(void);
void _cancelOnTimer(void);
void _cancelOffTimer(void);
};
#endif // IR_CARRIER_H_
kCarrierAc64MinTemp
const uint8_t kCarrierAc64MinTemp
Definition: ir_Carrier.h:75
kCarrierAc64TimerMin
const uint8_t kCarrierAc64TimerMin
Definition: ir_Carrier.h:78
IRCarrierAc64::on
void on(void)
Change the power setting to On.
Definition: ir_Carrier.cpp:310
IRCarrierAc64::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Carrier.cpp:299
CarrierProtocol::Sleep
uint8_t Sleep
Definition: ir_Carrier.h:51
IRCarrierAc64::getTemp
uint8_t getTemp(void) const
Get the current temperature from the internal state.
Definition: ir_Carrier.cpp:293
IRCarrierAc64::checksum
void checksum(void)
Calculate and set the checksum values for the internal state.
Definition: ir_Carrier.cpp:257
IRCarrierAc64::toCommon
stdAc::state_t toCommon(void) const
Convert the A/C state to it's common stdAc::state_t equivalent.
Definition: ir_Carrier.cpp:513
IRCarrierAc64::IRCarrierAc64
IRCarrierAc64(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Carrier.cpp:226
CarrierProtocol::Fan
uint8_t Fan
Definition: ir_Carrier.h:40
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
CarrierProtocol::OnTimer
uint8_t OnTimer
Definition: ir_Carrier.h:56
CarrierProtocol::OffTimerEnable
uint8_t OffTimerEnable
Definition: ir_Carrier.h:49
kCarrierAc64Heat
const uint8_t kCarrierAc64Heat
Definition: ir_Carrier.h:68
IRsend.h
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:182
IRCarrierAc64::_cancelOnTimer
void _cancelOnTimer(void)
Clear the On Timer enable bit.
Definition: ir_Carrier.cpp:430
IRCarrierAc64::begin
void begin()
Set up hardware to be able to send a message.
Definition: ir_Carrier.cpp:262
kCarrierAc64Cool
const uint8_t kCarrierAc64Cool
Definition: ir_Carrier.h:69
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
IRCarrierAc64::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode to it's common stdAc::opmode_t equivalent.
Definition: ir_Carrier.cpp:349
String
std::string String
Definition: IRremoteESP8266.h:1178
IRCarrierAc64::getOffTimer
uint16_t getOffTimer(void) const
Get the current Off Timer time.
Definition: ir_Carrier.cpp:466
IRCarrierAc64::setTemp
void setTemp(const uint8_t temp)
Set the temp in deg C.
Definition: ir_Carrier.cpp:285
IRCarrierAc64::send
void send(const uint16_t repeat=kCarrierAc64MinRepeat)
Send the current internal state as an IR message.
Definition: ir_Carrier.cpp:267
IRCarrierAc64::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Carrier.cpp:375
IRCarrierAc64::setOffTimer
void setOffTimer(const uint16_t nr_of_mins)
Set the Off Timer time.
Definition: ir_Carrier.cpp:477
kCarrierAc64TimerMax
const uint8_t kCarrierAc64TimerMax
Definition: ir_Carrier.h:77
kCarrierAc64FanHigh
const uint8_t kCarrierAc64FanHigh
Definition: ir_Carrier.h:74
IRremoteESP8266.h
CarrierProtocol
Native representation of a Carrier A/C message.
Definition: ir_Carrier.h:30
IRCarrierAc64::_
CarrierProtocol _
Definition: ir_Carrier.h:136
IRCarrierAc64::validChecksum
static bool validChecksum(const uint64_t state)
Verify the checksum is valid for a given state.
Definition: ir_Carrier.cpp:250
CarrierProtocol::Mode
uint8_t Mode
Definition: ir_Carrier.h:39
kCarrierAc64FanMedium
const uint8_t kCarrierAc64FanMedium
Definition: ir_Carrier.h:73
kCarrierAc64MaxTemp
const uint8_t kCarrierAc64MaxTemp
Definition: ir_Carrier.h:76
IRCarrierAc64
Class for handling detailed Carrier 64 bit A/C messages.
Definition: ir_Carrier.h:84
IRCarrierAc64::getMode
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition: ir_Carrier.cpp:317
IRCarrierAc64::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Carrier.h:130
IRCarrierAc64::stateReset
void stateReset()
Reset the internal state to a fixed known good state.
Definition: ir_Carrier.cpp:232
IRCarrierAc64::off
void off(void)
Change the power setting to Off.
Definition: ir_Carrier.cpp:313
CarrierProtocol::OffTimer
uint8_t OffTimer
Definition: ir_Carrier.h:59
IRCarrierAc64::calcChecksum
static uint8_t calcChecksum(const uint64_t state)
Calculate the checksum for a given state.
Definition: ir_Carrier.cpp:237
IRCarrierAc64::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Carrier.h:96
CarrierProtocol::Sum
uint8_t Sum
Definition: ir_Carrier.h:38
IRCarrierAc64::setRaw
void setRaw(const uint64_t state)
Set the internal state from a valid code for this protocol.
Definition: ir_Carrier.cpp:281
CarrierProtocol::Power
uint8_t Power
Definition: ir_Carrier.h:48
IRCarrierAc64::getSwingV
bool getSwingV(void) const
Get the Vertical Swing mode of the A/C.
Definition: ir_Carrier.cpp:406
IRCarrierAc64::getPower
bool getPower(void) const
Get the value of the current power setting.
Definition: ir_Carrier.cpp:305
kCarrierAc64Fan
const uint8_t kCarrierAc64Fan
Definition: ir_Carrier.h:70
kCarrierAc64ChecksumSize
const uint8_t kCarrierAc64ChecksumSize
Definition: ir_Carrier.h:67
CarrierProtocol::SwingV
uint8_t SwingV
Definition: ir_Carrier.h:44
IRCarrierAc64::setOnTimer
void setOnTimer(const uint16_t nr_of_mins)
Set the On Timer time.
Definition: ir_Carrier.cpp:448
IRCarrierAc64::getRaw
uint64_t getRaw(void)
Get a copy of the internal state as a valid code for this protocol.
Definition: ir_Carrier.cpp:274
IRCarrierAc64::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a standard A/C mode into its native mode.
Definition: ir_Carrier.cpp:338
kCarrierAc64MinRepeat
const uint16_t kCarrierAc64MinRepeat
Definition: IRremoteESP8266.h:896
kCarrierAc64FanLow
const uint8_t kCarrierAc64FanLow
Definition: ir_Carrier.h:72
kCarrierAc64FanAuto
const uint8_t kCarrierAc64FanAuto
Definition: ir_Carrier.h:71
IRCarrierAc64::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Carrier.cpp:389
CarrierProtocol::raw
uint64_t raw
The state of the IR remote.
Definition: ir_Carrier.h:31
IRCarrierAc64::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Carrier.cpp:365
IRCarrierAc64::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Carrier.cpp:323
IRCarrierAc64::setSwingV
void setSwingV(const bool on)
Set the Vertical Swing mode of the A/C.
Definition: ir_Carrier.cpp:400
IRCarrierAc64::setSleep
void setSleep(const bool on)
Set the Sleep mode of the A/C.
Definition: ir_Carrier.cpp:412
IRCarrierAc64::_cancelOffTimer
void _cancelOffTimer(void)
Clear the Off Timer enable bit.
Definition: ir_Carrier.cpp:459
IRCarrierAc64::toString
String toString(void) const
Convert the internal state into a human readable string.
Definition: ir_Carrier.cpp:490
IRCarrierAc64::getSleep
bool getSleep(void) const
Get the Sleep mode of the A/C.
Definition: ir_Carrier.cpp:425
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
CarrierProtocol::Temp
uint8_t Temp
Definition: ir_Carrier.h:42
CarrierProtocol::OnTimerEnable
uint8_t OnTimerEnable
Definition: ir_Carrier.h:50
IRCarrierAc64::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_Carrier.cpp:359
IRCarrierAc64::getOnTimer
uint16_t getOnTimer(void) const
Get the current On Timer time.
Definition: ir_Carrier.cpp:437
kCarrierAc64ChecksumOffset
const uint8_t kCarrierAc64ChecksumOffset
Definition: ir_Carrier.h:66
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46