IRremoteESP8266
Loading...
Searching...
No Matches
ir_Goodweather.h
Go to the documentation of this file.
1// Copyright 2019 ribeirodanielf
2// Copyright 2019 David Conran
3
7
8// Supports:
9// Brand: Goodweather, Model: ZH/JT-03 remote
10
11#ifndef IR_GOODWEATHER_H_
12#define IR_GOODWEATHER_H_
13
14#define __STDC_LIMIT_MACROS
15#include <stdint.h>
16#ifndef UNIT_TEST
17#include <Arduino.h>
18#endif
19#include "IRremoteESP8266.h"
20#include "IRsend.h"
21#ifdef UNIT_TEST
22#include "IRsend_test.h"
23#endif
24
27 uint64_t raw;
28 struct {
29 // Byte 0
30 uint8_t :8;
31 // Byte 1
32 uint8_t Light :1;
33 uint8_t :2;
34 uint8_t Turbo :1;
35 uint8_t :0;
36 // Byte 2
37 uint8_t Command :4;
38 uint8_t :0;
39 // Byte 3
40 uint8_t Sleep :1;
41 uint8_t Power :1;
42 uint8_t Swing :2;
43 uint8_t AirFlow :1;
44 uint8_t Fan :2;
45 uint8_t :0;
46 // Byte 4
47 uint8_t Temp :4;
48 uint8_t :1;
49 uint8_t Mode :3;
50 uint8_t :0;
51 };
52};
53
54// Constants
55// Timing
56const uint16_t kGoodweatherBitMark = 580;
57const uint16_t kGoodweatherOneSpace = 580;
58const uint16_t kGoodweatherZeroSpace = 1860;
59const uint16_t kGoodweatherHdrMark = 6820;
60const uint16_t kGoodweatherHdrSpace = 6820;
61const uint8_t kGoodweatherExtraTolerance = 12; // +12% extra
62
63// Modes
64const uint8_t kGoodweatherAuto = 0b000;
65const uint8_t kGoodweatherCool = 0b001;
66const uint8_t kGoodweatherDry = 0b010;
67const uint8_t kGoodweatherFan = 0b011;
68const uint8_t kGoodweatherHeat = 0b100;
69// Swing
70const uint8_t kGoodweatherSwingFast = 0b00;
71const uint8_t kGoodweatherSwingSlow = 0b01;
72const uint8_t kGoodweatherSwingOff = 0b10;
73// Fan Control
74const uint8_t kGoodweatherFanAuto = 0b00;
75const uint8_t kGoodweatherFanHigh = 0b01;
76const uint8_t kGoodweatherFanMed = 0b10;
77const uint8_t kGoodweatherFanLow = 0b11;
78// Temperature
79const uint8_t kGoodweatherTempMin = 16; // Celsius
80const uint8_t kGoodweatherTempMax = 31; // Celsius
81// Commands
82const uint8_t kGoodweatherCmdPower = 0x00;
83const uint8_t kGoodweatherCmdMode = 0x01;
84const uint8_t kGoodweatherCmdUpTemp = 0x02;
85const uint8_t kGoodweatherCmdDownTemp = 0x03;
86const uint8_t kGoodweatherCmdSwing = 0x04;
87const uint8_t kGoodweatherCmdFan = 0x05;
88const uint8_t kGoodweatherCmdTimer = 0x06;
89const uint8_t kGoodweatherCmdAirFlow = 0x07;
90const uint8_t kGoodweatherCmdHold = 0x08;
91const uint8_t kGoodweatherCmdSleep = 0x09;
92const uint8_t kGoodweatherCmdTurbo = 0x0A;
93const uint8_t kGoodweatherCmdLight = 0x0B;
94// PAD EOF
95const uint64_t kGoodweatherStateInit = 0xD50000000000;
96
97
98// Classes
101 public:
102 explicit IRGoodweatherAc(const uint16_t pin, const bool inverted = false,
103 const bool use_modulation = true);
104 void stateReset(void);
105#if SEND_GOODWEATHER
106 void send(const uint16_t repeat = kGoodweatherMinRepeat);
111 int8_t calibrate(void) { return _irsend.calibrate(); }
112#endif // SEND_GOODWEATHER
113 void begin(void);
114 void on(void);
115 void off(void);
116 void setPower(const bool on);
117 bool getPower(void) const;
118 void setTemp(const uint8_t temp);
119 uint8_t getTemp(void) const;
120 void setFan(const uint8_t speed);
121 uint8_t getFan(void) const;
122 void setMode(const uint8_t mode);
123 uint8_t getMode(void) const;
124 void setSwing(const uint8_t speed);
125 uint8_t getSwing(void) const;
126 void setSleep(const bool toggle);
127 bool getSleep(void) const;
128 void setTurbo(const bool toggle);
129 bool getTurbo(void) const;
130 void setLight(const bool toggle);
131 bool getLight(void) const;
132 void setCommand(const uint8_t cmd);
133 uint8_t getCommand(void) const;
134 uint64_t getRaw(void);
135 void setRaw(const uint64_t state);
136 static uint8_t convertMode(const stdAc::opmode_t mode);
137 static uint8_t convertFan(const stdAc::fanspeed_t speed);
138 static uint8_t convertSwingV(const stdAc::swingv_t swingv);
139 static stdAc::opmode_t toCommonMode(const uint8_t mode);
140 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
141 stdAc::state_t toCommon(void) const;
142 String toString(void) const;
143#ifndef UNIT_TEST
144
145 private:
147#else // UNIT_TEST
149 IRsendTest _irsend;
151#endif // UNIT_TEST
153};
154#endif // IR_GOODWEATHER_H_
const uint16_t kGoodweatherMinRepeat
Definition IRremoteESP8266.h:1276
std::string String
Definition IRremoteESP8266.h:1564
Class for handling detailed Goodweather A/C messages.
Definition ir_Goodweather.h:100
bool getSleep(void) const
Get the Sleep Toggle setting of the A/C.
Definition ir_Goodweather.cpp:193
void on(void)
Change the power setting to On.
Definition ir_Goodweather.cpp:92
uint8_t getTemp(void) const
Get the current temperature setting.
Definition ir_Goodweather.cpp:122
void setRaw(const uint64_t state)
Set the internal state from a valid code for this protocol.
Definition ir_Goodweather.cpp:89
bool getTurbo(void) const
Get the Turbo Toggle setting of the A/C.
Definition ir_Goodweather.cpp:206
void setSleep(const bool toggle)
Set the Sleep Toggle setting of the A/C.
Definition ir_Goodweather.cpp:186
GoodweatherProtocol _
Definition ir_Goodweather.h:152
static uint8_t convertSwingV(const stdAc::swingv_t swingv)
Convert a stdAc::swingv_t enum into it's native setting.
Definition ir_Goodweather.cpp:274
void setLight(const bool toggle)
Set the Light (LED) Toggle setting of the A/C.
Definition ir_Goodweather.cpp:173
uint8_t getSwing(void) const
Get the Vertical Swing speed of the A/C.
Definition ir_Goodweather.cpp:227
void setSwing(const uint8_t speed)
Set the Vertical Swing speed of the A/C.
Definition ir_Goodweather.cpp:212
void setCommand(const uint8_t cmd)
Set the remote Command type/button pressed.
Definition ir_Goodweather.cpp:233
uint8_t getFan(void) const
Get the current fan speed setting.
Definition ir_Goodweather.cpp:144
void setTurbo(const bool toggle)
Set the Turbo Toggle setting of the A/C.
Definition ir_Goodweather.cpp:199
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition ir_Goodweather.cpp:167
uint64_t getRaw(void)
Get a copy of the internal state as a valid code for this protocol.
Definition ir_Goodweather.cpp:85
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition ir_Goodweather.h:111
void setTemp(const uint8_t temp)
Set the temperature.
Definition ir_Goodweather.cpp:112
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition ir_Goodweather.cpp:150
String toString(void) const
Convert the current internal state into a human readable string.
Definition ir_Goodweather.cpp:340
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition ir_Goodweather.cpp:289
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition ir_Goodweather.cpp:313
void begin(void)
Set up hardware to be able to send a message.
Definition ir_Goodweather.cpp:73
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition ir_Goodweather.cpp:260
void send(const uint16_t repeat=kGoodweatherMinRepeat)
Send the current internal state as an IR message.
Definition ir_Goodweather.cpp:78
bool getPower(void) const
Get the value of the current power setting.
Definition ir_Goodweather.cpp:106
uint8_t getCommand(void) const
Get the Command type/button pressed from the current settings.
Definition ir_Goodweather.cpp:240
void setPower(const bool on)
Change the power setting.
Definition ir_Goodweather.cpp:99
IRsend _irsend
Instance of the IR send class.
Definition ir_Goodweather.h:146
void off(void)
Change the power setting to Off.
Definition ir_Goodweather.cpp:95
bool getLight(void) const
Get the Light (LED) Toggle setting of the A/C.
Definition ir_Goodweather.cpp:180
void stateReset(void)
Reset the internal state to a fixed known good state.
Definition ir_Goodweather.cpp:70
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition ir_Goodweather.cpp:247
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition ir_Goodweather.cpp:128
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition ir_Goodweather.cpp:302
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 kGoodweatherHeat
Definition ir_Goodweather.h:68
const uint8_t kGoodweatherSwingFast
Definition ir_Goodweather.h:70
const uint8_t kGoodweatherAuto
Definition ir_Goodweather.h:64
const uint8_t kGoodweatherCmdPower
Definition ir_Goodweather.h:82
const uint8_t kGoodweatherCmdSleep
Definition ir_Goodweather.h:91
const uint16_t kGoodweatherZeroSpace
Definition ir_Goodweather.h:58
const uint8_t kGoodweatherCmdFan
Definition ir_Goodweather.h:87
const uint8_t kGoodweatherFanMed
Definition ir_Goodweather.h:76
const uint8_t kGoodweatherCmdUpTemp
Definition ir_Goodweather.h:84
const uint16_t kGoodweatherHdrMark
Definition ir_Goodweather.h:59
const uint64_t kGoodweatherStateInit
Definition ir_Goodweather.h:95
const uint8_t kGoodweatherCmdMode
Definition ir_Goodweather.h:83
const uint8_t kGoodweatherFanLow
Definition ir_Goodweather.h:77
const uint16_t kGoodweatherHdrSpace
Definition ir_Goodweather.h:60
const uint8_t kGoodweatherCmdDownTemp
Definition ir_Goodweather.h:85
const uint8_t kGoodweatherTempMin
Definition ir_Goodweather.h:79
const uint16_t kGoodweatherOneSpace
Definition ir_Goodweather.h:57
const uint8_t kGoodweatherCool
Definition ir_Goodweather.h:65
const uint8_t kGoodweatherFanAuto
Definition ir_Goodweather.h:74
const uint8_t kGoodweatherSwingOff
Definition ir_Goodweather.h:72
const uint8_t kGoodweatherCmdAirFlow
Definition ir_Goodweather.h:89
const uint8_t kGoodweatherExtraTolerance
Definition ir_Goodweather.h:61
const uint8_t kGoodweatherCmdSwing
Definition ir_Goodweather.h:86
const uint8_t kGoodweatherTempMax
Definition ir_Goodweather.h:80
const uint8_t kGoodweatherCmdHold
Definition ir_Goodweather.h:90
const uint8_t kGoodweatherDry
Definition ir_Goodweather.h:66
const uint16_t kGoodweatherBitMark
Definition ir_Goodweather.h:56
const uint8_t kGoodweatherSwingSlow
Definition ir_Goodweather.h:71
const uint8_t kGoodweatherCmdTimer
Definition ir_Goodweather.h:88
const uint8_t kGoodweatherFan
Definition ir_Goodweather.h:67
const uint8_t kGoodweatherCmdLight
Definition ir_Goodweather.h:93
const uint8_t kGoodweatherCmdTurbo
Definition ir_Goodweather.h:92
const uint8_t kGoodweatherFanHigh
Definition ir_Goodweather.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
swingv_t
Common A/C settings for Vertical Swing.
Definition IRsend.h:74
Structure to hold a common A/C state.
Definition IRsend.h:114
Native representation of a Goodweather A/C message.
Definition ir_Goodweather.h:26
uint8_t Turbo
Definition ir_Goodweather.h:34
uint8_t Swing
Definition ir_Goodweather.h:42
uint8_t Mode
Definition ir_Goodweather.h:49
uint8_t Temp
Definition ir_Goodweather.h:47
uint8_t AirFlow
Definition ir_Goodweather.h:43
uint8_t Fan
Definition ir_Goodweather.h:44
uint8_t Light
Definition ir_Goodweather.h:32
uint8_t Sleep
Definition ir_Goodweather.h:40
uint8_t Power
Definition ir_Goodweather.h:41
uint8_t Command
Definition ir_Goodweather.h:37
uint64_t raw
The state of the IR remote in IR code form.
Definition ir_Goodweather.h:27