IRremoteESP8266
ir_Rhoss.h
Go to the documentation of this file.
1 // Copyright 2021 Tom Rosenback
2 
5 // Supports:
6 // Brand: Rhoss, Model: Idrowall MPCV 20-30-35-40
7 
8 #ifndef IR_RHOSS_H_
9 #define IR_RHOSS_H_
10 
11 #define __STDC_LIMIT_MACROS
12 #include <stdint.h>
13 #ifndef UNIT_TEST
14 #include <Arduino.h>
15 #endif
16 #include "IRremoteESP8266.h"
17 #include "IRsend.h"
18 #ifdef UNIT_TEST
19 #include "IRsend_test.h"
20 #endif
21 
22 
25  uint8_t raw[kRhossStateLength]; // The state of the IR remote.
26  struct {
27  // Byte 0
28  uint8_t :8; // Typically 0xAA
29  // Byte 1
30  uint8_t Temp :4;
31  uint8_t :4; // Typically 0x0
32  // Byte 2
33  uint8_t :8; // Typically 0x60
34  // Byte 3
35  uint8_t :8; // Typically 0x0
36  // Byte 4
37  uint8_t Fan :2;
38  uint8_t :2; // Typically 0x0
39  uint8_t Mode :4;
40  // Byte 5
41  uint8_t Swing :1;
42  uint8_t :5; // Typically 0x0
43  uint8_t Power :2;
44  // Byte 6
45  uint8_t :8; // Typically 0x54
46  // Byte 7
47  uint8_t :8; // Typically 0x0
48  // Byte 8
49  uint8_t :8; // Typically 0x0
50  // Byte 9
51  uint8_t :8; // Typically 0x0
52  // Byte 10
53  uint8_t :8; // Typically 0x0
54  // Byte 11
55  uint8_t Sum :8;
56  };
57 };
58 
59 // Constants
60 
61 // Fan Control
62 const uint8_t kRhossFanAuto = 0b00;
63 const uint8_t kRhossFanMin = 0b01;
64 const uint8_t kRhossFanMed = 0b10;
65 const uint8_t kRhossFanMax = 0b11;
66 // Modes
67 const uint8_t kRhossModeHeat = 0b0001;
68 const uint8_t kRhossModeCool = 0b0010;
69 const uint8_t kRhossModeDry = 0b0011;
70 const uint8_t kRhossModeFan = 0b0100;
71 const uint8_t kRhossModeAuto = 0b0101;
72 
73 // Temperature
74 const uint8_t kRhossTempMin = 16; // Celsius
75 const uint8_t kRhossTempMax = 30; // Celsius
76 
77 // Power
78 const uint8_t kRhossPowerOn = 0b10; // 0x2
79 const uint8_t kRhossPowerOff = 0b01; // 0x1
80 
81 // Swing
82 const uint8_t kRhossSwingOn = 0b1; // 0x1
83 const uint8_t kRhossSwingOff = 0b0; // 0x0
84 
87 const uint8_t kRhossDefaultTemp = 21; // Celsius
88 const bool kRhossDefaultPower = false;
89 const bool kRhossDefaultSwing = false;
90 
91 // Classes
92 
94 class IRRhossAc {
95  public:
96  explicit IRRhossAc(const uint16_t pin, const bool inverted = false,
97  const bool use_modulation = true);
98 
99  void stateReset();
100 #if SEND_RHOSS
101  void send(const uint16_t repeat = kRhossDefaultRepeat);
106  int8_t calibrate(void) { return _irsend.calibrate(); }
107 #endif // SEND_RHOSS
108  void begin();
109  static uint8_t calcChecksum(const uint8_t state[],
110  const uint16_t length = kRhossStateLength);
111  static bool validChecksum(const uint8_t state[],
112  const uint16_t length = kRhossStateLength);
113  void setPower(const bool state);
114  bool getPower(void) const;
115  void on(void);
116  void off(void);
117  void setTemp(const uint8_t temp);
118  uint8_t getTemp(void) const;
119  void setFan(const uint8_t speed);
120  uint8_t getFan(void) const;
121  void setSwing(const bool state);
122  uint8_t getSwing(void) const;
123  void setMode(const uint8_t mode);
124  uint8_t getMode(void) const;
125  uint8_t* getRaw(void);
126  void setRaw(const uint8_t state[]);
127  static uint8_t convertMode(const stdAc::opmode_t mode);
128  static uint8_t convertFan(const stdAc::fanspeed_t speed);
129  static stdAc::opmode_t toCommonMode(const uint8_t mode);
130  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
131  stdAc::state_t toCommon(void) const;
132  String toString(void) const;
133 #ifndef UNIT_TEST
134 
135  private:
137 #else
138  IRsendTest _irsend;
141 #endif
143  void checksum(void);
144 };
145 #endif // IR_RHOSS_H_
kRhossFanMin
const uint8_t kRhossFanMin
Definition: ir_Rhoss.h:63
kRhossTempMin
const uint8_t kRhossTempMin
Definition: ir_Rhoss.h:74
kRhossDefaultFan
const uint8_t kRhossDefaultFan
Definition: ir_Rhoss.h:85
kRhossSwingOn
const uint8_t kRhossSwingOn
Definition: ir_Rhoss.h:82
kRhossTempMax
const uint8_t kRhossTempMax
Definition: ir_Rhoss.h:75
IRRhossAc::setTemp
void setTemp(const uint8_t temp)
Set the temperature.
Definition: ir_Rhoss.cpp:191
kRhossStateLength
const uint16_t kRhossStateLength
Definition: IRremoteESP8266.h:1432
IRRhossAc::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_Rhoss.cpp:198
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:61
IRRhossAc::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Rhoss.cpp:281
kRhossModeHeat
const uint8_t kRhossModeHeat
Definition: ir_Rhoss.h:67
IRRhossAc::getPower
bool getPower(void) const
Get the power setting from the internal state.
Definition: ir_Rhoss.cpp:185
kRhossDefaultMode
const uint8_t kRhossDefaultMode
Definition: ir_Rhoss.h:86
IRRhossAc
Class for handling detailed Rhoss A/C messages.
Definition: ir_Rhoss.h:94
IRsend.h
IRRhossAc::begin
void begin()
Set up hardware to be able to send a message.
Definition: ir_Rhoss.cpp:112
kRhossModeFan
const uint8_t kRhossModeFan
Definition: ir_Rhoss.h:70
RhossProtocol::Swing
uint8_t Swing
Definition: ir_Rhoss.h:41
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:237
kRhossModeAuto
const uint8_t kRhossModeAuto
Definition: ir_Rhoss.h:71
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
kRhossDefaultPower
const bool kRhossDefaultPower
Definition: ir_Rhoss.h:88
kRhossFanMed
const uint8_t kRhossFanMed
Definition: ir_Rhoss.h:64
String
std::string String
Definition: IRremoteESP8266.h:1521
IRRhossAc::setRaw
void setRaw(const uint8_t state[])
Set the raw state of the object.
Definition: ir_Rhoss.cpp:167
kRhossModeCool
const uint8_t kRhossModeCool
Definition: ir_Rhoss.h:68
RhossProtocol::Sum
uint8_t Sum
Definition: ir_Rhoss.h:55
RhossProtocol::Power
uint8_t Power
Definition: ir_Rhoss.h:43
IRremoteESP8266.h
IRRhossAc::validChecksum
static bool validChecksum(const uint8_t state[], const uint16_t length=kRhossStateLength)
Verify the checksum is valid for a given state.
Definition: ir_Rhoss.cpp:134
kRhossPowerOn
const uint8_t kRhossPowerOn
Definition: ir_Rhoss.h:78
kRhossDefaultSwing
const bool kRhossDefaultSwing
Definition: ir_Rhoss.h:89
IRRhossAc::toString
String toString(void) const
Convert the current internal state into a human readable string.
Definition: ir_Rhoss.cpp:352
kRhossDefaultTemp
const uint8_t kRhossDefaultTemp
Definition: ir_Rhoss.h:87
IRRhossAc::_irsend
IRsend _irsend
Definition: ir_Rhoss.h:136
IRRhossAc::checksum
void checksum(void)
Update the checksum value for the internal state.
Definition: ir_Rhoss.cpp:139
kRhossModeDry
const uint8_t kRhossModeDry
Definition: ir_Rhoss.h:69
IRRhossAc::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Rhoss.cpp:261
kRhossPowerOff
const uint8_t kRhossPowerOff
Definition: ir_Rhoss.h:79
kRhossDefaultRepeat
const uint16_t kRhossDefaultRepeat
Definition: IRremoteESP8266.h:1434
kRhossFanAuto
const uint8_t kRhossFanAuto
Definition: ir_Rhoss.h:62
IRRhossAc::send
void send(const uint16_t repeat=kRhossDefaultRepeat)
Send the current internal state as an IR message.
Definition: ir_Rhoss.cpp:117
RhossProtocol
Native representation of a Rhoss A/C message.
Definition: ir_Rhoss.h:24
IRRhossAc::getMode
uint8_t getMode(void) const
Get the current operation mode setting.
Definition: ir_Rhoss.cpp:237
RhossProtocol::Mode
uint8_t Mode
Definition: ir_Rhoss.h:39
kRhossFanMax
const uint8_t kRhossFanMax
Definition: ir_Rhoss.h:65
kRhossSwingOff
const uint8_t kRhossSwingOff
Definition: ir_Rhoss.h:83
IRRhossAc::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Rhoss.cpp:204
IRRhossAc::setPower
void setPower(const bool state)
Set the internal state to have the desired power.
Definition: ir_Rhoss.cpp:179
IRRhossAc::on
void on(void)
Set the internal state to have the power on.
Definition: ir_Rhoss.cpp:172
IRRhossAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Rhoss.cpp:299
RhossProtocol::Fan
uint8_t Fan
Definition: ir_Rhoss.h:37
IRRhossAc::setSwing
void setSwing(const bool state)
Set the Vertical Swing mode of the A/C.
Definition: ir_Rhoss.cpp:225
IRRhossAc::setMode
void setMode(const uint8_t mode)
Set the desired operation mode.
Definition: ir_Rhoss.cpp:243
IRRhossAc::getRaw
uint8_t * getRaw(void)
Get the raw state of the object, suitable to be sent with the appropriate IRsend object method.
Definition: ir_Rhoss.cpp:160
IRRhossAc::calcChecksum
static uint8_t calcChecksum(const uint8_t state[], const uint16_t length=kRhossStateLength)
Calculate the checksum for the supplied state.
Definition: ir_Rhoss.cpp:126
IRRhossAc::IRRhossAc
IRRhossAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Rhoss.cpp:107
IRRhossAc::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_Rhoss.cpp:219
RhossProtocol::Temp
uint8_t Temp
Definition: ir_Rhoss.h:30
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:114
IRRhossAc::getSwing
uint8_t getSwing(void) const
Get the Vertical Swing speed of the A/C.
Definition: ir_Rhoss.cpp:231
IRRhossAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Rhoss.cpp:313
IRRhossAc::off
void off(void)
Set the internal state to have the power off.
Definition: ir_Rhoss.cpp:175
IRRhossAc::_
RhossProtocol _
Definition: ir_Rhoss.h:142
IRRhossAc::toCommon
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Rhoss.cpp:326
IRRhossAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Rhoss.h:106
IRRhossAc::stateReset
void stateReset()
Reset the internals of the object to a known good state.
Definition: ir_Rhoss.cpp:145
RhossProtocol::raw
uint8_t raw[kRhossStateLength]
Definition: ir_Rhoss.h:25
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:49