IRremoteESP8266
ir_Argo.h
Go to the documentation of this file.
1 // Copyright 2017 Schmolders
4 
5 // Supports:
6 // Brand: Argo, Model: Ulisse 13 DCI Mobile Split A/C
7 
8 #ifndef IR_ARGO_H_
9 #define IR_ARGO_H_
10 
11 #ifndef UNIT_TEST
12 #include <Arduino.h>
13 #endif
14 #include "IRremoteESP8266.h"
15 #include "IRsend.h"
16 #ifdef UNIT_TEST
17 #include "IRsend_test.h"
18 #endif
19 
20 
21 // ARGO Ulisse DCI
22 
24 union ArgoProtocol {
25  uint8_t raw[kArgoStateLength];
26  struct {
27  // Byte 0
28  uint64_t :8; // Typically 0b00110101
29  // Byte 1
30  uint64_t :8; // Typically 0b10101111
31  // Byte 2~4
32  uint64_t :3;
33  uint64_t Mode :3;
34  uint64_t Temp :5; // straddle byte 2 and 3
35  uint64_t Fan :2;
36  uint64_t RoomTemp :5; // straddle byte 3 and 4
37  uint64_t Flap :3; // SwingV
38  uint64_t :3; // OnTimer, maybe hours
39  // Byte 5
40  uint64_t :8; // OnTimer, maybe minutes
41  // Byte 6
42  uint64_t :8; // OffTimer, maybe minutes
43  // Byte 7
44  uint64_t :3; // OffTimer, maybe hours
45  uint64_t :5; // Time
46  // Byte 8
47  uint32_t :6; // Time
48  uint32_t :1; // Timer On/Off
49  uint32_t :1; // Timer Program
50  // Byte 9
51  uint32_t :1; // Timer Program
52  uint32_t :1; // Timer 1h
53  uint32_t Night :1;
54  uint32_t Max :1;
55  uint32_t :1; // Filter
56  uint32_t Power :1;
57  uint32_t :1; // const 0
58  uint32_t iFeel :1;
59  // Byte 10~11
60  uint32_t :2; // const 01
61  uint32_t Sum :8; // straddle byte 10 and 11
62  uint32_t :6;
63  };
64 };
65 
66 // Constants. Store MSB left.
67 
68 const uint8_t kArgoHeatBit = 0b00100000;
69 
70 // Mode 0b00111000
71 const uint8_t kArgoCool = 0b000;
72 const uint8_t kArgoDry = 0b001;
73 const uint8_t kArgoAuto = 0b010;
74 const uint8_t kArgoOff = 0b011;
75 const uint8_t kArgoHeat = 0b100;
76 const uint8_t kArgoHeatAuto = 0b101;
77 // ?no idea what mode that is
78 const uint8_t kArgoHeatBlink = 0b110;
79 
80 // Fan 0b00011000
81 const uint8_t kArgoFanAuto = 0; // 0b00
82 const uint8_t kArgoFan1 = 1; // 0b01
83 const uint8_t kArgoFan2 = 2; // 0b10
84 const uint8_t kArgoFan3 = 3; // 0b11
85 
86 // Temp
87 const uint8_t kArgoTempDelta = 4;
88 const uint8_t kArgoMaxRoomTemp = 35; // Celsius
89 const uint8_t kArgoMinTemp = 10; // Celsius delta +4
90 const uint8_t kArgoMaxTemp = 32; // Celsius
91 
92 // Flap/SwingV
93 const uint8_t kArgoFlapAuto = 0;
94 const uint8_t kArgoFlap1 = 1;
95 const uint8_t kArgoFlap2 = 2;
96 const uint8_t kArgoFlap3 = 3;
97 const uint8_t kArgoFlap4 = 4;
98 const uint8_t kArgoFlap5 = 5;
99 const uint8_t kArgoFlap6 = 6;
100 const uint8_t kArgoFlapFull = 7;
101 
102 // Legacy defines. (Deprecated)
103 #define ARGO_COOL_ON kArgoCoolOn
104 #define ARGO_COOL_OFF kArgoCoolOff
105 #define ARGO_COOL_AUTO kArgoCoolAuto
106 #define ARGO_COOL_HUM kArgoCoolHum
107 #define ARGO_HEAT_ON kArgoHeatOn
108 #define ARGO_HEAT_AUTO kArgoHeatAuto
109 #define ARGO_HEAT_BLINK kArgoHeatBlink
110 #define ARGO_MIN_TEMP kArgoMinTemp
111 #define ARGO_MAX_TEMP kArgoMaxTemp
112 #define ARGO_FAN_AUTO kArgoFanAuto
113 #define ARGO_FAN_3 kArgoFan3
114 #define ARGO_FAN_2 kArgoFan2
115 #define ARGO_FAN_1 kArgoFan1
116 #define ARGO_FLAP_AUTO kArgoFlapAuto
117 #define ARGO_FLAP_1 kArgoFlap1
118 #define ARGO_FLAP_2 kArgoFlap2
119 #define ARGO_FLAP_3 kArgoFlap3
120 #define ARGO_FLAP_4 kArgoFlap4
121 #define ARGO_FLAP_5 kArgoFlap5
122 #define ARGO_FLAP_6 kArgoFlap6
123 #define ARGO_FLAP_FULL kArgoFlapFull
124 
125 
127 class IRArgoAC {
128  public:
129  explicit IRArgoAC(const uint16_t pin, const bool inverted = false,
130  const bool use_modulation = true);
131 
132 #if SEND_ARGO
133  void send(const uint16_t repeat = kArgoDefaultRepeat);
134  void sendSensorTemp(const uint8_t temp,
135  const uint16_t repeat = kArgoDefaultRepeat);
140  int8_t calibrate(void) { return _irsend.calibrate(); }
141 #endif // SEND_ARGO
142  void begin(void);
143  void on(void);
144  void off(void);
145 
146  void setPower(const bool on);
147  bool getPower(void) const;
148 
149  void setTemp(const uint8_t degrees);
150  uint8_t getTemp(void) const;
151 
152  void setFan(const uint8_t fan);
153  uint8_t getFan(void) const;
154 
155  void setFlap(const uint8_t flap);
156  uint8_t getFlap(void) const;
157 
158  void setMode(const uint8_t mode);
159  uint8_t getMode(void) const;
160 
161  void setMax(const bool on);
162  bool getMax(void) const;
163 
164  void setNight(const bool on);
165  bool getNight(void) const;
166 
167  void setiFeel(const bool on);
168  bool getiFeel(void) const;
169 
170  void setTime(void);
171  void setRoomTemp(const uint8_t degrees);
172  uint8_t getRoomTemp(void) const;
173 
174  uint8_t* getRaw(void);
175  void setRaw(const uint8_t state[]);
176  static uint8_t calcChecksum(const uint8_t state[],
177  const uint16_t length = kArgoStateLength);
178  static bool validChecksum(const uint8_t state[],
179  const uint16_t length = kArgoStateLength);
180  static uint8_t convertMode(const stdAc::opmode_t mode);
181  static uint8_t convertFan(const stdAc::fanspeed_t speed);
182  static uint8_t convertSwingV(const stdAc::swingv_t position);
183  static stdAc::opmode_t toCommonMode(const uint8_t mode);
184  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
185  stdAc::state_t toCommon(void) const;
186  String toString(void) const;
187 #ifndef UNIT_TEST
188 
189  private:
191 #else
192  IRsendTest _irsend;
194 #endif
196  // # of bytes per command
198  void stateReset(void);
199  void checksum(void);
200 
201  // Attributes
202  uint8_t flap_mode;
203  uint8_t heat_mode;
204  uint8_t cool_mode;
205 };
206 
207 #endif // IR_ARGO_H_
IRArgoAC::setTime
void setTime(void)
Set the time for the A/C.
Definition: ir_Argo.cpp:266
IRArgoAC::calcChecksum
static uint8_t calcChecksum(const uint8_t state[], const uint16_t length=kArgoStateLength)
Verify the checksum is valid for a given state.
Definition: ir_Argo.cpp:94
ArgoProtocol::Sum
uint32_t Sum
Definition: ir_Argo.h:61
IRArgoAC::flap_mode
uint8_t flap_mode
Definition: ir_Argo.h:202
IRArgoAC::setFan
void setFan(const uint8_t fan)
Set the speed of the fan.
Definition: ir_Argo.cpp:198
IRArgoAC::_irsend
IRsend _irsend
instance of the IR send class
Definition: ir_Argo.h:190
kArgoHeatBlink
const uint8_t kArgoHeatBlink
Definition: ir_Argo.h:78
stdAc::swingv_t
swingv_t
Common A/C settings for Vertical Swing.
Definition: IRsend.h:70
IRArgoAC::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_Argo.cpp:204
kArgoMaxTemp
const uint8_t kArgoMaxTemp
Definition: ir_Argo.h:90
kArgoDefaultRepeat
const uint16_t kArgoDefaultRepeat
Definition: IRremoteESP8266.h:1127
IRArgoAC::setTemp
void setTemp(const uint8_t degrees)
Set the temperature.
Definition: ir_Argo.cpp:181
IRArgoAC::setFlap
void setFlap(const uint8_t flap)
Set the flap position. i.e. Swing.
Definition: ir_Argo.cpp:211
IRArgoAC::toString
String toString(void) const
Convert the current internal state into a human readable string.
Definition: ir_Argo.cpp:394
IRArgoAC::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Argo.cpp:287
IRArgoAC::getRoomTemp
uint8_t getRoomTemp(void) const
Get the currently stored value for the room temperature setting.
Definition: ir_Argo.cpp:280
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
kArgoFlap2
const uint8_t kArgoFlap2
Definition: ir_Argo.h:95
IRArgoAC::getFlap
uint8_t getFlap(void) const
Get the flap position. i.e. Swing.
Definition: ir_Argo.cpp:219
IRArgoAC::stateReset
void stateReset(void)
Reset the internals of the object to a known good state.
Definition: ir_Argo.cpp:120
ArgoProtocol::Night
uint32_t Night
Definition: ir_Argo.h:53
kArgoFlap4
const uint8_t kArgoFlap4
Definition: ir_Argo.h:97
kArgoHeatBit
const uint8_t kArgoHeatBit
Definition: ir_Argo.h:68
IRArgoAC::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Argo.h:140
IRsend.h
IRArgoAC::getPower
bool getPower(void) const
Get the power setting from the internal state.
Definition: ir_Argo.cpp:166
kArgoFlap3
const uint8_t kArgoFlap3
Definition: ir_Argo.h:96
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:212
IRArgoAC::validChecksum
static bool validChecksum(const uint8_t state[], const uint16_t length=kArgoStateLength)
Verify the checksum is valid for a given state.
Definition: ir_Argo.cpp:105
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
kArgoStateLength
const uint16_t kArgoStateLength
Definition: IRremoteESP8266.h:1125
String
std::string String
Definition: IRremoteESP8266.h:1472
kArgoFan1
const uint8_t kArgoFan1
Definition: ir_Argo.h:82
IRArgoAC::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Argo.cpp:344
kArgoOff
const uint8_t kArgoOff
Definition: ir_Argo.h:74
ArgoProtocol::Flap
uint64_t Flap
Definition: ir_Argo.h:37
IRArgoAC::getiFeel
bool getiFeel(void) const
Get the status of iFeel mode.
Definition: ir_Argo.cpp:262
IRArgoAC::convertSwingV
static uint8_t convertSwingV(const stdAc::swingv_t position)
Convert a stdAc::swingv_t enum into it's native setting.
Definition: ir_Argo.cpp:324
kArgoFlapFull
const uint8_t kArgoFlapFull
Definition: ir_Argo.h:100
ArgoProtocol::Mode
uint64_t Mode
Definition: ir_Argo.h:33
IRremoteESP8266.h
IRArgoAC::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_Argo.cpp:192
kArgoDry
const uint8_t kArgoDry
Definition: ir_Argo.h:72
IRArgoAC::toCommon
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Argo.cpp:368
kArgoAuto
const uint8_t kArgoAuto
Definition: ir_Argo.h:73
IRArgoAC::setRoomTemp
void setRoomTemp(const uint8_t degrees)
Set the value for the current room temperature.
Definition: ir_Argo.cpp:272
IRArgoAC::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Argo.cpp:306
IRArgoAC::off
void off(void)
Set the internal state to have the power off.
Definition: ir_Argo.cpp:156
ArgoProtocol::Temp
uint64_t Temp
Definition: ir_Argo.h:34
ArgoProtocol::Power
uint32_t Power
Definition: ir_Argo.h:56
IRArgoAC::setPower
void setPower(const bool on)
Set the internal state to have the desired power.
Definition: ir_Argo.cpp:160
kArgoFlap1
const uint8_t kArgoFlap1
Definition: ir_Argo.h:94
ArgoProtocol::raw
uint8_t raw[kArgoStateLength]
The state in native IR code form.
Definition: ir_Argo.h:25
IRArgoAC::getRaw
uint8_t * getRaw(void)
Get the raw state of the object, suitable to be sent with the appropriate IRsend object method.
Definition: ir_Argo.cpp:141
ArgoProtocol::Fan
uint64_t Fan
Definition: ir_Argo.h:35
IRArgoAC::heat_mode
uint8_t heat_mode
Definition: ir_Argo.h:203
ArgoProtocol::Max
uint32_t Max
Definition: ir_Argo.h:54
ArgoProtocol::RoomTemp
uint64_t RoomTemp
Definition: ir_Argo.h:36
IRArgoAC::sendSensorTemp
void sendSensorTemp(const uint8_t temp, const uint16_t repeat=kArgoDefaultRepeat)
Send current room temperature for the iFeel feature as a silent IR message (no acknowledgement from t...
Definition: ir_Argo.cpp:71
kArgoMinTemp
const uint8_t kArgoMinTemp
Definition: ir_Argo.h:89
IRArgoAC::on
void on(void)
Set the internal state to have the power on.
Definition: ir_Argo.cpp:153
IRArgoAC::setNight
void setNight(const bool on)
Turn on/off the Night mode. i.e. Sleep.
Definition: ir_Argo.cpp:246
kArgoFan2
const uint8_t kArgoFan2
Definition: ir_Argo.h:83
kArgoCool
const uint8_t kArgoCool
Definition: ir_Argo.h:71
IRArgoAC::send
void send(const uint16_t repeat=kArgoDefaultRepeat)
Send the current internal state as an IR message.
Definition: ir_Argo.cpp:63
IRArgoAC::_
ArgoProtocol _
Definition: ir_Argo.h:197
kArgoHeatAuto
const uint8_t kArgoHeatAuto
Definition: ir_Argo.h:76
ArgoProtocol
Native representation of a Argo A/C message.
Definition: ir_Argo.h:24
IRArgoAC::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Argo.cpp:357
kArgoHeat
const uint8_t kArgoHeat
Definition: ir_Argo.h:75
IRArgoAC::setRaw
void setRaw(const uint8_t state[])
Set the raw state of the object.
Definition: ir_Argo.cpp:148
IRArgoAC::getMode
uint8_t getMode(void) const
Get the current operation mode setting.
Definition: ir_Argo.cpp:223
kArgoFlap5
const uint8_t kArgoFlap5
Definition: ir_Argo.h:98
IRArgoAC::IRArgoAC
IRArgoAC(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Argo.cpp:53
kArgoTempDelta
const uint8_t kArgoTempDelta
Definition: ir_Argo.h:87
IRArgoAC::checksum
void checksum(void)
Update the checksum for the internal state.
Definition: ir_Argo.cpp:111
kArgoFlap6
const uint8_t kArgoFlap6
Definition: ir_Argo.h:99
IRArgoAC::cool_mode
uint8_t cool_mode
Definition: ir_Argo.h:204
IRArgoAC::getMax
bool getMax(void) const
Is the Max (i.e. Turbo) setting on?
Definition: ir_Argo.cpp:176
IRArgoAC::getNight
bool getNight(void) const
Get the status of Night mode. i.e. Sleep.
Definition: ir_Argo.cpp:252
IRArgoAC::setiFeel
void setiFeel(const bool on)
Turn on/off the iFeel mode.
Definition: ir_Argo.cpp:256
ArgoProtocol::iFeel
uint32_t iFeel
Definition: ir_Argo.h:58
IRArgoAC::setMax
void setMax(const bool on)
Control the current Max setting. (i.e. Turbo)
Definition: ir_Argo.cpp:170
kArgoFlapAuto
const uint8_t kArgoFlapAuto
Definition: ir_Argo.h:93
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
kArgoFan3
const uint8_t kArgoFan3
Definition: ir_Argo.h:84
IRArgoAC
Class for handling detailed Argo A/C messages.
Definition: ir_Argo.h:127
kArgoFanAuto
const uint8_t kArgoFanAuto
Definition: ir_Argo.h:81
IRArgoAC::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Argo.cpp:58
IRArgoAC::setMode
void setMode(const uint8_t mode)
Set the desired operation mode.
Definition: ir_Argo.cpp:229
kArgoMaxRoomTemp
const uint8_t kArgoMaxRoomTemp
Definition: ir_Argo.h:88
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46