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