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 union AmcorProtocol{
29 uint8_t raw[kAmcorStateLength]; // The state of the IR remote.
30 struct {
31 // Byte 0
32 uint8_t :8; // Typically 0x01
33 // Byte 1
34 uint8_t Mode :3;
35 uint8_t :1;
36 uint8_t Fan :3;
37 uint8_t :1;
38 // Byte 2
39 uint8_t :1;
40 uint8_t Temp :6;
41 uint8_t :1;
42 // Byte 3
43 uint8_t :8;
44 // Byte 4
45 uint8_t :8;
46 // Byte 5
47 uint8_t :4;
48 uint8_t Power :4;
49 // Byte 6
50 uint8_t Max :2;
51 uint8_t :4;
52 uint8_t Vent :2;
53 // Byte 7
54 uint8_t Sum :8;
55 };
56 };
57
58 // Constants
59
60 // Fan Control
61 const uint8_t kAmcorFanMin = 0b001;
62 const uint8_t kAmcorFanMed = 0b010;
63 const uint8_t kAmcorFanMax = 0b011;
64 const uint8_t kAmcorFanAuto = 0b100;
65 // Modes
66 const uint8_t kAmcorCool = 0b001;
67 const uint8_t kAmcorHeat = 0b010;
68 const uint8_t kAmcorFan = 0b011; // Aka "Vent"
69 const uint8_t kAmcorDry = 0b100;
70 const uint8_t kAmcorAuto = 0b101;
71
72 // Temperature
73 const uint8_t kAmcorMinTemp = 12; // Celsius
74 const uint8_t kAmcorMaxTemp = 32; // Celsius
75
76 // Power
77 const uint8_t kAmcorPowerOn = 0b0011; // 0x3
78 const uint8_t kAmcorPowerOff = 0b1100; // 0xC
79
80 // Max Mode (aka "Lo" in Cool and "Hi" in Heat)
81 const uint8_t kAmcorMax = 0b11;
82
83 // "Vent" Mode
84 const uint8_t kAmcorVentOn = 0b11;
85
86
87 // Classes
88
90 class IRAmcorAc {
91 public:
92 explicit IRAmcorAc(const uint16_t pin, const bool inverted = false,
93 const bool use_modulation = true);
94
95 void stateReset();
96 #if SEND_AMCOR
97 void send(const uint16_t repeat = kAmcorDefaultRepeat);
102 int8_t calibrate(void) { return _irsend.calibrate(); }
103 #endif // SEND_AMCOR
104 void begin();
105 static uint8_t calcChecksum(const uint8_t state[],
106 const uint16_t length = kAmcorStateLength);
107 static bool validChecksum(const uint8_t state[],
108 const uint16_t length = kAmcorStateLength);
109 void setPower(const bool state);
110 bool getPower(void) const;
111 void on(void);
112 void off(void);
113 void setTemp(const uint8_t temp);
114 uint8_t getTemp(void) const;
115 void setMax(const bool on);
116 bool getMax(void) const;
117 void setFan(const uint8_t speed);
118 uint8_t getFan(void) const;
119 void setMode(const uint8_t mode);
120 uint8_t getMode(void) const;
121 uint8_t* getRaw(void);
122 void setRaw(const uint8_t state[]);
123 static uint8_t convertMode(const stdAc::opmode_t mode);
124 static uint8_t convertFan(const stdAc::fanspeed_t speed);
125 static stdAc::opmode_t toCommonMode(const uint8_t mode);
126 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
127 stdAc::state_t toCommon(void) const;
128 String toString(void) const;
129 #ifndef UNIT_TEST
130
131 private:
132 IRsend _irsend;
133 #else
134 IRsendTest _irsend;
137 #endif
138 AmcorProtocol _;
139 void checksum(void);
140 };
141 #endif // IR_AMCOR_H_
AmcorProtocol::Mode
uint8_t Mode
Definition: ir_Amcor.h:34
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:29
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:66
kAmcorStateLength
const uint16_t kAmcorStateLength
Definition: IRremoteESP8266.h:1155
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:61
IRAmcorAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Amcor.cpp:292
AmcorProtocol
Native representation of a Amcor A/C message.
Definition: ir_Amcor.h:28
kAmcorPowerOn
const uint8_t kAmcorPowerOn
Definition: ir_Amcor.h:77
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:81
IRAmcorAc::_irsend
IRsend _irsend
Definition: ir_Amcor.h:132
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:67
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:64
AmcorProtocol::Fan
uint8_t Fan
Definition: ir_Amcor.h:36
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:237
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:1521
IRAmcorAc
Class for handling detailed Amcor A/C messages.
Definition: ir_Amcor.h:90
kAmcorMinTemp
const uint8_t kAmcorMinTemp
Definition: ir_Amcor.h:73
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:40
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:68
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:84
kAmcorFanMin
const uint8_t kAmcorFanMin
Definition: ir_Amcor.h:61
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:54
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:69
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:62
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:52
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:102
AmcorProtocol::Power
uint8_t Power
Definition: ir_Amcor.h:48
kAmcorPowerOff
const uint8_t kAmcorPowerOff
Definition: ir_Amcor.h:78
IRAmcorAc::toCommon
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
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:50
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:70
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:138
kAmcorMaxTemp
const uint8_t kAmcorMaxTemp
Definition: ir_Amcor.h:74
kAmcorDefaultRepeat
const uint16_t kAmcorDefaultRepeat
Definition: IRremoteESP8266.h:1157
kAmcorFanMax
const uint8_t kAmcorFanMax
Definition: ir_Amcor.h:63
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:114
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 equivalent.
Definition: ir_Amcor.cpp:305
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:49