# IRremoteESP8266: src/ir_Amcor.h Source File

ir_Amcor.h
Go to the documentation of this file.
// Copyright 2019 David Conran
// Supports:
// Brand: Amcor, Model: ADR-853H A/C
// Brand: Amcor, Model: TAC-495 remote
// Brand: Amcor, Model: TAC-444 remote
#ifndef IR_AMCOR_H_
#define IR_AMCOR_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 AmcorProtocol{
uint8_t raw[kAmcorStateLength]; // The state of the IR remote.
struct {
// Byte 0
uint8_t :8; // Typically 0x01
// Byte 1
uint8_t Mode :3;
uint8_t :1;
uint8_t Fan :3;
uint8_t :1;
// Byte 2
uint8_t :1;
uint8_t Temp :6;
uint8_t :1;
// Byte 3
uint8_t :8;
// Byte 4
uint8_t :8;
// Byte 5
uint8_t :4;
uint8_t Power :4;
// Byte 6
uint8_t Max :2;
uint8_t :4;
uint8_t Vent :2;
// Byte 7
uint8_t Sum :8;
};
};
// Constants
// Fan Control
const uint8_t kAmcorFanMin = 0b001;
const uint8_t kAmcorFanMed = 0b010;
const uint8_t kAmcorFanMax = 0b011;
const uint8_t kAmcorFanAuto = 0b100;
// Modes
const uint8_t kAmcorCool = 0b001;
const uint8_t kAmcorHeat = 0b010;
const uint8_t kAmcorFan = 0b011; // Aka "Vent"
const uint8_t kAmcorDry = 0b100;
const uint8_t kAmcorAuto = 0b101;
// Temperature
const uint8_t kAmcorMinTemp = 12; // Celsius
const uint8_t kAmcorMaxTemp = 32; // Celsius
// Power
const uint8_t kAmcorPowerOn = 0b0011; // 0x3
const uint8_t kAmcorPowerOff = 0b1100; // 0xC
// Max Mode (aka "Lo" in Cool and "Hi" in Heat)
const uint8_t kAmcorMax = 0b11;
// "Vent" Mode
const uint8_t kAmcorVentOn = 0b11;
// Classes
class IRAmcorAc {
public:
explicit IRAmcorAc(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
void stateReset();
#if SEND_AMCOR
void send(const uint16_t repeat = kAmcorDefaultRepeat);
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif // SEND_AMCOR
void begin();
static uint8_t calcChecksum(const uint8_t state[],
const uint16_t length = kAmcorStateLength);
static bool validChecksum(const uint8_t state[],
const uint16_t length = kAmcorStateLength);
void setPower(const bool state);
bool getPower(void) const;
void on(void);
void off(void);
void setTemp(const uint8_t temp);
uint8_t getTemp(void) const;
void setMax(const bool on);
bool getMax(void) const;
void setFan(const uint8_t speed);
uint8_t getFan(void) const;
void setMode(const uint8_t mode);
uint8_t getMode(void) const;
uint8_t* getRaw(void);
void setRaw(const uint8_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
AmcorProtocol _;
void checksum(void);
};
#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:883
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 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:182
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:1178
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:885
kAmcorFanMax
const uint8_t kAmcorFanMax
Definition: ir_Amcor.h:63
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 equivalent.
Definition: ir_Amcor.cpp:305
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46