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