# IRremoteESP8266: src/ir_Vestel.h Source File

ir_Vestel.h
Go to the documentation of this file.
// Copyright 2018 Erdem U. Altinyurt
// Copyright 2019 David Conran
// Supports:
// Brand: Vestel, Model: BIOX CXP-9 A/C (9K BTU)
#ifndef IR_VESTEL_H_
#define IR_VESTEL_H_
#define __STDC_LIMIT_MACROS
#include <stdint.h>
#ifdef ARDUINO
#include <Arduino.h>
#endif
#include "IRremoteESP8266.h"
#include "IRsend.h"
#ifdef UNIT_TEST
#include "IRsend_test.h"
#endif
// Structure of a Command message (56 bits)
// Signature: 12 bits. e.g. 0x201
// Checksum: 8 bits
// Swing: 4 bits. (auto 0xA, stop 0xF)
// turbo_sleep_normal: 4bits. (normal 0x1, sleep 0x3, turbo 0x7)
// Unused: 8 bits. (0x00)
// Temperature: 4 bits. (Celsius, but offset by -16 degrees. e.g. 0x0 = 16C)
// Fan Speed: 4 bits (auto 0x1, low 0x5, mid 0x9, high 0xB, 0xD auto hot,
// 0xC auto cool)
// Mode: 3 bits. (auto 0x0, cold 0x1, dry 0x2, fan 0x3, hot 0x4)
// unknown/unused: 6 bits.
// Ion flag: 1 bit.
// unknown/unused: 1 bit.
// Power/message type: 4 bits. (on 0xF, off 0xC, 0x0 == Timer mesage)
//
// Structure of a Time(r) message (56 bits)
// Signature: 12 bits. e.g. 0x201
// Checksum: 8 bits
// Off Minutes: 3 bits. (Stored in 10 min increments. eg. xx:20 is 0x2)
// Off Hours: 5 bits. (0x17 == 11PM / 23:00)
// On Minutes: 3 bits. (Stored in 10 min increments. eg. xx:20 is 0x2)
// On Hours: 5 bits. (0x9 == 9AM / 09:00)
// Clock Hours: 5 bits.
// On Timer flag: 1 bit.
// Off Timer flag: 1 bit.
// Timer mode flag: 1 bit. (Off after X many hours/mins, not at clock time.)
// Clock Minutes: 8 bits. (0-59)
// Power/message type: 4 bits. (0x0 == Timer mesage, else see Comman message)
// Constants
const uint16_t kVestelAcHdrMark = 3110;
const uint16_t kVestelAcHdrSpace = 9066;
const uint16_t kVestelAcBitMark = 520;
const uint16_t kVestelAcOneSpace = 1535;
const uint16_t kVestelAcZeroSpace = 480;
const uint16_t kVestelAcTolerance = 30;
const uint8_t kVestelAcMinTempH = 16;
const uint8_t kVestelAcMinTempC = 18;
const uint8_t kVestelAcMaxTemp = 30;
const uint8_t kVestelAcAuto = 0;
const uint8_t kVestelAcCool = 1;
const uint8_t kVestelAcDry = 2;
const uint8_t kVestelAcFan = 3;
const uint8_t kVestelAcHeat = 4;
const uint8_t kVestelAcFanAuto = 1;
const uint8_t kVestelAcFanLow = 5;
const uint8_t kVestelAcFanMed = 9;
const uint8_t kVestelAcFanHigh = 0xB;
const uint8_t kVestelAcFanAutoCool = 0xC;
const uint8_t kVestelAcFanAutoHot = 0xD;
const uint8_t kVestelAcNormal = 1;
const uint8_t kVestelAcSleep = 3;
const uint8_t kVestelAcTurbo = 7;
const uint8_t kVestelAcIon = 4;
const uint8_t kVestelAcSwing = 0xA;
const uint8_t kVestelAcChecksumOffset = 12;
const uint8_t kVestelAcChecksumSize = 8; // Nr. of bits
const uint8_t kVestelAcSwingOffset = 20;
const uint8_t kVestelAcTurboSleepOffset = 24;
const uint8_t kVestelAcTempOffset = 36;
const uint8_t kVestelAcFanOffset = 40;
const uint8_t kVestelAcFanSize = 4; // Nr. of bits
const uint8_t kVestelAcModeOffset = 44;
const uint8_t kVestelAcIonOffset = 50;
const uint8_t kVestelAcPowerOffset = 52;
const uint8_t kVestelAcPowerSize = 2; // Nr. of bits
const uint8_t kVestelAcOffTimeOffset = 20;
const uint8_t kVestelAcOnTimeOffset = 28;
const uint8_t kVestelAcTimerHourSize = 5; // Nr. of bits
const uint8_t kVestelAcTimerMinsSize = 3; // Nr. of bits
const uint8_t kVestelAcTimerSize = kVestelAcTimerHourSize +
kVestelAcTimerMinsSize; // Nr. of bits
const uint8_t kVestelAcHourOffset = 36; // 5 bits
const uint8_t kVestelAcHourSize = 5; // Nr. of bits
const uint8_t kVestelAcOnTimerFlagOffset = kVestelAcHourOffset + 5;
const uint8_t kVestelAcOffTimerFlagOffset = kVestelAcHourOffset + 6;
const uint8_t kVestelAcTimerFlagOffset = kVestelAcHourOffset + 7;
const uint8_t kVestelAcMinuteOffset = 44;
const uint8_t kVestelAcMinuteSize = 8; // Nr. of bits
// Default states
const uint64_t kVestelAcStateDefault = 0x0F00D9001FEF201ULL;
const uint64_t kVestelAcTimeStateDefault = 0x201ULL;
// Classes
class IRVestelAc {
public:
explicit IRVestelAc(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
void stateReset(void);
#if SEND_VESTEL_AC
void send(const uint16_t repeat = kNoRepeat);
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif // SEND_VESTEL_AC
void begin(void);
void on(void);
void off(void);
void setPower(const bool on);
bool getPower(void);
void setAuto(const int8_t autoLevel);
void setTimer(const uint16_t minutes);
uint16_t getTimer(void);
void setTime(const uint16_t minutes);
uint16_t getTime(void);
void setOnTimer(const uint16_t minutes);
uint16_t getOnTimer(void);
void setOffTimer(const uint16_t minutes);
uint16_t getOffTimer(void);
void setTemp(const uint8_t temp);
uint8_t getTemp(void);
void setFan(const uint8_t fan);
uint8_t getFan(void);
void setMode(const uint8_t mode);
uint8_t getMode(void);
void setRaw(const uint8_t* newState);
void setRaw(const uint64_t newState);
uint64_t getRaw(void);
static bool validChecksum(const uint64_t state);
void setSwing(const bool on);
bool getSwing(void);
void setSleep(const bool on);
bool getSleep(void);
void setTurbo(const bool on);
bool getTurbo(void);
void setIon(const bool on);
bool getIon(void);
bool isTimeCommand(void);
bool isOnTimerActive(void);
void setOnTimerActive(const bool on);
bool isOffTimerActive(void);
void setOffTimerActive(const bool on);
bool isTimerActive(void);
void setTimerActive(const bool on);
static uint8_t calcChecksum(const uint64_t state);
static uint8_t convertMode(const stdAc::opmode_t mode);
static uint8_t convertFan(const stdAc::fanspeed_t speed);
static stdAc::opmode_t toCommonMode(const uint8_t mode);
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
stdAc::state_t toCommon(void);
String toString(void);
#ifndef UNIT_TEST
private:
IRsend _irsend;
#else // UNIT_TEST
IRsendTest _irsend;
#endif // UNIT_TEST
uint64_t remote_state;
uint64_t remote_time_state;
bool use_time_state;
void checksum(void);
void _setTimer(const uint16_t minutes, const uint8_t offset);
uint16_t _getTimer(const uint8_t offset);
};
#endif // IR_VESTEL_H_
kVestelAcHdrSpace
const uint16_t kVestelAcHdrSpace
Definition: ir_Vestel.h:57
kVestelAcOffTimeOffset
const uint8_t kVestelAcOffTimeOffset
Definition: ir_Vestel.h:97
kVestelAcFanAutoHot
const uint8_t kVestelAcFanAutoHot
Definition: ir_Vestel.h:78
IRVestelAc::stateReset
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition: ir_Vestel.cpp:60
IRVestelAc::getOffTimer
uint16_t getOffTimer(void)
Get the A/C's Off Timer time.
Definition: ir_Vestel.cpp:330
kVestelAcTimerHourSize
const uint8_t kVestelAcTimerHourSize
Definition: ir_Vestel.h:99
IRVestelAc::toCommon
stdAc::state_t toCommon(void)
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Vestel.cpp:478
IRVestelAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Vestel.cpp:67
IRVestelAc::setFan
void setFan(const uint8_t fan)
Set the speed of the fan.
Definition: ir_Vestel.cpp:147
kVestelAcHourSize
const uint8_t kVestelAcHourSize
Definition: ir_Vestel.h:104
kVestelAcFanOffset
const uint8_t kVestelAcFanOffset
Definition: ir_Vestel.h:91
IRVestelAc::setTemp
void setTemp(const uint8_t temp)
Set the temperature.
Definition: ir_Vestel.cpp:130
IRVestelAc::setOffTimerActive
void setOffTimerActive(const bool on)
Set the Off timer to be active on the A/C.
Definition: ir_Vestel.cpp:310
IRVestelAc::setTime
void setTime(const uint16_t minutes)
Set the A/C's internal clock.
Definition: ir_Vestel.cpp:247
kVestelAcMaxTemp
const uint8_t kVestelAcMaxTemp
Definition: ir_Vestel.h:65
IRVestelAc::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Vestel.cpp:116
IRVestelAc::isTimeCommand
bool isTimeCommand(void)
Is the current state a time command?
Definition: ir_Vestel.cpp:419
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
kVestelAcSleep
const uint8_t kVestelAcSleep
Definition: ir_Vestel.h:81
IRVestelAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Vestel.h:127
kVestelAcDry
const uint8_t kVestelAcDry
Definition: ir_Vestel.h:69
kVestelAcBitMark
const uint16_t kVestelAcBitMark
Definition: ir_Vestel.h:58
kVestelAcAuto
const uint8_t kVestelAcAuto
Definition: ir_Vestel.h:67
kVestelAcFanMed
const uint8_t kVestelAcFanMed
Definition: ir_Vestel.h:75
IRVestelAc::setTurbo
void setTurbo(const bool on)
Set the Turbo setting of the A/C.
Definition: ir_Vestel.cpp:351
IRVestelAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Vestel.h:178
IRVestelAc::setTimer
void setTimer(const uint16_t minutes)
Set Timer option of A/C.
Definition: ir_Vestel.cpp:228
IRVestelAc::on
void on(void)
Set the requested power state of the A/C to on.
Definition: ir_Vestel.cpp:109
IRVestelAc::_getTimer
uint16_t _getTimer(const uint8_t offset)
Get the number of minutes a timer is set for.
Definition: ir_Vestel.cpp:289
IRVestelAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Vestel.cpp:178
IRsend.h
IRVestelAc::isOffTimerActive
bool isOffTimerActive(void)
Get if the Off Timer is active on the A/C.
Definition: ir_Vestel.cpp:317
kVestelAcMinuteSize
const uint8_t kVestelAcMinuteSize
Definition: ir_Vestel.h:109
kVestelAcMinTempC
const uint8_t kVestelAcMinTempC
Definition: ir_Vestel.h:64
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:182
kVestelAcChecksumSize
const uint8_t kVestelAcChecksumSize
Definition: ir_Vestel.h:87
IRVestelAc::getTimer
uint16_t getTimer(void)
Get the Timer time of A/C.
Definition: ir_Vestel.cpp:243
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
kVestelAcFanSize
const uint8_t kVestelAcFanSize
Definition: ir_Vestel.h:92
kVestelAcSwingOffset
const uint8_t kVestelAcSwingOffset
Definition: ir_Vestel.h:88
IRVestelAc::isOnTimerActive
bool isOnTimerActive(void)
Get if the On Timer is active on the A/C.
Definition: ir_Vestel.cpp:272
String
std::string String
Definition: IRremoteESP8266.h:1178
kVestelAcTimerFlagOffset
const uint8_t kVestelAcTimerFlagOffset
Definition: ir_Vestel.h:107
IRVestelAc::isTimerActive
bool isTimerActive(void)
Get if the Timer is active on the A/C.
Definition: ir_Vestel.cpp:220
IRVestelAc::setRaw
void setRaw(const uint8_t *newState)
Set the internal state from a valid code for this protocol.
Definition: ir_Vestel.cpp:87
kVestelAcFan
const uint8_t kVestelAcFan
Definition: ir_Vestel.h:70
IRremoteESP8266.h
kVestelAcMinTempH
const uint8_t kVestelAcMinTempH
Definition: ir_Vestel.h:63
IRVestelAc::getTemp
uint8_t getTemp(void)
Get the current temperature setting.
Definition: ir_Vestel.cpp:140
kVestelAcHdrMark
const uint16_t kVestelAcHdrMark
Definition: ir_Vestel.h:56
kNoRepeat
const uint16_t kNoRepeat
Definition: IRremoteESP8266.h:875
IRVestelAc::remote_time_state
uint64_t remote_time_state
The time state of the remote in code form.
Definition: ir_Vestel.h:185
kVestelAcOnTimerFlagOffset
const uint8_t kVestelAcOnTimerFlagOffset
Definition: ir_Vestel.h:105
IRVestelAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Vestel.cpp:454
IRVestelAc::remote_state
uint64_t remote_state
The state of the IR remote in IR code form.
Definition: ir_Vestel.h:184
IRVestelAc::getSleep
bool getSleep(void)
Get the Sleep setting of the A/C.
Definition: ir_Vestel.cpp:344
kVestelAcOneSpace
const uint16_t kVestelAcOneSpace
Definition: ir_Vestel.h:59
IRVestelAc::checksum
void checksum(void)
Calculate & set the checksum for the current internal state of the remote.
Definition: ir_Vestel.cpp:409
IRVestelAc::setSwing
void setSwing(const bool on)
Set the Swing Roaming setting of the A/C.
Definition: ir_Vestel.cpp:379
IRVestelAc::getTurbo
bool getTurbo(void)
Get the Turbo setting of the A/C.
Definition: ir_Vestel.cpp:359
kVestelAcTempOffset
const uint8_t kVestelAcTempOffset
Definition: ir_Vestel.h:90
IRVestelAc::setOffTimer
void setOffTimer(const uint16_t minutes)
Set the Off timer time on the A/C.
Definition: ir_Vestel.cpp:323
kVestelAcTimerMinsSize
const uint8_t kVestelAcTimerMinsSize
Definition: ir_Vestel.h:100
IRVestelAc::setOnTimerActive
void setOnTimerActive(const bool on)
Set the On timer to be active on the A/C.
Definition: ir_Vestel.cpp:265
kVestelAcHourOffset
const uint8_t kVestelAcHourOffset
Definition: ir_Vestel.h:103
IRVestelAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Vestel.cpp:467
IRVestelAc::send
void send(const uint16_t repeat=kNoRepeat)
Send the current internal state as an IR message.
Definition: ir_Vestel.cpp:72
IRVestelAc::off
void off(void)
Set the requested power state of the A/C to off.
Definition: ir_Vestel.cpp:112
kVestelAcFanAutoCool
const uint8_t kVestelAcFanAutoCool
Definition: ir_Vestel.h:77
kVestelAcStateDefault
const uint64_t kVestelAcStateDefault
Definition: ir_Vestel.h:111
IRVestelAc::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Vestel.cpp:427
IRVestelAc::setIon
void setIon(const bool on)
Set the Ion (Filter) setting of the A/C.
Definition: ir_Vestel.cpp:366
IRVestelAc::toString
String toString(void)
Convert the current internal state into a human readable string.
Definition: ir_Vestel.cpp:505
kVestelAcTolerance
const uint16_t kVestelAcTolerance
Definition: ir_Vestel.h:61
kVestelAcFanLow
const uint8_t kVestelAcFanLow
Definition: ir_Vestel.h:74
kVestelAcChecksumOffset
const uint8_t kVestelAcChecksumOffset
Definition: ir_Vestel.h:86
kVestelAcPowerSize
const uint8_t kVestelAcPowerSize
Definition: ir_Vestel.h:96
kVestelAcSwing
const uint8_t kVestelAcSwing
Definition: ir_Vestel.h:84
kVestelAcIonOffset
const uint8_t kVestelAcIonOffset
Definition: ir_Vestel.h:94
kVestelAcOnTimeOffset
const uint8_t kVestelAcOnTimeOffset
Definition: ir_Vestel.h:98
kVestelAcZeroSpace
const uint16_t kVestelAcZeroSpace
Definition: ir_Vestel.h:60
kVestelAcMinuteOffset
const uint8_t kVestelAcMinuteOffset
Definition: ir_Vestel.h:108
kVestelAcTimeStateDefault
const uint64_t kVestelAcTimeStateDefault
Definition: ir_Vestel.h:112
IRVestelAc::getTime
uint16_t getTime(void)
Get the A/C's internal clock's time.
Definition: ir_Vestel.cpp:257
kVestelAcTurboSleepOffset
const uint8_t kVestelAcTurboSleepOffset
Definition: ir_Vestel.h:89
kVestelAcTurbo
const uint8_t kVestelAcTurbo
Definition: ir_Vestel.h:82
IRVestelAc::getPower
bool getPower(void)
Get the value of the current power setting.
Definition: ir_Vestel.cpp:124
IRVestelAc::calcChecksum
static uint8_t calcChecksum(const uint64_t state)
Calculate the checksum for a given state.
Definition: ir_Vestel.cpp:395
IRVestelAc::getRaw
uint64_t getRaw(void)
Get a copy of the internal state/code for this protocol.
Definition: ir_Vestel.cpp:79
kVestelAcHeat
const uint8_t kVestelAcHeat
Definition: ir_Vestel.h:71
kVestelAcNormal
const uint8_t kVestelAcNormal
Definition: ir_Vestel.h:80
kVestelAcFanHigh
const uint8_t kVestelAcFanHigh
Definition: ir_Vestel.h:76
kVestelAcTimerSize
const uint8_t kVestelAcTimerSize
Definition: ir_Vestel.h:101
IRVestelAc::IRVestelAc
IRVestelAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Vestel.cpp:54
IRVestelAc
Class for handling detailed Vestel A/C messages.
Definition: ir_Vestel.h:116
IRVestelAc::getIon
bool getIon(void)
Get the Ion (Filter) setting of the A/C.
Definition: ir_Vestel.cpp:373
kVestelAcCool
const uint8_t kVestelAcCool
Definition: ir_Vestel.h:68
IRVestelAc::getMode
uint8_t getMode(void)
Get the operating mode setting of the A/C.
Definition: ir_Vestel.cpp:171
IRVestelAc::getOnTimer
uint16_t getOnTimer(void)
Get the A/C's On Timer time.
Definition: ir_Vestel.cpp:304
IRVestelAc::setTimerActive
void setTimerActive(const bool on)
Set the timer to be active on the A/C.
Definition: ir_Vestel.cpp:213
IRVestelAc::setSleep
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition: ir_Vestel.cpp:336
IRVestelAc::_setTimer
void _setTimer(const uint16_t minutes, const uint8_t offset)
Set a given timer time at a given bit offset.
Definition: ir_Vestel.cpp:279
IRVestelAc::use_time_state
bool use_time_state
Definition: ir_Vestel.h:186
kVestelAcOffTimerFlagOffset
const uint8_t kVestelAcOffTimerFlagOffset
Definition: ir_Vestel.h:106
kVestelAcModeOffset
const uint8_t kVestelAcModeOffset
Definition: ir_Vestel.h:93
kVestelAcIon
const uint8_t kVestelAcIon
Definition: ir_Vestel.h:83
IRVestelAc::getFan
uint8_t getFan(void)
Get the current fan speed setting.
Definition: ir_Vestel.cpp:165
IRVestelAc::getSwing
bool getSwing(void)
Get the Swing Roaming setting of the A/C.
Definition: ir_Vestel.cpp:387
kVestelAcPowerOffset
const uint8_t kVestelAcPowerOffset
Definition: ir_Vestel.h:95
IRVestelAc::validChecksum
static bool validChecksum(const uint64_t state)
Verify the checksum is valid for a given state.
Definition: ir_Vestel.cpp:403
IRVestelAc::setAuto
void setAuto(const int8_t autoLevel)
Set Auto mode/level of the A/C.
Definition: ir_Vestel.cpp:195
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
kVestelAcFanAuto
const uint8_t kVestelAcFanAuto
Definition: ir_Vestel.h:73
IRVestelAc::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Vestel.cpp:440
IRVestelAc::setOnTimer
void setOnTimer(const uint16_t minutes)
Set the On timer time on the A/C.
Definition: ir_Vestel.cpp:297
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46