IRremoteIDF
Infrared send & receive for ESP-IDF
Loading...
Searching...
No Matches
ir_York.h
Go to the documentation of this file.
1// Copyright 2022 Daniele Gobbetti
2
5
6// Supports:
7// Brand: York, Model: MHH07P17 A/C
8// Brand: York, Model: GRYLH2A remote
9
10#ifndef IR_YORK_H_
11#define IR_YORK_H_
12
13#define __STDC_LIMIT_MACROS
14#include <stdint.h>
15#include "IRplatform.h"
16#include "IRremoteESP8266.h"
17#include "IRsend.h"
18#ifdef UNIT_TEST
19#include "IRsend_test.h"
20#endif
21
22
26 struct {
27 // byte 0-5
28 uint8_t preamble[6]; // unknown, fixed 0x08, 0x10, 0x07, 0x02, 0x40, 0x08
29 // byte 6
30 uint8_t Key1 :4; // key pressed on the remote: 1 power, 2 temp up, 3
31 // temp down...
32 uint8_t Key2 :4; // only set when setting ontime/offtime:
33 // Key1 value is 0x6 (enter key) and Key2 is 0x3 for
34 // "start" and 0x2 for "stop"
35 // byte 7
36 uint8_t Fan :4; // Fan speed: 1 low, 2 mid, 3 max, 8 auto
37 uint8_t Power :1; // main unit power: 1 on, 0 off
38 uint8_t :3;
39 // byte 8
40 uint8_t Mode :4; // 1 heat, 2 cool, 3 dry, 4 fan, 8 auto
41 uint8_t :4;
42 // byte 9
43 uint8_t :2;
44 uint8_t Temp :6; // Degrees Celsius
45 // byte 10
46 uint8_t OffTimer :8; // Power off time: 10s of minutes from now
47 // byte 11
48 uint8_t OnTimer :8; // Power on time: 10s of minutes from now
49 // byte 12
50 uint8_t :8; // unknown, normally 0x00, could be 0x08 when ontime
51 // set, 0x88 if both on and offtime set, 0x60 if
52 // sleep mode set
53 // byte 13
54 uint8_t SwingV :1; // 0 off, 1 on
55 uint8_t :7;
56 // byte 14
57 uint8_t :8; // checksum preamble, fixed 0xEC
58 // byte 15-16
59 uint8_t Chk1 :8; // checksum, algorithm CRC-16/ARC, first byte
60 uint8_t Chk2 :8; // checksum, algorithm CRC-16/ARC, second byte
61 };
62};
63
64// Constants
66 0x08, 0x10, 0x07, 0x02, 0x40, 0x08,
67 0x03, 0x18, 0x01, 0x60, 0x00, 0x00, 0x00, 0x00,
68 0xEC,
69 0xF5, 0xF2}; // Mode "Heat", Fan Speed "auto", Temp: 24, Power: on
70
71// Temperature
72const uint8_t kYorkMinTemp = 18; // Celsius
73const uint8_t kYorkMaxTemp = 32; // Celsius
74// Fan
75const uint8_t kYorkFanLow = 1;
76const uint8_t kYorkFanMedium = 2;
77const uint8_t kYorkFanHigh = 3;
78const uint8_t kYorkFanAuto = 8;
79// Modes
80const uint8_t kYorkHeat = 1;
81const uint8_t kYorkCool = 2;
82const uint8_t kYorkDry = 3;
83const uint8_t kYorkFan = 4;
84const uint8_t kYorkAuto = 8;
85
86// Classes
88class IRYorkAc {
89 public:
90 explicit IRYorkAc(const uint16_t pin, const bool inverted = false,
91 const bool use_modulation = true);
92 void stateReset();
93#if SEND_YORK
94 void send(const uint16_t repeat = kNoRepeat);
99 int8_t calibrate(void) { return _irsend.calibrate(); }
100#endif // SEND_YORK
101 void begin();
102 void setPowerToggle(const bool on);
103 bool getPowerToggle() const;
104 void setTemp(const uint8_t temp);
105 uint8_t getTemp() const;
106 void setFan(const uint8_t speed);
107 uint8_t getFan() const;
108 void setMode(const uint8_t mode);
109 uint8_t getMode() const;
110 uint16_t getOnTimer(void) const;
111 uint16_t getOffTimer(void) const;
112 void setOnTimer(const uint16_t mins);
113 void setOffTimer(const uint16_t mins);
114 uint8_t* getRaw();
115 void setRaw(const uint8_t new_code[],
116 const uint16_t length = kYorkStateLength);
117 static uint8_t convertMode(const stdAc::opmode_t mode);
118 static uint8_t convertFan(const stdAc::fanspeed_t speed);
119 void calcChecksum();
120 static stdAc::opmode_t toCommonMode(const uint8_t mode);
121 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
122 stdAc::state_t toCommon(const stdAc::state_t *prev = NULL) const;
123 String toString() const;
124#ifndef UNIT_TEST
125
126 private:
128#else
130 IRsendTest _irsend;
132#endif
134};
135#endif // IR_YORK_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
const uint16_t kYorkStateLength
Definition IRremoteESP8266.h:1466
Class for handling detailed York A/C messages.
Definition ir_York.h:88
uint8_t getFan() const
Get the current fan speed setting.
Definition ir_York.cpp:209
uint8_t * getRaw()
Get the raw state of the object, suitable to be sent with the appropriate IRsend object method.
Definition ir_York.cpp:119
void setMode(const uint8_t mode)
Set the desired operation mode.
Definition ir_York.cpp:147
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition ir_York.cpp:164
uint16_t getOffTimer(void) const
Get the Off Timer setting of the A/C.
Definition ir_York.cpp:281
YorkProtocol _
Definition ir_York.h:133
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition ir_York.cpp:177
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition ir_York.cpp:216
stdAc::state_t toCommon(const stdAc::state_t *prev=NULL) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition ir_York.cpp:307
void send(const uint16_t repeat=kNoRepeat)
Send the current internal state as an IR message.
Definition ir_York.cpp:134
uint8_t getTemp() const
Get the current temperature setting.
Definition ir_York.cpp:251
uint8_t getMode() const
Get the current operation mode setting.
Definition ir_York.cpp:141
void calcChecksum()
CRC16-16 (a.k.a. CRC-16-IBM)
Definition ir_York.cpp:286
void begin()
Set up hardware to be able to send a message.
Definition ir_York.cpp:114
void setRaw(const uint8_t new_code[], const uint16_t length=kYorkStateLength)
Set the internal state from a valid code for this protocol.
Definition ir_York.cpp:127
void stateReset()
Definition ir_York.cpp:108
void setTemp(const uint8_t temp)
Set the temperature.
Definition ir_York.cpp:245
String toString() const
Convert the current internal state into a human readable string.
Definition ir_York.cpp:341
bool getPowerToggle() const
void setPowerToggle(const bool on)
uint16_t getOnTimer(void) const
Get the On Timer setting of the A/C.
Definition ir_York.cpp:274
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition ir_York.cpp:191
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition ir_York.h:99
void setOnTimer(const uint16_t mins)
Set the On Timer value of the A/C.
Definition ir_York.cpp:259
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition ir_York.cpp:234
IRsend _irsend
Instance of the IR send class.
Definition ir_York.h:127
void setOffTimer(const uint16_t mins)
Set the Off Timer value of the A/C.
Definition ir_York.cpp:267
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 kYorkFanAuto
Definition ir_York.h:78
const uint8_t kYorkHeat
Definition ir_York.h:80
const uint8_t kYorkFanHigh
Definition ir_York.h:77
const uint8_t kYorkCool
Definition ir_York.h:81
const uint8_t kYorkFanLow
Definition ir_York.h:75
const uint8_t kYorkFan
Definition ir_York.h:83
const uint8_t kYorkKnownGoodState[kYorkStateLength]
Definition ir_York.h:65
const uint8_t kYorkDry
Definition ir_York.h:82
const uint8_t kYorkMinTemp
Definition ir_York.h:72
const uint8_t kYorkFanMedium
Definition ir_York.h:76
const uint8_t kYorkAuto
Definition ir_York.h:84
const uint8_t kYorkMaxTemp
Definition ir_York.h:73
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 York A/C message.
Definition ir_York.h:24
uint8_t OffTimer
Definition ir_York.h:46
uint8_t SwingV
Definition ir_York.h:54
uint8_t Fan
Definition ir_York.h:36
uint8_t Chk2
Definition ir_York.h:60
uint8_t OnTimer
Definition ir_York.h:48
uint8_t Key1
Definition ir_York.h:30
uint8_t Key2
Definition ir_York.h:32
uint8_t preamble[6]
Definition ir_York.h:28
uint8_t Temp
Definition ir_York.h:44
uint8_t Mode
Definition ir_York.h:40
uint8_t raw[kYorkStateLength]
The state of the IR remote.
Definition ir_York.h:25
uint8_t Chk1
Definition ir_York.h:59
uint8_t Power
Definition ir_York.h:37