IRremoteESP8266
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#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
24
28 struct {
29 // byte 0-5
30 uint8_t preamble[6]; // unknown, fixed 0x08, 0x10, 0x07, 0x02, 0x40, 0x08
31 // byte 6
32 uint8_t Key1 :4; // key pressed on the remote: 1 power, 2 temp up, 3
33 // temp down...
34 uint8_t Key2 :4; // only set when setting ontime/offtime:
35 // Key1 value is 0x6 (enter key) and Key2 is 0x3 for
36 // "start" and 0x2 for "stop"
37 // byte 7
38 uint8_t Fan :4; // Fan speed: 1 low, 2 mid, 3 max, 8 auto
39 uint8_t Power :1; // main unit power: 1 on, 0 off
40 uint8_t :3;
41 // byte 8
42 uint8_t Mode :4; // 1 heat, 2 cool, 3 dry, 4 fan, 8 auto
43 uint8_t :4;
44 // byte 9
45 uint8_t :2;
46 uint8_t Temp :6; // Degrees Celsius
47 // byte 10
48 uint8_t OffTimer :8; // Power off time: 10s of minutes from now
49 // byte 11
50 uint8_t OnTimer :8; // Power on time: 10s of minutes from now
51 // byte 12
52 uint8_t :8; // unknown, normally 0x00, could be 0x08 when ontime
53 // set, 0x88 if both on and offtime set, 0x60 if
54 // sleep mode set
55 // byte 13
56 uint8_t SwingV :1; // 0 off, 1 on
57 uint8_t :7;
58 // byte 14
59 uint8_t :8; // checksum preamble, fixed 0xEC
60 // byte 15-16
61 uint8_t Chk1 :8; // checksum, algorithm CRC-16/ARC, first byte
62 uint8_t Chk2 :8; // checksum, algorithm CRC-16/ARC, second byte
63 };
64};
65
66// Constants
68 0x08, 0x10, 0x07, 0x02, 0x40, 0x08,
69 0x03, 0x18, 0x01, 0x60, 0x00, 0x00, 0x00, 0x00,
70 0xEC,
71 0xF5, 0xF2}; // Mode "Heat", Fan Speed "auto", Temp: 24, Power: on
72
73// Temperature
74const uint8_t kYorkMinTemp = 18; // Celsius
75const uint8_t kYorkMaxTemp = 32; // Celsius
76// Fan
77const uint8_t kYorkFanLow = 1;
78const uint8_t kYorkFanMedium = 2;
79const uint8_t kYorkFanHigh = 3;
80const uint8_t kYorkFanAuto = 8;
81// Modes
82const uint8_t kYorkHeat = 1;
83const uint8_t kYorkCool = 2;
84const uint8_t kYorkDry = 3;
85const uint8_t kYorkFan = 4;
86const uint8_t kYorkAuto = 8;
87
88// Classes
90class IRYorkAc {
91 public:
92 explicit IRYorkAc(const uint16_t pin, const bool inverted = false,
93 const bool use_modulation = true);
94 void stateReset();
95#if SEND_YORK
96 void send(const uint16_t repeat = kNoRepeat);
101 int8_t calibrate(void) { return _irsend.calibrate(); }
102#endif // SEND_YORK
103 void begin();
104 void setPowerToggle(const bool on);
105 bool getPowerToggle() const;
106 void setTemp(const uint8_t temp);
107 uint8_t getTemp() const;
108 void setFan(const uint8_t speed);
109 uint8_t getFan() const;
110 void setMode(const uint8_t mode);
111 uint8_t getMode() const;
112 uint16_t getOnTimer(void) const;
113 uint16_t getOffTimer(void) const;
114 void setOnTimer(const uint16_t mins);
115 void setOffTimer(const uint16_t mins);
116 uint8_t* getRaw();
117 void setRaw(const uint8_t new_code[],
118 const uint16_t length = kYorkStateLength);
119 static uint8_t convertMode(const stdAc::opmode_t mode);
120 static uint8_t convertFan(const stdAc::fanspeed_t speed);
121 void calcChecksum();
122 static stdAc::opmode_t toCommonMode(const uint8_t mode);
123 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
124 stdAc::state_t toCommon(const stdAc::state_t *prev = NULL) const;
125 String toString() const;
126#ifndef UNIT_TEST
127
128 private:
130#else
132 IRsendTest _irsend;
134#endif
136};
137#endif // IR_YORK_H_
const uint16_t kNoRepeat
Definition IRremoteESP8266.h:1172
const uint16_t kYorkStateLength
Definition IRremoteESP8266.h:1467
std::string String
Definition IRremoteESP8266.h:1564
Class for handling detailed York A/C messages.
Definition ir_York.h:90
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:135
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:101
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:129
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: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 kYorkFanAuto
Definition ir_York.h:80
const uint8_t kYorkHeat
Definition ir_York.h:82
const uint8_t kYorkFanHigh
Definition ir_York.h:79
const uint8_t kYorkCool
Definition ir_York.h:83
const uint8_t kYorkFanLow
Definition ir_York.h:77
const uint8_t kYorkFan
Definition ir_York.h:85
const uint8_t kYorkKnownGoodState[kYorkStateLength]
Definition ir_York.h:67
const uint8_t kYorkDry
Definition ir_York.h:84
const uint8_t kYorkMinTemp
Definition ir_York.h:74
const uint8_t kYorkFanMedium
Definition ir_York.h:78
const uint8_t kYorkAuto
Definition ir_York.h:86
const uint8_t kYorkMaxTemp
Definition ir_York.h:75
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 York A/C message.
Definition ir_York.h:26
uint8_t OffTimer
Definition ir_York.h:48
uint8_t SwingV
Definition ir_York.h:56
uint8_t Fan
Definition ir_York.h:38
uint8_t Chk2
Definition ir_York.h:62
uint8_t OnTimer
Definition ir_York.h:50
uint8_t Key1
Definition ir_York.h:32
uint8_t Key2
Definition ir_York.h:34
uint8_t preamble[6]
Definition ir_York.h:30
uint8_t Temp
Definition ir_York.h:46
uint8_t Mode
Definition ir_York.h:42
uint8_t raw[kYorkStateLength]
The state of the IR remote.
Definition ir_York.h:27
uint8_t Chk1
Definition ir_York.h:61
uint8_t Power
Definition ir_York.h:39