IRremoteESP8266

ir_Truma.h
Go to the documentation of this file.
1 // Copyright 2021 David Conran (crankyoldgit)
2
7
8 // Supports:
9 // Brand: Truma, Model: Aventa A/C
10 // Brand: Truma, Model: 40091-86700 remote
11
12 #ifndef IR_TRUMA_H_
13 #define IR_TRUMA_H_
14
15 #ifndef UNIT_TEST
16 #include <Arduino.h>
17 #endif
18 #include "IRremoteESP8266.h"
19 #include "IRsend.h"
20 #ifdef UNIT_TEST
21 #include "IRsend_test.h"
22 #endif
23
25 union TrumaProtocol{
26 uint64_t raw;
27 struct {
28 // Byte 0 (least significant byte)
29 uint8_t :8; // fixed value (0x81)
30 // Byte 1
31 uint8_t Mode :2;
32 uint8_t PowerOff :1;
33 uint8_t Fan :3;
34 uint8_t :2; // fixed value (0b11)
35 // Byte 2
36 uint8_t Temp:5;
37 uint8_t :3;
38 // Byte 3
39 uint8_t :8; // fixed value (0xFF)
40 // Byte 4
41 uint8_t :8; // fixed value (0xFF)
42 // Byte 5
43 uint8_t :8; // fixed value (0xFF)
44 // Byte 6
45 uint8_t Sum:8;
46 };
47 };
48
49 // Constants
50 const uint64_t kTrumaDefaultState = 0x50FFFFFFE6E781;
51 const uint8_t kTrumaChecksumInit = 5;
52
53 const uint8_t kTrumaAuto = 0; // 0b00
54 const uint8_t kTrumaCool = 2; // 0b10
55 const uint8_t kTrumaFan = 3; // 0b11
56
57 const uint8_t kTrumaFanQuiet = 3; // 0b011
58 const uint8_t kTrumaFanHigh = 4; // 0b100
59 const uint8_t kTrumaFanMed = 5; // 0b101
60 const uint8_t kTrumaFanLow = 6; // 0b110
61
62 const uint8_t kTrumaTempOffset = 10;
63 const uint8_t kTrumaMinTemp = 16;
64 const uint8_t kTrumaMaxTemp = 31;
65
66
67 // Class
69 class IRTrumaAc {
70 public:
71 explicit IRTrumaAc(const uint16_t pin, const bool inverted = false,
72 const bool use_modulation = true);
73 #if SEND_TRUMA
74 void send(const uint16_t repeat = kNoRepeat);
79 int8_t calibrate(void) { return _irsend.calibrate(); }
80 #endif // SEND_TRUMA
81 void begin(void);
82 void stateReset(void);
83
84 void on(void);
85 void off(void);
86 void setPower(const bool on);
87 bool getPower(void) const;
88
89 void setTemp(const uint8_t celsius);
90 uint8_t getTemp(void) const;
91
92 void setFan(const uint8_t speed);
93 uint8_t getFan(void) const;
94
95 uint8_t getMode(void) const;
96 void setMode(const uint8_t mode);
97
98 void setQuiet(const bool on);
99 bool getQuiet(void) const;
100
101 uint64_t getRaw(void);
102 void setRaw(const uint64_t state);
103 static bool validChecksum(const uint64_t state);
104 static uint8_t convertMode(const stdAc::opmode_t mode);
105 static uint8_t convertFan(const stdAc::fanspeed_t speed);
106 static stdAc::opmode_t toCommonMode(const uint8_t mode);
107 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
108 stdAc::state_t toCommon(void) const;
109 String toString(void) const;
110 #ifndef UNIT_TEST
111
112 private:
113 IRsend _irsend;
114 #else // UNIT_TEST
115 IRsendTest _irsend;
117 #endif // UNIT_TEST
119 TrumaProtocol _;
120 uint8_t _lastfan; // Last user chosen/valid fan speed.
121 uint8_t _lastmode; // Last user chosen operation mode.
122 static uint8_t calcChecksum(const uint64_t state);
123 void checksum(void);
124 };
125
126 #endif // IR_TRUMA_H_
IRTrumaAc::setTemp
void setTemp(const uint8_t celsius)
Set the temperature.
Definition: ir_Truma.cpp:225
kTrumaFanQuiet
const uint8_t kTrumaFanQuiet
Definition: ir_Truma.h:57
kTrumaCool
const uint8_t kTrumaCool
Definition: ir_Truma.h:54
IRTrumaAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Truma.cpp:275
IRTrumaAc::setQuiet
void setQuiet(const bool on)
Change the Quiet setting.
Definition: ir_Truma.cpp:238
IRTrumaAc::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_Truma.cpp:200
IRTrumaAc::checksum
void checksum(void)
Calculate & set the checksum for the current internal state of the remote.
Definition: ir_Truma.cpp:143
kTrumaMaxTemp
const uint8_t kTrumaMaxTemp
Definition: ir_Truma.h:64
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:61
IRTrumaAc::getMode
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition: ir_Truma.cpp:221
kTrumaDefaultState
const uint64_t kTrumaDefaultState
Off, Auto, 16C, High.
Definition: ir_Truma.h:50
kTrumaMinTemp
const uint8_t kTrumaMinTemp
Definition: ir_Truma.h:63
kTrumaAuto
const uint8_t kTrumaAuto
Definition: ir_Truma.h:53
IRTrumaAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Truma.cpp:286
IRTrumaAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Truma.h:79
TrumaProtocol::Fan
uint8_t Fan
Definition: ir_Truma.h:33
IRsend.h
IRTrumaAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Truma.cpp:204
IRTrumaAc::stateReset
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition: ir_Truma.cpp:146
kTrumaTempOffset
const uint8_t kTrumaTempOffset
Definition: ir_Truma.h:62
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:237
TrumaProtocol::raw
uint64_t raw
Remote state in IR code form.
Definition: ir_Truma.h:26
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
IRTrumaAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Truma.cpp:110
kTrumaChecksumInit
const uint8_t kTrumaChecksumInit
Definition: ir_Truma.h:51
String
std::string String
Definition: IRremoteESP8266.h:1521
IRTrumaAc::off
void off(void)
Set the requested power state of the A/C to off.
Definition: ir_Truma.cpp:167
IRTrumaAc::getQuiet
bool getQuiet(void) const
Get the value of the current quiet setting.
Definition: ir_Truma.cpp:247
IRremoteESP8266.h
IRTrumaAc::setRaw
void setRaw(const uint64_t state)
Set the internal state from a valid code for this protocol.
Definition: ir_Truma.cpp:157
IRTrumaAc::_
TrumaProtocol _
Definition: ir_Truma.h:119
IRTrumaAc::validChecksum
static bool validChecksum(const uint64_t state)
Verify the checksum is valid for a given state.
Definition: ir_Truma.cpp:136
IRTrumaAc::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Truma.cpp:171
IRTrumaAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Truma.h:113
TrumaProtocol::Mode
uint8_t Mode
Definition: ir_Truma.h:31
TrumaProtocol::Temp
uint8_t Temp
Temp in DegC minus 10(DEC).
Definition: ir_Truma.h:36
IRTrumaAc::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_Truma.cpp:233
kNoRepeat
const uint16_t kNoRepeat
Definition: IRremoteESP8266.h:1145
IRTrumaAc::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Truma.cpp:182
IRTrumaAc::send
void send(const uint16_t repeat=kNoRepeat)
Send the current internal state as an IR message.
Definition: ir_Truma.cpp:115
IRTrumaAc::_lastfan
uint8_t _lastfan
Definition: ir_Truma.h:120
IRTrumaAc::IRTrumaAc
IRTrumaAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Truma.cpp:105
IRTrumaAc::toString
String toString(void) const
Convert the current internal state into a human readable string.
Definition: ir_Truma.cpp:327
TrumaProtocol
Native representation of a Truma A/C message.
Definition: ir_Truma.h:25
TrumaProtocol::Sum
uint8_t Sum
Checksum value.
Definition: ir_Truma.h:45
IRTrumaAc::toCommon
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Truma.cpp:297
IRTrumaAc::on
void on(void)
Set the requested power state of the A/C to on.
Definition: ir_Truma.cpp:164
kTrumaFan
const uint8_t kTrumaFan
Definition: ir_Truma.h:55
IRTrumaAc::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Truma.cpp:263
kTrumaFanMed
const uint8_t kTrumaFanMed
Definition: ir_Truma.h:59
IRTrumaAc::getRaw
uint64_t getRaw(void)
Get a copy of the internal state/code for this protocol.
Definition: ir_Truma.cpp:150
IRTrumaAc
Class for handling detailed Truma A/C messages.
Definition: ir_Truma.h:69
IRTrumaAc::calcChecksum
static uint8_t calcChecksum(const uint64_t state)
Calculate the checksum for a given state.
Definition: ir_Truma.cpp:123
TrumaProtocol::PowerOff
uint8_t PowerOff
Definition: ir_Truma.h:32
IRTrumaAc::getPower
bool getPower(void) const
Get the value of the current power setting.
Definition: ir_Truma.cpp:178
kTrumaFanHigh
const uint8_t kTrumaFanHigh
Definition: ir_Truma.h:58
IRTrumaAc::_lastmode
uint8_t _lastmode
Definition: ir_Truma.h:121
kTrumaFanLow
const uint8_t kTrumaFanLow
Definition: ir_Truma.h:60
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:114
IRTrumaAc::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Truma.cpp:252
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:49