IRremoteESP8266
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#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
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
50const uint64_t kTrumaDefaultState = 0x50FFFFFFE6E781;
51const uint8_t kTrumaChecksumInit = 5;
52
53const uint8_t kTrumaAuto = 0; // 0b00
54const uint8_t kTrumaCool = 2; // 0b10
55const uint8_t kTrumaFan = 3; // 0b11
56
57const uint8_t kTrumaFanQuiet = 3; // 0b011
58const uint8_t kTrumaFanHigh = 4; // 0b100
59const uint8_t kTrumaFanMed = 5; // 0b101
60const uint8_t kTrumaFanLow = 6; // 0b110
61
62const uint8_t kTrumaTempOffset = 10;
63const uint8_t kTrumaMinTemp = 16;
64const uint8_t kTrumaMaxTemp = 31;
65
66
67// Class
69class 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:
114#else // UNIT_TEST
116 IRsendTest _irsend;
118#endif // UNIT_TEST
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_
const uint16_t kNoRepeat
Definition IRremoteESP8266.h:1172
std::string String
Definition IRremoteESP8266.h:1564
Class for handling detailed Truma A/C messages.
Definition ir_Truma.h:69
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:79
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:120
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:121
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:113
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:119
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:249
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition IRsend.cpp:209
const uint8_t kTrumaMinTemp
Definition ir_Truma.h:63
const uint8_t kTrumaFanQuiet
Definition ir_Truma.h:57
const uint64_t kTrumaDefaultState
Off, Auto, 16C, High.
Definition ir_Truma.h:50
const uint8_t kTrumaFanLow
Definition ir_Truma.h:60
const uint8_t kTrumaAuto
Definition ir_Truma.h:53
const uint8_t kTrumaChecksumInit
Definition ir_Truma.h:51
const uint8_t kTrumaFanHigh
Definition ir_Truma.h:58
const uint8_t kTrumaFan
Definition ir_Truma.h:55
const uint8_t kTrumaTempOffset
Definition ir_Truma.h:62
const uint8_t kTrumaFanMed
Definition ir_Truma.h:59
const uint8_t kTrumaCool
Definition ir_Truma.h:54
const uint8_t kTrumaMaxTemp
Definition ir_Truma.h:64
fanspeed_t
Common A/C settings for Fan Speeds.
Definition IRsend.h:61
opmode_t
Common A/C settings for A/C operating modes.
Definition IRsend.h:49
Structure to hold a common A/C state.
Definition IRsend.h:114
Native representation of a Truma A/C message.
Definition ir_Truma.h:25
uint8_t Fan
Definition ir_Truma.h:33
uint8_t Sum
Checksum value.
Definition ir_Truma.h:45
uint64_t raw
Remote state in IR code form.
Definition ir_Truma.h:26
uint8_t Temp
Temp in DegC minus 10(DEC).
Definition ir_Truma.h:36
uint8_t PowerOff
Definition ir_Truma.h:32
uint8_t Mode
Definition ir_Truma.h:31