# IRremoteESP8266: src/ir_Kelvinator.h Source File

ir_Kelvinator.h
Go to the documentation of this file.
// Copyright 2016 David Conran
// Supports:
// Brand: Kelvinator, Model: YALIF Remote
// Brand: Kelvinator, Model: KSV26CRC A/C
// Brand: Kelvinator, Model: KSV26HRC A/C
// Brand: Kelvinator, Model: KSV35CRC A/C
// Brand: Kelvinator, Model: KSV35HRC A/C
// Brand: Kelvinator, Model: KSV53HRC A/C
// Brand: Kelvinator, Model: KSV62HRC A/C
// Brand: Kelvinator, Model: KSV70CRC A/C
// Brand: Kelvinator, Model: KSV70HRC A/C
// Brand: Kelvinator, Model: KSV80HRC A/C
// Brand: Green, Model: YAPOF3 remote
// Brand: Sharp, Model: YB1FA remote
#ifndef IR_KELVINATOR_H_
#define IR_KELVINATOR_H_
#define __STDC_LIMIT_MACROS
#include <stdint.h>
#ifndef UNIT_TEST
#include <Arduino.h>
#endif
#include "IRremoteESP8266.h"
#include "IRsend.h"
#ifdef UNIT_TEST
#include "IRsend_test.h"
#endif
union KelvinatorProtocol{
uint8_t raw[kKelvinatorStateLength];
struct {
// Byte 0
uint8_t Mode :3;
uint8_t Power :1;
uint8_t BasicFan :2;
uint8_t VentSwing :1;
uint8_t :1; // Sleep Modes 1 & 3 (1 = On, 0 = Off)
// Byte 1
uint8_t Temp :4; // Degrees C.
uint8_t :4;
// Byte 2
uint8_t :4;
uint8_t Turbo :1;
uint8_t Light :1;
uint8_t IonFilter :1;
uint8_t XFan :1;
// Byte 3
uint8_t :4;
uint8_t :2; // (possibly timer related) (Typically 0b01)
uint8_t :2; // End of command block (B01)
// (B010 marker and a gap of 20ms)
// Byte 4
uint8_t SwingV :1;
uint8_t :3;
uint8_t SwingH :1;
uint8_t :3;
// Byte 5~6
uint8_t pad0[2]; // Timer related. Typically 0 except when timer in use.
// Byte 7
uint8_t :4; // (Used in Timer mode)
uint8_t Sum1 :4; // checksum of the previous bytes (0-6)
// (gap of 40ms)
// (header mark and space)
// Byte 8~10
uint8_t pad1[3]; // Repeat of byte 0~2
// Byte 11
uint8_t :4;
uint8_t :2; // (possibly timer related) (Typically 0b11)
uint8_t :2; // End of command block (B01)
// (B010 marker and a gap of 20ms)
// Byte 12
uint8_t :1; // Sleep mode 2 (1 = On, 0=Off)
uint8_t :6; // (Used in Sleep Mode 3, Typically 0b000000)
uint8_t Quiet :1;
// Byte 13
uint8_t :8; // (Sleep Mode 3 related, Typically 0x00)
// Byte 14
uint8_t :4; // (Sleep Mode 3 related, Typically 0b0000)
uint8_t Fan :3;
// Byte 15
uint8_t :4;
uint8_t Sum2 :4; // checksum of the previous bytes (8-14)
};
};
// Constants
const uint8_t kKelvinatorAuto = 0; // (temp = 25C)
const uint8_t kKelvinatorCool = 1;
const uint8_t kKelvinatorDry = 2; // (temp = 25C, but not shown)
const uint8_t kKelvinatorFan = 3;
const uint8_t kKelvinatorHeat = 4;
const uint8_t kKelvinatorBasicFanMax = 3;
const uint8_t kKelvinatorFanAuto = 0;
const uint8_t kKelvinatorFanMin = 1;
const uint8_t kKelvinatorFanMax = 5;
const uint8_t kKelvinatorMinTemp = 16; // 16C
const uint8_t kKelvinatorMaxTemp = 30; // 30C
const uint8_t kKelvinatorAutoTemp = 25; // 25C
// Legacy defines (Deprecated)
#define KELVINATOR_MIN_TEMP kKelvinatorMinTemp
#define KELVINATOR_MAX_TEMP kKelvinatorMaxTemp
#define KELVINATOR_HEAT kKelvinatorHeat
#define KELVINATOR_FAN_MAX kKelvinatorFanMax
#define KELVINATOR_FAN_AUTO kKelvinatorFanAuto
#define KELVINATOR_FAN kKelvinatorFan
#define KELVINATOR_DRY kKelvinatorDry
#define KELVINATOR_COOL kKelvinatorCool
#define KELVINATOR_BASIC_FAN_MAX kKelvinatorBasicFanMax
#define KELVINATOR_AUTO_TEMP kKelvinatorAutoTemp
#define KELVINATOR_AUTO kKelvinatorAuto
// Classes
class IRKelvinatorAC {
public:
explicit IRKelvinatorAC(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
void stateReset(void);
#if SEND_KELVINATOR
void send(const uint16_t repeat = kKelvinatorDefaultRepeat);
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif // SEND_KELVINATOR
void begin(void);
void on(void);
void off(void);
void setPower(const bool on);
bool getPower(void) const;
void setTemp(const uint8_t degrees);
uint8_t getTemp(void) const;
void setFan(const uint8_t speed);
uint8_t getFan(void) const;
void setMode(const uint8_t mode);
uint8_t getMode(void) const;
void setSwingVertical(const bool on);
bool getSwingVertical(void) const;
void setSwingHorizontal(const bool on);
bool getSwingHorizontal(void) const;
void setQuiet(const bool on);
bool getQuiet(void) const;
void setIonFilter(const bool on);
bool getIonFilter(void) const;
void setLight(const bool on);
bool getLight(void) const;
void setXFan(const bool on);
bool getXFan(void) const;
void setTurbo(const bool on);
bool getTurbo(void) const;
uint8_t* getRaw(void);
void setRaw(const uint8_t new_code[]);
static uint8_t calcBlockChecksum(
const uint8_t* block, const uint16_t length = kKelvinatorStateLength / 2);
static bool validChecksum(const uint8_t state[],
const uint16_t length = kKelvinatorStateLength);
static uint8_t convertMode(const stdAc::opmode_t mode);
static stdAc::opmode_t toCommonMode(const uint8_t mode);
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
stdAc::state_t toCommon(void) const;
String toString(void) const;
#ifndef UNIT_TEST
private:
IRsend _irsend;
#else // UNIT_TEST
IRsendTest _irsend;
#endif // UNIT_TEST
KelvinatorProtocol _;
void checksum(void);
void fixup(void);
};
#endif // IR_KELVINATOR_H_
IRKelvinatorAC::setSwingHorizontal
void setSwingHorizontal(const bool on)
Control the current horizontal swing setting.
Definition: ir_Kelvinator.cpp:292
IRKelvinatorAC::stateReset
void stateReset(void)
Reset the internals of the object to a known good state.
Definition: ir_Kelvinator.cpp:114
IRKelvinatorAC::setTurbo
void setTurbo(const bool on)
Control the current Turbo setting.
Definition: ir_Kelvinator.cpp:358
kKelvinatorFanAuto
const uint8_t kKelvinatorFanAuto
Definition: ir_Kelvinator.h:98
IRKelvinatorAC::on
void on(void)
Set the internal state to have the power on.
Definition: ir_Kelvinator.cpp:196
kKelvinatorFanMax
const uint8_t kKelvinatorFanMax
Definition: ir_Kelvinator.h:100
kKelvinatorCool
const uint8_t kKelvinatorCool
Definition: ir_Kelvinator.h:93
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
IRKelvinatorAC::setLight
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:330
KelvinatorProtocol::IonFilter
uint8_t IonFilter
Definition: ir_Kelvinator.h:50
KelvinatorProtocol::SwingV
uint8_t SwingV
Definition: ir_Kelvinator.h:58
KelvinatorProtocol::pad0
uint8_t pad0[2]
Definition: ir_Kelvinator.h:63
IRKelvinatorAC::toCommonFanSpeed
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:397
kKelvinatorAutoTemp
const uint8_t kKelvinatorAutoTemp
Definition: ir_Kelvinator.h:103
KelvinatorProtocol::VentSwing
uint8_t VentSwing
Definition: ir_Kelvinator.h:41
IRKelvinatorAC::getRaw
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:146
IRsend.h
IRKelvinatorAC::getLight
bool getLight(void) const
Is the Light (Display) setting on?
Definition: ir_Kelvinator.cpp:336
KelvinatorProtocol::XFan
uint8_t XFan
Definition: ir_Kelvinator.h:51
IRKelvinatorAC::setIonFilter
void setIonFilter(const bool on)
Control the current Ion Filter setting.
Definition: ir_Kelvinator.cpp:317
IRKelvinatorAC::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_Kelvinator.cpp:223
IRKelvinatorAC::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Kelvinator.cpp:229
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:182
kKelvinatorMinTemp
const uint8_t kKelvinatorMinTemp
Definition: ir_Kelvinator.h:101
IRKelvinatorAC::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Kelvinator.h:131
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
String
std::string String
Definition: IRremoteESP8266.h:1178
IRKelvinatorAC::getSwingHorizontal
bool getSwingHorizontal(void) const
Is the horizontal swing setting on?
Definition: ir_Kelvinator.cpp:299
IRKelvinatorAC::setPower
void setPower(const bool on)
Set the internal state to have the desired power.
Definition: ir_Kelvinator.cpp:203
IRKelvinatorAC::setMode
void setMode(const uint8_t mode)
Set the desired operation mode.
Definition: ir_Kelvinator.cpp:257
IRKelvinatorAC::send
void send(const uint16_t repeat=kKelvinatorDefaultRepeat)
Send the current internal state as an IR message.
Definition: ir_Kelvinator.cpp:138
IRKelvinatorAC::setRaw
void setRaw(const uint8_t new_code[])
Set the raw state of the object.
Definition: ir_Kelvinator.cpp:153
IRKelvinatorAC::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Kelvinator.cpp:121
IRKelvinatorAC::calcBlockChecksum
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:162
KelvinatorProtocol::Power
uint8_t Power
Definition: ir_Kelvinator.h:39
IRremoteESP8266.h
IRKelvinatorAC::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Kelvinator.h:172
KelvinatorProtocol::Light
uint8_t Light
Definition: ir_Kelvinator.h:49
KelvinatorProtocol::raw
uint8_t raw[kKelvinatorStateLength]
The state in IR code form.
Definition: ir_Kelvinator.h:35
IRKelvinatorAC::getPower
bool getPower(void) const
Get the power setting from the internal state.
Definition: ir_Kelvinator.cpp:209
IRKelvinatorAC::validChecksum
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:184
IRKelvinatorAC
Class for handling detailed Kelvinator A/C messages.
Definition: ir_Kelvinator.h:120
kKelvinatorMaxTemp
const uint8_t kKelvinatorMaxTemp
Definition: ir_Kelvinator.h:102
IRKelvinatorAC::getSwingVertical
bool getSwingVertical(void) const
Is the vertical swing setting on?
Definition: ir_Kelvinator.cpp:286
KelvinatorProtocol::Mode
uint8_t Mode
Definition: ir_Kelvinator.h:38
KelvinatorProtocol::Sum1
uint8_t Sum1
Definition: ir_Kelvinator.h:66
IRKelvinatorAC::checksum
void checksum(void)
Calculate the checksum for the internal state.
Definition: ir_Kelvinator.cpp:175
IRKelvinatorAC::fixup
void fixup(void)
Fix up any odd conditions for the current state.
Definition: ir_Kelvinator.cpp:124
KelvinatorProtocol::pad1
uint8_t pad1[3]
Definition: ir_Kelvinator.h:70
kKelvinatorStateLength
const uint16_t kKelvinatorStateLength
Definition: IRremoteESP8266.h:979
IRKelvinatorAC::toCommon
stdAc::state_t toCommon(void) const
Convert the internal A/C object state to it's stdAc::state_t equivalent.
Definition: ir_Kelvinator.cpp:403
IRKelvinatorAC::setQuiet
void setQuiet(const bool on)
Control the current Quiet setting.
Definition: ir_Kelvinator.cpp:305
IRKelvinatorAC::setXFan
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:345
KelvinatorProtocol::SwingH
uint8_t SwingH
Definition: ir_Kelvinator.h:60
kKelvinatorFan
const uint8_t kKelvinatorFan
Definition: ir_Kelvinator.h:95
IRKelvinatorAC::toString
String toString(void) const
Convert the internal settings into a human readable string.
Definition: ir_Kelvinator.cpp:429
IRKelvinatorAC::setTemp
void setTemp(const uint8_t degrees)
Set the temperature setting.
Definition: ir_Kelvinator.cpp:215
KelvinatorProtocol::Sum2
uint8_t Sum2
Definition: ir_Kelvinator.h:87
kKelvinatorBasicFanMax
const uint8_t kKelvinatorBasicFanMax
Definition: ir_Kelvinator.h:97
kKelvinatorFanMin
const uint8_t kKelvinatorFanMin
Definition: ir_Kelvinator.h:99
IRKelvinatorAC::getTurbo
bool getTurbo(void) const
Is the Turbo setting on?
Definition: ir_Kelvinator.cpp:364
IRKelvinatorAC::_
KelvinatorProtocol _
Definition: ir_Kelvinator.h:178
IRKelvinatorAC::getMode
uint8_t getMode(void) const
Get the current operation mode setting.
Definition: ir_Kelvinator.cpp:251
KelvinatorProtocol::BasicFan
uint8_t BasicFan
Definition: ir_Kelvinator.h:40
kKelvinatorHeat
const uint8_t kKelvinatorHeat
Definition: ir_Kelvinator.h:96
IRKelvinatorAC::getQuiet
bool getQuiet(void) const
Is the Quiet setting on?
Definition: ir_Kelvinator.cpp:311
IRKelvinatorAC::IRKelvinatorAC
IRKelvinatorAC(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Kelvinator.cpp:109
IRKelvinatorAC::off
void off(void)
Set the internal state to have the power off.
Definition: ir_Kelvinator.cpp:199
kKelvinatorDefaultRepeat
const uint16_t kKelvinatorDefaultRepeat
Definition: IRremoteESP8266.h:981
IRKelvinatorAC::setSwingVertical
void setSwingVertical(const bool on)
Control the current vertical swing setting.
Definition: ir_Kelvinator.cpp:279
IRKelvinatorAC::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_Kelvinator.cpp:245
kKelvinatorDry
const uint8_t kKelvinatorDry
Definition: ir_Kelvinator.h:94
KelvinatorProtocol::Quiet
uint8_t Quiet
Definition: ir_Kelvinator.h:79
IRKelvinatorAC::getXFan
bool getXFan(void) const
Is the XFan setting on?
Definition: ir_Kelvinator.cpp:351
KelvinatorProtocol
Native representation of a Kelvinator A/C message.
Definition: ir_Kelvinator.h:34
IRKelvinatorAC::getIonFilter
bool getIonFilter(void) const
Is the Ion Filter setting on?
Definition: ir_Kelvinator.cpp:323
IRKelvinatorAC::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode to it's stdAc::opmode_t equivalent.
Definition: ir_Kelvinator.cpp:384
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
KelvinatorProtocol::Turbo
uint8_t Turbo
Definition: ir_Kelvinator.h:48
KelvinatorProtocol::Temp
uint8_t Temp
Definition: ir_Kelvinator.h:44
KelvinatorProtocol::Fan
uint8_t Fan
Definition: ir_Kelvinator.h:84
kKelvinatorAuto
const uint8_t kKelvinatorAuto
Definition: ir_Kelvinator.h:92
IRKelvinatorAC::convertMode
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:371
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46