IRremoteESP8266
ir_Carrier.h
Go to the documentation of this file.
1 // Copyright 2020-2022 David Conran
8 
9 // Supports:
10 // Brand: Carrier/Surrey, Model: 42QG5A55970 remote
11 // Brand: Carrier/Surrey, Model: 619EGX0090E0 A/C
12 // Brand: Carrier/Surrey, Model: 619EGX0120E0 A/C
13 // Brand: Carrier/Surrey, Model: 619EGX0180E0 A/C
14 // Brand: Carrier/Surrey, Model: 619EGX0220E0 A/C
15 // Brand: Carrier/Surrey, Model: 53NGK009/012 Inverter
16 // Brand: Carrier, Model: 40GKX0E2006 remote (CARRIER_AC128)
17 // Brand: Carrier, Model: 3021203 RR03-S-Remote (CARRIER_AC84)
18 // Brand: Carrier, Model: 342WM100CT A/C (CARRIER_AC84)
19 
20 #ifndef IR_CARRIER_H_
21 #define IR_CARRIER_H_
22 
23 #define __STDC_LIMIT_MACROS
24 #include <stdint.h>
25 #ifndef UNIT_TEST
26 #include <Arduino.h>
27 #endif
28 #include "IRremoteESP8266.h"
29 #include "IRsend.h"
30 #ifdef UNIT_TEST
31 #include "IRsend_test.h"
32 #endif
33 
36  uint64_t raw;
37  struct {
38  // Byte 0
39  uint8_t :8;
40  // Byte 1
41  uint8_t :8;
42  // Byte 2
43  uint8_t Sum:4;
44  uint8_t Mode:2;
45  uint8_t Fan:2;
46  // Byte 3
47  uint8_t Temp:4;
48  uint8_t :1;
49  uint8_t SwingV:1;
50  uint8_t :2;
51  // Byte 4
52  uint8_t :4;
53  uint8_t Power:1;
54  uint8_t OffTimerEnable:1;
55  uint8_t OnTimerEnable:1;
56  uint8_t Sleep:1;
57  // Byte 5
58  uint8_t :8;
59  // Byte 6
60  uint8_t :4;
61  uint8_t OnTimer:4;
62  // Byte 7
63  uint8_t :4;
64  uint8_t OffTimer:4;
65  };
66 };
67 
68 // Constants
69 
70 // CARRIER_AC64
71 const uint8_t kCarrierAc64ChecksumOffset = 16;
72 const uint8_t kCarrierAc64ChecksumSize = 4;
73 const uint8_t kCarrierAc64Heat = 0b01; // 1
74 const uint8_t kCarrierAc64Cool = 0b10; // 2
75 const uint8_t kCarrierAc64Fan = 0b11; // 3
76 const uint8_t kCarrierAc64FanAuto = 0b00; // 0
77 const uint8_t kCarrierAc64FanLow = 0b01; // 1
78 const uint8_t kCarrierAc64FanMedium = 0b10; // 2
79 const uint8_t kCarrierAc64FanHigh = 0b11; // 3
80 const uint8_t kCarrierAc64MinTemp = 16; // Celsius
81 const uint8_t kCarrierAc64MaxTemp = 30; // Celsius
82 const uint8_t kCarrierAc64TimerMax = 9; // Hours.
83 const uint8_t kCarrierAc64TimerMin = 1; // Hours.
84 
85 
86 // Classes
87 
90  public:
91  explicit IRCarrierAc64(const uint16_t pin, const bool inverted = false,
92  const bool use_modulation = true);
93 
94  void stateReset();
95 #if SEND_CARRIER_AC64
96  void send(const uint16_t repeat = kCarrierAc64MinRepeat);
101  int8_t calibrate(void) { return _irsend.calibrate(); }
102 #endif // SEND_CARRIER_AC64
103  void begin();
104  static uint8_t calcChecksum(const uint64_t state);
105  static bool validChecksum(const uint64_t state);
106  void setPower(const bool on);
107  bool getPower(void) const;
108  void on(void);
109  void off(void);
110  void setTemp(const uint8_t temp);
111  uint8_t getTemp(void) const;
112  void setSwingV(const bool on);
113  bool getSwingV(void) const;
114  void setSleep(const bool on);
115  bool getSleep(void) const;
116  void setFan(const uint8_t speed);
117  uint8_t getFan(void) const;
118  void setMode(const uint8_t mode);
119  uint8_t getMode(void) const;
120  void setOnTimer(const uint16_t nr_of_mins);
121  uint16_t getOnTimer(void) const;
122  void setOffTimer(const uint16_t nr_of_mins);
123  uint16_t getOffTimer(void) const;
124  uint64_t getRaw(void);
125  void setRaw(const uint64_t state);
126  static uint8_t convertMode(const stdAc::opmode_t mode);
127  static uint8_t convertFan(const stdAc::fanspeed_t speed);
128  static stdAc::opmode_t toCommonMode(const uint8_t mode);
129  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
130  stdAc::state_t toCommon(void) const;
131  String toString(void) const;
132 #ifndef UNIT_TEST
133 
134  private:
136 #else
137  IRsendTest _irsend;
139 #endif
142  void checksum(void);
143  void _cancelOnTimer(void);
144  void _cancelOffTimer(void);
145 };
146 #endif // IR_CARRIER_H_
kCarrierAc64MinTemp
const uint8_t kCarrierAc64MinTemp
Definition: ir_Carrier.h:80
kCarrierAc64TimerMin
const uint8_t kCarrierAc64TimerMin
Definition: ir_Carrier.h:83
IRCarrierAc64::on
void on(void)
Change the power setting to On.
Definition: ir_Carrier.cpp:330
IRCarrierAc64::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Carrier.cpp:319
CarrierProtocol::Sleep
uint8_t Sleep
Definition: ir_Carrier.h:56
IRCarrierAc64::getTemp
uint8_t getTemp(void) const
Get the current temperature from the internal state.
Definition: ir_Carrier.cpp:313
IRCarrierAc64::checksum
void checksum(void)
Calculate and set the checksum values for the internal state.
Definition: ir_Carrier.cpp:277
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:533
IRCarrierAc64::IRCarrierAc64
IRCarrierAc64(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Carrier.cpp:246
CarrierProtocol::Fan
uint8_t Fan
Definition: ir_Carrier.h:45
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:61
CarrierProtocol::OnTimer
uint8_t OnTimer
Definition: ir_Carrier.h:61
CarrierProtocol::OffTimerEnable
uint8_t OffTimerEnable
Definition: ir_Carrier.h:54
kCarrierAc64Heat
const uint8_t kCarrierAc64Heat
Definition: ir_Carrier.h:73
IRsend.h
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:237
IRCarrierAc64::_cancelOnTimer
void _cancelOnTimer(void)
Clear the On Timer enable bit.
Definition: ir_Carrier.cpp:450
IRCarrierAc64::begin
void begin()
Set up hardware to be able to send a message.
Definition: ir_Carrier.cpp:282
kCarrierAc64Cool
const uint8_t kCarrierAc64Cool
Definition: ir_Carrier.h:74
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:369
String
std::string String
Definition: IRremoteESP8266.h:1521
IRCarrierAc64::getOffTimer
uint16_t getOffTimer(void) const
Get the current Off Timer time.
Definition: ir_Carrier.cpp:486
IRCarrierAc64::setTemp
void setTemp(const uint8_t temp)
Set the temp in deg C.
Definition: ir_Carrier.cpp:305
IRCarrierAc64::send
void send(const uint16_t repeat=kCarrierAc64MinRepeat)
Send the current internal state as an IR message.
Definition: ir_Carrier.cpp:287
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:395
IRCarrierAc64::setOffTimer
void setOffTimer(const uint16_t nr_of_mins)
Set the Off Timer time.
Definition: ir_Carrier.cpp:497
kCarrierAc64TimerMax
const uint8_t kCarrierAc64TimerMax
Definition: ir_Carrier.h:82
kCarrierAc64FanHigh
const uint8_t kCarrierAc64FanHigh
Definition: ir_Carrier.h:79
IRremoteESP8266.h
CarrierProtocol
Native representation of a Carrier A/C message.
Definition: ir_Carrier.h:35
IRCarrierAc64::_
CarrierProtocol _
Definition: ir_Carrier.h:141
IRCarrierAc64::validChecksum
static bool validChecksum(const uint64_t state)
Verify the checksum is valid for a given state.
Definition: ir_Carrier.cpp:270
CarrierProtocol::Mode
uint8_t Mode
Definition: ir_Carrier.h:44
kCarrierAc64FanMedium
const uint8_t kCarrierAc64FanMedium
Definition: ir_Carrier.h:78
kCarrierAc64MaxTemp
const uint8_t kCarrierAc64MaxTemp
Definition: ir_Carrier.h:81
IRCarrierAc64
Class for handling detailed Carrier 64 bit A/C messages.
Definition: ir_Carrier.h:89
IRCarrierAc64::getMode
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition: ir_Carrier.cpp:337
IRCarrierAc64::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Carrier.h:135
IRCarrierAc64::stateReset
void stateReset()
Reset the internal state to a fixed known good state.
Definition: ir_Carrier.cpp:252
IRCarrierAc64::off
void off(void)
Change the power setting to Off.
Definition: ir_Carrier.cpp:333
CarrierProtocol::OffTimer
uint8_t OffTimer
Definition: ir_Carrier.h:64
IRCarrierAc64::calcChecksum
static uint8_t calcChecksum(const uint64_t state)
Calculate the checksum for a given state.
Definition: ir_Carrier.cpp:257
IRCarrierAc64::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Carrier.h:101
CarrierProtocol::Sum
uint8_t Sum
Definition: ir_Carrier.h:43
IRCarrierAc64::setRaw
void setRaw(const uint64_t state)
Set the internal state from a valid code for this protocol.
Definition: ir_Carrier.cpp:301
CarrierProtocol::Power
uint8_t Power
Definition: ir_Carrier.h:53
IRCarrierAc64::getSwingV
bool getSwingV(void) const
Get the Vertical Swing mode of the A/C.
Definition: ir_Carrier.cpp:426
IRCarrierAc64::getPower
bool getPower(void) const
Get the value of the current power setting.
Definition: ir_Carrier.cpp:325
kCarrierAc64Fan
const uint8_t kCarrierAc64Fan
Definition: ir_Carrier.h:75
kCarrierAc64ChecksumSize
const uint8_t kCarrierAc64ChecksumSize
Definition: ir_Carrier.h:72
CarrierProtocol::SwingV
uint8_t SwingV
Definition: ir_Carrier.h:49
IRCarrierAc64::setOnTimer
void setOnTimer(const uint16_t nr_of_mins)
Set the On Timer time.
Definition: ir_Carrier.cpp:468
IRCarrierAc64::getRaw
uint64_t getRaw(void)
Get a copy of the internal state as a valid code for this protocol.
Definition: ir_Carrier.cpp:294
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:358
kCarrierAc64MinRepeat
const uint16_t kCarrierAc64MinRepeat
Definition: IRremoteESP8266.h:1178
kCarrierAc64FanLow
const uint8_t kCarrierAc64FanLow
Definition: ir_Carrier.h:77
kCarrierAc64FanAuto
const uint8_t kCarrierAc64FanAuto
Definition: ir_Carrier.h:76
IRCarrierAc64::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Carrier.cpp:409
CarrierProtocol::raw
uint64_t raw
The state of the IR remote.
Definition: ir_Carrier.h:36
IRCarrierAc64::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Carrier.cpp:385
IRCarrierAc64::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Carrier.cpp:343
IRCarrierAc64::setSwingV
void setSwingV(const bool on)
Set the Vertical Swing mode of the A/C.
Definition: ir_Carrier.cpp:420
IRCarrierAc64::setSleep
void setSleep(const bool on)
Set the Sleep mode of the A/C.
Definition: ir_Carrier.cpp:432
IRCarrierAc64::_cancelOffTimer
void _cancelOffTimer(void)
Clear the Off Timer enable bit.
Definition: ir_Carrier.cpp:479
IRCarrierAc64::toString
String toString(void) const
Convert the internal state into a human readable string.
Definition: ir_Carrier.cpp:510
IRCarrierAc64::getSleep
bool getSleep(void) const
Get the Sleep mode of the A/C.
Definition: ir_Carrier.cpp:445
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:114
CarrierProtocol::Temp
uint8_t Temp
Definition: ir_Carrier.h:47
CarrierProtocol::OnTimerEnable
uint8_t OnTimerEnable
Definition: ir_Carrier.h:55
IRCarrierAc64::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_Carrier.cpp:379
IRCarrierAc64::getOnTimer
uint16_t getOnTimer(void) const
Get the current On Timer time.
Definition: ir_Carrier.cpp:457
kCarrierAc64ChecksumOffset
const uint8_t kCarrierAc64ChecksumOffset
Definition: ir_Carrier.h:71
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:49