IRremoteESP8266
ir_Amcor.h
Go to the documentation of this file.
1 // Copyright 2019 David Conran
2 
7 // Supports:
8 // Brand: Amcor, Model: ADR-853H A/C
9 // Brand: Amcor, Model: TAC-495 remote
10 // Brand: Amcor, Model: TAC-444 remote
11 
12 #ifndef IR_AMCOR_H_
13 #define IR_AMCOR_H_
14 
15 #define __STDC_LIMIT_MACROS
16 #include <stdint.h>
17 #ifndef UNIT_TEST
18 #include <Arduino.h>
19 #endif
20 #include "IRremoteESP8266.h"
21 #include "IRsend.h"
22 #ifdef UNIT_TEST
23 #include "IRsend_test.h"
24 #endif
25 
26 
28  uint8_t raw[kAmcorStateLength]; // The state of the IR remote.
29  struct {
30  // Byte 0
31  uint8_t :8; // Typically 0x01
32  // Byte 1
33  uint8_t Mode :3;
34  uint8_t :1;
35  uint8_t Fan :3;
36  uint8_t :1;
37  // Byte 2
38  uint8_t :1;
39  uint8_t Temp :6;
40  uint8_t :1;
41  // Byte 3
42  uint8_t :8;
43  // Byte 4
44  uint8_t :8;
45  // Byte 5
46  uint8_t :4;
47  uint8_t Power :4;
48  // Byte 6
49  uint8_t Max :2;
50  uint8_t :4;
51  uint8_t Vent :2;
52  // Byte 7
53  uint8_t Sum :8;
54  };
55 };
56 
57 // Constants
58 
59 // Fan Control
60 const uint8_t kAmcorFanMin = 0b001;
61 const uint8_t kAmcorFanMed = 0b010;
62 const uint8_t kAmcorFanMax = 0b011;
63 const uint8_t kAmcorFanAuto = 0b100;
64 // Modes
65 const uint8_t kAmcorCool = 0b001;
66 const uint8_t kAmcorHeat = 0b010;
67 const uint8_t kAmcorFan = 0b011; // Aka "Vent"
68 const uint8_t kAmcorDry = 0b100;
69 const uint8_t kAmcorAuto = 0b101;
70 
71 // Temperature
72 const uint8_t kAmcorMinTemp = 12; // Celsius
73 const uint8_t kAmcorMaxTemp = 32; // Celsius
74 
75 // Power
76 const uint8_t kAmcorPowerOn = 0b0011; // 0x3
77 const uint8_t kAmcorPowerOff = 0b1100; // 0xC
78 
79 // Max Mode (aka "Lo" in Cool and "Hi" in Heat)
80 const uint8_t kAmcorMax = 0b11;
81 
82 // "Vent" Mode
83 const uint8_t kAmcorVentOn = 0b11;
84 
85 
86 // Classes
87 
89 class IRAmcorAc {
90  public:
91  explicit IRAmcorAc(const uint16_t pin, const bool inverted = false,
92  const bool use_modulation = true);
93 
94  void stateReset();
95 #if SEND_AMCOR
96  void send(const uint16_t repeat = kAmcorDefaultRepeat);
101  int8_t calibrate(void) { return _irsend.calibrate(); }
102 #endif // SEND_AMCOR
103  void begin();
104  static uint8_t calcChecksum(const uint8_t state[],
105  const uint16_t length = kAmcorStateLength);
106  static bool validChecksum(const uint8_t state[],
107  const uint16_t length = kAmcorStateLength);
108  void setPower(const bool state);
109  bool getPower(void) const;
110  void on(void);
111  void off(void);
112  void setTemp(const uint8_t temp);
113  uint8_t getTemp(void) const;
114  void setMax(const bool on);
115  bool getMax(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  uint8_t* getRaw(void);
121  void setRaw(const uint8_t state[]);
122  static uint8_t convertMode(const stdAc::opmode_t mode);
123  static uint8_t convertFan(const stdAc::fanspeed_t speed);
124  static stdAc::opmode_t toCommonMode(const uint8_t mode);
125  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
126  stdAc::state_t toCommon(void) const;
127  String toString(void) const;
128 #ifndef UNIT_TEST
129 
130  private:
132 #else
133  IRsendTest _irsend;
136 #endif
138  void checksum(void);
139 };
140 #endif // IR_AMCOR_H_
AmcorProtocol::Mode
uint8_t Mode
Definition: ir_Amcor.h:33
IRAmcorAc::IRAmcorAc
IRAmcorAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Amcor.cpp:95
AmcorProtocol::raw
uint8_t raw[kAmcorStateLength]
Definition: ir_Amcor.h:28
IRAmcorAc::getRaw
uint8_t * getRaw(void)
Get the raw state of the object, suitable to be sent with the appropriate IRsend object method.
Definition: ir_Amcor.cpp:143
IRAmcorAc::setMode
void setMode(const uint8_t mode)
Set the desired operation mode.
Definition: ir_Amcor.cpp:236
IRAmcorAc::send
void send(const uint16_t repeat=kAmcorDefaultRepeat)
Send the current internal state as an IR message.
Definition: ir_Amcor.cpp:105
kAmcorCool
const uint8_t kAmcorCool
Definition: ir_Amcor.h:65
kAmcorStateLength
const uint16_t kAmcorStateLength
Definition: IRremoteESP8266.h:859
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
IRAmcorAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivilant.
Definition: ir_Amcor.cpp:292
AmcorProtocol
Definition: ir_Amcor.h:27
kAmcorPowerOn
const uint8_t kAmcorPowerOn
Definition: ir_Amcor.h:76
IRAmcorAc::calcChecksum
static uint8_t calcChecksum(const uint8_t state[], const uint16_t length=kAmcorStateLength)
Calculate the checksum for the supplied state.
Definition: ir_Amcor.cpp:114
kAmcorMax
const uint8_t kAmcorMax
Definition: ir_Amcor.h:80
IRAmcorAc::_irsend
IRsend _irsend
Definition: ir_Amcor.h:131
IRAmcorAc::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Amcor.cpp:274
kAmcorHeat
const uint8_t kAmcorHeat
Definition: ir_Amcor.h:66
IRAmcorAc::begin
void begin()
Set up hardware to be able to send a message.
Definition: ir_Amcor.cpp:100
IRsend.h
kAmcorFanAuto
const uint8_t kAmcorFanAuto
Definition: ir_Amcor.h:63
AmcorProtocol::Fan
uint8_t Fan
Definition: ir_Amcor.h:35
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:176
IRAmcorAc::getMode
uint8_t getMode(void) const
Get the current operation mode setting.
Definition: ir_Amcor.cpp:230
IRAmcorAc::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Amcor.cpp:209
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
String
std::string String
Definition: IRremoteESP8266.h:1148
IRAmcorAc
Class for handling detailed Amcor A/C messages.
Definition: ir_Amcor.h:89
kAmcorMinTemp
const uint8_t kAmcorMinTemp
Definition: ir_Amcor.h:72
IRAmcorAc::setMax
void setMax(const bool on)
Control the current Maximum Cooling or Heating setting. (i.e. Turbo)
Definition: ir_Amcor.cpp:189
AmcorProtocol::Temp
uint8_t Temp
Definition: ir_Amcor.h:39
IRAmcorAc::stateReset
void stateReset()
Reset the internals of the object to a known good state.
Definition: ir_Amcor.cpp:132
kAmcorFan
const uint8_t kAmcorFan
Definition: ir_Amcor.h:67
IRAmcorAc::setRaw
void setRaw(const uint8_t state[])
Set the raw state of the object.
Definition: ir_Amcor.cpp:150
kAmcorVentOn
const uint8_t kAmcorVentOn
Definition: ir_Amcor.h:83
kAmcorFanMin
const uint8_t kAmcorFanMin
Definition: ir_Amcor.h:60
IRAmcorAc::toString
String toString(void) const
Convert the current internal state into a human readable string.
Definition: ir_Amcor.cpp:342
IRremoteESP8266.h
AmcorProtocol::Sum
uint8_t Sum
Definition: ir_Amcor.h:53
IRAmcorAc::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Amcor.cpp:256
kAmcorDry
const uint8_t kAmcorDry
Definition: ir_Amcor.h:68
IRAmcorAc::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_Amcor.cpp:224
kAmcorFanMed
const uint8_t kAmcorFanMed
Definition: ir_Amcor.h:61
IRAmcorAc::getPower
bool getPower(void) const
Get the power setting from the internal state.
Definition: ir_Amcor.cpp:168
IRAmcorAc::setTemp
void setTemp(const uint8_t temp)
Set the temperature.
Definition: ir_Amcor.cpp:174
IRAmcorAc::on
void on(void)
Set the internal state to have the power on.
Definition: ir_Amcor.cpp:155
AmcorProtocol::Vent
uint8_t Vent
Definition: ir_Amcor.h:51
IRAmcorAc::setPower
void setPower(const bool state)
Set the internal state to have the desired power.
Definition: ir_Amcor.cpp:162
IRAmcorAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Amcor.h:101
AmcorProtocol::Power
uint8_t Power
Definition: ir_Amcor.h:47
kAmcorPowerOff
const uint8_t kAmcorPowerOff
Definition: ir_Amcor.h:77
IRAmcorAc::toCommon
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivilant.
Definition: ir_Amcor.cpp:316
IRAmcorAc::checksum
void checksum(void)
Update the checksum value for the internal state.
Definition: ir_Amcor.cpp:127
AmcorProtocol::Max
uint8_t Max
Definition: ir_Amcor.h:49
IRAmcorAc::validChecksum
static bool validChecksum(const uint8_t state[], const uint16_t length=kAmcorStateLength)
Verify the checksum is valid for a given state.
Definition: ir_Amcor.cpp:122
kAmcorAuto
const uint8_t kAmcorAuto
Definition: ir_Amcor.h:69
IRAmcorAc::getMax
bool getMax(void) const
Is the Maximum Cooling or Heating setting (i.e. Turbo) setting on?
Definition: ir_Amcor.cpp:203
IRAmcorAc::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_Amcor.cpp:182
IRAmcorAc::_
AmcorProtocol _
Definition: ir_Amcor.h:137
kAmcorMaxTemp
const uint8_t kAmcorMaxTemp
Definition: ir_Amcor.h:73
kAmcorDefaultRepeat
const uint16_t kAmcorDefaultRepeat
Definition: IRremoteESP8266.h:861
kAmcorFanMax
const uint8_t kAmcorFanMax
Definition: ir_Amcor.h:62
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
IRAmcorAc::off
void off(void)
Set the internal state to have the power off.
Definition: ir_Amcor.cpp:158
IRAmcorAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivilant.
Definition: ir_Amcor.cpp:305
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46