IRremoteIDF
Infrared send & receive for ESP-IDF
Loading...
Searching...
No Matches
ir_Kelvinator.h
Go to the documentation of this file.
1// Copyright 2016 David Conran
4
5// Supports:
6// Brand: Kelvinator, Model: YALIF Remote
7// Brand: Kelvinator, Model: KSV26CRC A/C
8// Brand: Kelvinator, Model: KSV26HRC A/C
9// Brand: Kelvinator, Model: KSV35CRC A/C
10// Brand: Kelvinator, Model: KSV35HRC A/C
11// Brand: Kelvinator, Model: KSV53HRC A/C
12// Brand: Kelvinator, Model: KSV62HRC A/C
13// Brand: Kelvinator, Model: KSV70CRC A/C
14// Brand: Kelvinator, Model: KSV70HRC A/C
15// Brand: Kelvinator, Model: KSV80HRC A/C
16// Brand: Gree, Model: YAPOF3 remote
17// Brand: Gree, Model: YAP0F8 remote
18// Brand: Sharp, Model: YB1FA remote
19// Brand: Sharp, Model: A5VEY A/C
20
21#ifndef IR_KELVINATOR_H_
22#define IR_KELVINATOR_H_
23
24#define __STDC_LIMIT_MACROS
25#include <stdint.h>
26#include "IRplatform.h"
27#include "IRremoteESP8266.h"
28#include "IRsend.h"
29#ifdef UNIT_TEST
30#include "IRsend_test.h"
31#endif
32
36 struct {
37 // Byte 0
38 uint8_t Mode :3;
39 uint8_t Power :1;
40 uint8_t BasicFan :2;
41 uint8_t SwingAuto :1;
42 uint8_t :1; // Sleep Modes 1 & 3 (1 = On, 0 = Off)
43 // Byte 1
44 uint8_t Temp :4; // Degrees C.
45 uint8_t :4;
46 // Byte 2
47 uint8_t :4;
48 uint8_t Turbo :1;
49 uint8_t Light :1;
50 uint8_t IonFilter :1;
51 uint8_t XFan :1;
52 // Byte 3
53 uint8_t :4;
54 uint8_t :2; // (possibly timer related) (Typically 0b01)
55 uint8_t :2; // End of command block (B01)
56 // (B010 marker and a gap of 20ms)
57 // Byte 4
58 uint8_t SwingV :4;
59 uint8_t SwingH :1;
60 uint8_t :3;
61 // Byte 5~6
62 uint8_t pad0[2]; // Timer related. Typically 0 except when timer in use.
63 // Byte 7
64 uint8_t :4; // (Used in Timer mode)
65 uint8_t Sum1 :4; // checksum of the previous bytes (0-6)
66 // (gap of 40ms)
67 // (header mark and space)
68 // Byte 8~10
69 uint8_t pad1[3]; // Repeat of byte 0~2
70 // Byte 11
71 uint8_t :4;
72 uint8_t :2; // (possibly timer related) (Typically 0b11)
73 uint8_t :2; // End of command block (B01)
74 // (B010 marker and a gap of 20ms)
75 // Byte 12
76 uint8_t :1; // Sleep mode 2 (1 = On, 0=Off)
77 uint8_t :6; // (Used in Sleep Mode 3, Typically 0b000000)
78 uint8_t Quiet :1;
79 // Byte 13
80 uint8_t :8; // (Sleep Mode 3 related, Typically 0x00)
81 // Byte 14
82 uint8_t :4; // (Sleep Mode 3 related, Typically 0b0000)
83 uint8_t Fan :3;
84 // Byte 15
85 uint8_t :4;
86 uint8_t Sum2 :4; // checksum of the previous bytes (8-14)
87 };
88};
89
90// Constants
91const uint8_t kKelvinatorAuto = 0; // (temp = 25C)
92const uint8_t kKelvinatorCool = 1;
93const uint8_t kKelvinatorDry = 2; // (temp = 25C, but not shown)
94const uint8_t kKelvinatorFan = 3;
95const uint8_t kKelvinatorHeat = 4;
96const uint8_t kKelvinatorBasicFanMax = 3;
97const uint8_t kKelvinatorFanAuto = 0;
98const uint8_t kKelvinatorFanMin = 1;
99const uint8_t kKelvinatorFanMax = 5;
100const uint8_t kKelvinatorMinTemp = 16; // 16C
101const uint8_t kKelvinatorMaxTemp = 30; // 30C
102const uint8_t kKelvinatorAutoTemp = 25; // 25C
103
104const uint8_t kKelvinatorSwingVOff = 0b0000; // 0
105const uint8_t kKelvinatorSwingVAuto = 0b0001; // 1
106const uint8_t kKelvinatorSwingVHighest = 0b0010; // 2
107const uint8_t kKelvinatorSwingVUpperMiddle = 0b0011; // 3
108const uint8_t kKelvinatorSwingVMiddle = 0b0100; // 4
109const uint8_t kKelvinatorSwingVLowerMiddle = 0b0101; // 5
110const uint8_t kKelvinatorSwingVLowest = 0b0110; // 6
111const uint8_t kKelvinatorSwingVLowAuto = 0b0111; // 7
112const uint8_t kKelvinatorSwingVMiddleAuto = 0b1001; // 9
113const uint8_t kKelvinatorSwingVHighAuto = 0b1011; // 11
114
115// Legacy defines (Deprecated)
116#define KELVINATOR_MIN_TEMP kKelvinatorMinTemp
117#define KELVINATOR_MAX_TEMP kKelvinatorMaxTemp
118#define KELVINATOR_HEAT kKelvinatorHeat
119#define KELVINATOR_FAN_MAX kKelvinatorFanMax
120#define KELVINATOR_FAN_AUTO kKelvinatorFanAuto
121#define KELVINATOR_FAN kKelvinatorFan
122#define KELVINATOR_DRY kKelvinatorDry
123#define KELVINATOR_COOL kKelvinatorCool
124#define KELVINATOR_BASIC_FAN_MAX kKelvinatorBasicFanMax
125#define KELVINATOR_AUTO_TEMP kKelvinatorAutoTemp
126#define KELVINATOR_AUTO kKelvinatorAuto
127
128// Classes
131 public:
132 explicit IRKelvinatorAC(const uint16_t pin, const bool inverted = false,
133 const bool use_modulation = true);
134 void stateReset(void);
135#if SEND_KELVINATOR
136 void send(const uint16_t repeat = kKelvinatorDefaultRepeat);
141 int8_t calibrate(void) { return _irsend.calibrate(); }
142#endif // SEND_KELVINATOR
143 void begin(void);
144 void on(void);
145 void off(void);
146 void setPower(const bool on);
147 bool getPower(void) const;
148 void setTemp(const uint8_t degrees);
149 uint8_t getTemp(void) const;
150 void setFan(const uint8_t speed);
151 uint8_t getFan(void) const;
152 void setMode(const uint8_t mode);
153 uint8_t getMode(void) const;
154 void setSwingVertical(const bool automatic, const uint8_t position);
155 bool getSwingVerticalAuto(void) const;
156 uint8_t getSwingVerticalPosition(void) const;
157 static uint8_t convertSwingV(const stdAc::swingv_t swingv);
158 static stdAc::swingv_t toCommonSwingV(const uint8_t pos);
159 void setSwingHorizontal(const bool on);
160 bool getSwingHorizontal(void) const;
161 void setQuiet(const bool on);
162 bool getQuiet(void) const;
163 void setIonFilter(const bool on);
164 bool getIonFilter(void) const;
165 void setLight(const bool on);
166 bool getLight(void) const;
167 void setXFan(const bool on);
168 bool getXFan(void) const;
169 void setTurbo(const bool on);
170 bool getTurbo(void) const;
171 uint8_t* getRaw(void);
172 void setRaw(const uint8_t new_code[]);
173 static uint8_t calcBlockChecksum(
174 const uint8_t* block, const uint16_t length = kKelvinatorStateLength / 2);
175 static bool validChecksum(const uint8_t state[],
176 const uint16_t length = kKelvinatorStateLength);
177 static uint8_t convertMode(const stdAc::opmode_t mode);
178 static stdAc::opmode_t toCommonMode(const uint8_t mode);
179 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
180 stdAc::state_t toCommon(void) const;
181 String toString(void) const;
182#ifndef UNIT_TEST
183
184 private:
186#else // UNIT_TEST
188 IRsendTest _irsend;
190#endif // UNIT_TEST
192 void checksum(void);
193 void fixup(void);
194};
195
196#endif // IR_KELVINATOR_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 kKelvinatorDefaultRepeat
Definition IRremoteESP8266.h:1320
const uint16_t kKelvinatorStateLength
Definition IRremoteESP8266.h:1318
Class for handling detailed Kelvinator A/C messages.
Definition ir_Kelvinator.h:130
uint8_t * getRaw(void)
Get the raw state of the object, suitable to be sent with the appropriate IRsend object method.
Definition ir_Kelvinator.cpp:147
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed to it's stdAc::fanspeed_t equivalent.
Definition ir_Kelvinator.cpp:443
uint8_t getSwingVerticalPosition(void) const
Get the Vertical Swing position setting of the A/C.
Definition ir_Kelvinator.cpp:318
static uint8_t calcBlockChecksum(const uint8_t *block, const uint16_t length=kKelvinatorStateLength/2)
Calculate the checksum for a given block of state.
Definition ir_Kelvinator.cpp:163
void setQuiet(const bool on)
Control the current Quiet setting.
Definition ir_Kelvinator.cpp:337
void setSwingHorizontal(const bool on)
Control the current horizontal swing setting.
Definition ir_Kelvinator.cpp:324
void fixup(void)
Fix up any odd conditions for the current state.
Definition ir_Kelvinator.cpp:125
bool getXFan(void) const
Is the XFan setting on?
Definition ir_Kelvinator.cpp:383
bool getQuiet(void) const
Is the Quiet setting on?
Definition ir_Kelvinator.cpp:343
static uint8_t convertSwingV(const stdAc::swingv_t swingv)
Convert a stdAc::swingv_t enum into it's native setting.
Definition ir_Kelvinator.cpp:416
void begin(void)
Set up hardware to be able to send a message.
Definition ir_Kelvinator.cpp:122
void setRaw(const uint8_t new_code[])
Set the raw state of the object.
Definition ir_Kelvinator.cpp:154
void off(void)
Set the internal state to have the power off.
Definition ir_Kelvinator.cpp:200
stdAc::state_t toCommon(void) const
Convert the internal A/C object state to it's stdAc::state_t equivalent.
Definition ir_Kelvinator.cpp:449
static stdAc::swingv_t toCommonSwingV(const uint8_t pos)
void setPower(const bool on)
Set the internal state to have the desired power.
Definition ir_Kelvinator.cpp:204
bool getSwingVerticalAuto(void) const
Get the Vertical Swing Automatic mode setting of the A/C.
Definition ir_Kelvinator.cpp:312
String toString(void) const
Convert the internal settings into a human readable string.
Definition ir_Kelvinator.cpp:475
void setIonFilter(const bool on)
Control the current Ion Filter setting.
Definition ir_Kelvinator.cpp:349
uint8_t getTemp(void) const
Get the current temperature setting.
Definition ir_Kelvinator.cpp:224
void on(void)
Set the internal state to have the power on.
Definition ir_Kelvinator.cpp:197
void setTurbo(const bool on)
Control the current Turbo setting.
Definition ir_Kelvinator.cpp:390
void setLight(const bool on)
Control the current Light setting. i.e. The LED display on the A/C unit that shows the basic settings...
Definition ir_Kelvinator.cpp:362
void setSwingVertical(const bool automatic, const uint8_t position)
Set the Vertical Swing mode of the A/C.
Definition ir_Kelvinator.cpp:281
void send(const uint16_t repeat=kKelvinatorDefaultRepeat)
Send the current internal state as an IR message.
Definition ir_Kelvinator.cpp:139
static bool validChecksum(const uint8_t state[], const uint16_t length=kKelvinatorStateLength)
Verify the checksum is valid for a given state.
Definition ir_Kelvinator.cpp:185
void checksum(void)
Calculate the checksum for the internal state.
Definition ir_Kelvinator.cpp:176
bool getLight(void) const
Is the Light (Display) setting on?
Definition ir_Kelvinator.cpp:368
void setTemp(const uint8_t degrees)
Set the temperature setting.
Definition ir_Kelvinator.cpp:216
bool getSwingHorizontal(void) const
Is the horizontal swing setting on?
Definition ir_Kelvinator.cpp:331
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a standard A/C mode (stdAc::opmode_t) into it a native mode.
Definition ir_Kelvinator.cpp:403
void stateReset(void)
Reset the internals of the object to a known good state.
Definition ir_Kelvinator.cpp:115
KelvinatorProtocol _
Definition ir_Kelvinator.h:191
bool getPower(void) const
Get the power setting from the internal state.
Definition ir_Kelvinator.cpp:210
bool getIonFilter(void) const
Is the Ion Filter setting on?
Definition ir_Kelvinator.cpp:355
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode to it's stdAc::opmode_t equivalent.
Definition ir_Kelvinator.cpp:430
IRsend _irsend
Instance of the IR send class.
Definition ir_Kelvinator.h:185
uint8_t getFan(void) const
Get the current fan speed setting.
Definition ir_Kelvinator.cpp:246
bool getTurbo(void) const
Is the Turbo setting on?
Definition ir_Kelvinator.cpp:396
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition ir_Kelvinator.h:141
void setXFan(const bool on)
Control the current XFan setting. This setting will cause the unit blow air after power off to dry ou...
Definition ir_Kelvinator.cpp:377
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition ir_Kelvinator.cpp:230
void setMode(const uint8_t mode)
Set the desired operation mode.
Definition ir_Kelvinator.cpp:258
uint8_t getMode(void) const
Get the current operation mode setting.
Definition ir_Kelvinator.cpp:252
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 kKelvinatorHeat
Definition ir_Kelvinator.h:95
const uint8_t kKelvinatorSwingVMiddle
Definition ir_Kelvinator.h:108
const uint8_t kKelvinatorBasicFanMax
Definition ir_Kelvinator.h:96
const uint8_t kKelvinatorMaxTemp
Definition ir_Kelvinator.h:101
const uint8_t kKelvinatorDry
Definition ir_Kelvinator.h:93
const uint8_t kKelvinatorFanMin
Definition ir_Kelvinator.h:98
const uint8_t kKelvinatorSwingVMiddleAuto
Definition ir_Kelvinator.h:112
const uint8_t kKelvinatorAuto
Definition ir_Kelvinator.h:91
const uint8_t kKelvinatorFanMax
Definition ir_Kelvinator.h:99
const uint8_t kKelvinatorFan
Definition ir_Kelvinator.h:94
const uint8_t kKelvinatorMinTemp
Definition ir_Kelvinator.h:100
const uint8_t kKelvinatorSwingVOff
Definition ir_Kelvinator.h:104
const uint8_t kKelvinatorSwingVLowerMiddle
Definition ir_Kelvinator.h:109
const uint8_t kKelvinatorFanAuto
Definition ir_Kelvinator.h:97
const uint8_t kKelvinatorCool
Definition ir_Kelvinator.h:92
const uint8_t kKelvinatorSwingVHighest
Definition ir_Kelvinator.h:106
const uint8_t kKelvinatorSwingVAuto
Definition ir_Kelvinator.h:105
const uint8_t kKelvinatorSwingVUpperMiddle
Definition ir_Kelvinator.h:107
const uint8_t kKelvinatorSwingVLowAuto
Definition ir_Kelvinator.h:111
const uint8_t kKelvinatorSwingVHighAuto
Definition ir_Kelvinator.h:113
const uint8_t kKelvinatorSwingVLowest
Definition ir_Kelvinator.h:110
const uint8_t kKelvinatorAutoTemp
Definition ir_Kelvinator.h:102
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
swingv_t
Common A/C settings for Vertical Swing.
Definition IRsend.h:80
Structure to hold a common A/C state.
Definition IRsend.h:120
Native representation of a Kelvinator A/C message.
Definition ir_Kelvinator.h:34
uint8_t Sum1
Definition ir_Kelvinator.h:65
uint8_t Temp
Definition ir_Kelvinator.h:44
uint8_t Light
Definition ir_Kelvinator.h:49
uint8_t XFan
Definition ir_Kelvinator.h:51
uint8_t Power
Definition ir_Kelvinator.h:39
uint8_t Turbo
Definition ir_Kelvinator.h:48
uint8_t Fan
Definition ir_Kelvinator.h:83
uint8_t BasicFan
Definition ir_Kelvinator.h:40
uint8_t SwingAuto
Definition ir_Kelvinator.h:41
uint8_t raw[kKelvinatorStateLength]
The state in IR code form.
Definition ir_Kelvinator.h:35
uint8_t pad1[3]
Definition ir_Kelvinator.h:69
uint8_t SwingH
Definition ir_Kelvinator.h:59
uint8_t pad0[2]
Definition ir_Kelvinator.h:62
uint8_t Sum2
Definition ir_Kelvinator.h:86
uint8_t SwingV
Definition ir_Kelvinator.h:58
uint8_t Mode
Definition ir_Kelvinator.h:38
uint8_t Quiet
Definition ir_Kelvinator.h:78
uint8_t IonFilter
Definition ir_Kelvinator.h:50