# IRremoteESP8266: src/ir_Sanyo.h Source File

ir_Sanyo.h
Go to the documentation of this file.
// Copyright 2020 David Conran
// Supports:
// Brand: Sanyo, Model: SA 8650B - disabled
// Brand: Sanyo, Model: LC7461 transmitter IC (SANYO_LC7461)
// Brand: Sanyo, Model: SAP-K121AHA A/C (SANYO_AC)
// Brand: Sanyo, Model: RCS-2HS4E remote (SANYO_AC)
// Brand: Sanyo, Model: SAP-K242AH A/C (SANYO_AC)
// Brand: Sanyo, Model: RCS-2S4E remote (SANYO_AC)
#ifndef IR_SANYO_H_
#define IR_SANYO_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
union SanyoProtocol{
uint8_t raw[kSanyoAcStateLength];
// Ref: https://docs.google.com/spreadsheets/d/1dYfLsnYvpjV-SgO8pdinpfuBIpSzm8Q1R5SabrLeskw/edit?usp=sharing
struct {
// Byte 0
uint8_t :8; // 0x6A (Fixed?)
// Byte 1
uint8_t Temp :5;
uint8_t :3;
// Byte 2
uint8_t SensorTemp :5;
uint8_t Sensor :1;
uint8_t Beep :1;
uint8_t :1;
// Byte 3
uint8_t OffHour :4;
uint8_t :4;
// Byte 4
uint8_t Fan :2;
uint8_t OffTimer :1;
uint8_t :1;
uint8_t Mode :3;
uint8_t :1;
// Byte 5
uint8_t SwingV :3;
uint8_t :3;
uint8_t Power :2;
// Byte 6
uint8_t :3;
uint8_t Sleep :1;
uint8_t :4;
// Byte 7
uint8_t :8;
// Byte 8
uint8_t Sum :8;
};
};
// Constants
const uint8_t kSanyoAcTempMin = 16;
const uint8_t kSanyoAcTempMax = 30;
const uint8_t kSanyoAcTempDelta = 4;
const uint8_t kSanyoAcHourMax = 15;
const uint8_t kSanyoAcHeat = 1;
const uint8_t kSanyoAcCool = 2;
const uint8_t kSanyoAcDry = 3;
const uint8_t kSanyoAcAuto = 4;
const uint8_t kSanyoAcFanAuto = 0;
const uint8_t kSanyoAcFanHigh = 1;
const uint8_t kSanyoAcFanLow = 2;
const uint8_t kSanyoAcFanMedium = 3;
// const uint8_t kSanyoAcPowerStandby = 0b00; ///< Standby?
const uint8_t kSanyoAcPowerOff = 0b01;
const uint8_t kSanyoAcPowerOn = 0b10;
const uint8_t kSanyoAcSwingVAuto = 0;
const uint8_t kSanyoAcSwingVLowest = 2;
const uint8_t kSanyoAcSwingVLow = 3;
const uint8_t kSanyoAcSwingVLowerMiddle = 4;
const uint8_t kSanyoAcSwingVUpperMiddle = 5;
const uint8_t kSanyoAcSwingVHigh = 6;
const uint8_t kSanyoAcSwingVHighest = 7;
// Classes
class IRSanyoAc {
public:
explicit IRSanyoAc(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
void stateReset(void);
#if SEND_SANYO_AC
void send(const uint16_t repeat = kNoRepeat);
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif // SEND_SANYO_AC
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 setSensorTemp(const uint8_t degrees);
uint8_t getSensorTemp(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 setSleep(const bool on);
bool getSleep(void) const;
void setSensor(const bool location);
bool getSensor(void) const;
void setBeep(const bool on);
bool getBeep(void) const;
void setSwingV(const uint8_t setting);
uint8_t getSwingV(void) const;
void setRaw(const uint8_t newState[]);
uint8_t* getRaw(void);
uint16_t getOffTimer(void) const;
void setOffTimer(const uint16_t mins);
static bool validChecksum(const uint8_t state[],
const uint16_t length = kSanyoAcStateLength);
static uint8_t convertMode(const stdAc::opmode_t mode);
static uint8_t convertFan(const stdAc::fanspeed_t speed);
static uint8_t convertSwingV(const stdAc::swingv_t position);
static stdAc::opmode_t toCommonMode(const uint8_t mode);
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
static stdAc::swingv_t toCommonSwingV(const uint8_t setting);
stdAc::state_t toCommon(void) const;
String toString(void) const;
#ifndef UNIT_TEST
private:
IRsend _irsend;
#else // UNIT_TEST
IRsendTest _irsend;
#endif // UNIT_TEST
SanyoProtocol _;
void checksum(void);
static uint8_t calcChecksum(const uint8_t state[],
const uint16_t length = kSanyoAcStateLength);
};
#endif // IR_SANYO_H_
SanyoProtocol::Sleep
uint8_t Sleep
Definition: ir_Sanyo.h:67
IRSanyoAc::_
SanyoProtocol _
Definition: ir_Sanyo.h:163
kSanyoAcTempDelta
const uint8_t kSanyoAcTempDelta
Celsius to Native Temp difference.
Definition: ir_Sanyo.h:80
stdAc::swingv_t
swingv_t
Common A/C settings for Vertical Swing.
Definition: IRsend.h:70
IRSanyoAc::getSensorTemp
uint8_t getSensorTemp(void) const
Get the current sensor temperature setting.
Definition: ir_Sanyo.cpp:451
SanyoProtocol::Fan
uint8_t Fan
Definition: ir_Sanyo.h:56
SanyoProtocol::Beep
uint8_t Beep
Definition: ir_Sanyo.h:50
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
IRSanyoAc::convertSwingV
static uint8_t convertSwingV(const stdAc::swingv_t position)
Convert a stdAc::swingv_t enum into it's native setting.
Definition: ir_Sanyo.cpp:512
kSanyoAcHourMax
const uint8_t kSanyoAcHourMax
0b1111
Definition: ir_Sanyo.h:82
IRSanyoAc::calcChecksum
static uint8_t calcChecksum(const uint8_t state[], const uint16_t length=kSanyoAcStateLength)
Calculate the checksum for a given state.
Definition: ir_Sanyo.cpp:344
IRSanyoAc::getMode
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition: ir_Sanyo.cpp:384
IRSanyoAc::getPower
bool getPower(void) const
Get the value of the current power setting.
Definition: ir_Sanyo.cpp:378
kSanyoAcCool
const uint8_t kSanyoAcCool
0b010
Definition: ir_Sanyo.h:85
IRSanyoAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Sanyo.h:157
IRsend.h
IRSanyoAc::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Sanyo.cpp:372
IRSanyoAc::send
void send(const uint16_t repeat=kNoRepeat)
Send the current internal state as IR messages.
Definition: ir_Sanyo.cpp:321
kSanyoAcDry
const uint8_t kSanyoAcDry
0b011
Definition: ir_Sanyo.h:86
IRSanyoAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Sanyo.cpp:391
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:182
IRSanyoAc::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_Sanyo.cpp:463
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
kSanyoAcSwingVHigh
const uint8_t kSanyoAcSwingVHigh
0b110
Definition: ir_Sanyo.h:101
IRSanyoAc
Class for handling detailed Sanyo A/C messages.
Definition: ir_Sanyo.h:106
IRSanyoAc::getSleep
bool getSleep(void) const
Get the Sleep (Night Setback) setting of the A/C.
Definition: ir_Sanyo.cpp:546
kSanyoAcPowerOff
const uint8_t kSanyoAcPowerOff
Off.
Definition: ir_Sanyo.h:94
IRSanyoAc::setSensor
void setSensor(const bool location)
Set the Sensor Location setting of the A/C. i.e. Where the ambient temperature is measured.
Definition: ir_Sanyo.cpp:553
String
std::string String
Definition: IRremoteESP8266.h:1178
kSanyoAcFanAuto
const uint8_t kSanyoAcFanAuto
0b00
Definition: ir_Sanyo.h:88
IRSanyoAc::getSensor
bool getSensor(void) const
Get the Sensor Location setting of the A/C. i.e. Where the ambient temperature is measured.
Definition: ir_Sanyo.cpp:560
IRSanyoAc::setTemp
void setTemp(const uint8_t degrees)
Set the desired temperature.
Definition: ir_Sanyo.cpp:429
SanyoProtocol::OffTimer
uint8_t OffTimer
Definition: ir_Sanyo.h:57
IRSanyoAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Sanyo.h:117
kSanyoAcSwingVHighest
const uint8_t kSanyoAcSwingVHighest
0b111
Definition: ir_Sanyo.h:102
IRremoteESP8266.h
IRSanyoAc::toString
String toString(void) const
Convert the current internal state into a human readable string.
Definition: ir_Sanyo.cpp:625
kSanyoAcSwingVAuto
const uint8_t kSanyoAcSwingVAuto
0b000
Definition: ir_Sanyo.h:96
kNoRepeat
const uint16_t kNoRepeat
Definition: IRremoteESP8266.h:875
kSanyoAcTempMin
const uint8_t kSanyoAcTempMin
Celsius.
Definition: ir_Sanyo.h:78
kSanyoAcFanHigh
const uint8_t kSanyoAcFanHigh
0b01
Definition: ir_Sanyo.h:89
kSanyoAcSwingVLow
const uint8_t kSanyoAcSwingVLow
0b011
Definition: ir_Sanyo.h:98
IRSanyoAc::IRSanyoAc
IRSanyoAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Sanyo.cpp:303
IRSanyoAc::checksum
void checksum(void)
Calculate & set the checksum for the current internal state of the remote.
Definition: ir_Sanyo.cpp:358
kSanyoAcAuto
const uint8_t kSanyoAcAuto
0b100
Definition: ir_Sanyo.h:87
IRSanyoAc::getOffTimer
uint16_t getOffTimer(void) const
Get the nr of minutes the Off Timer is set to.
Definition: ir_Sanyo.cpp:580
IRSanyoAc::toCommon
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Sanyo.cpp:599
IRSanyoAc::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Sanyo.cpp:406
SanyoProtocol::raw
uint8_t raw[kSanyoAcStateLength]
The state in IR code form.
Definition: ir_Sanyo.h:39
IRSanyoAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Sanyo.cpp:316
SanyoProtocol::OffHour
uint8_t OffHour
Definition: ir_Sanyo.h:53
kSanyoAcHeat
const uint8_t kSanyoAcHeat
0b001
Definition: ir_Sanyo.h:84
IRSanyoAc::setSwingV
void setSwingV(const uint8_t setting)
Set the vertical swing setting of the A/C.
Definition: ir_Sanyo.cpp:501
SanyoProtocol::SensorTemp
uint8_t SensorTemp
Definition: ir_Sanyo.h:48
IRSanyoAc::toCommonSwingV
static stdAc::swingv_t toCommonSwingV(const uint8_t setting)
Convert a native vertical swing postion to it's common equivalent.
Definition: ir_Sanyo.cpp:526
IRSanyoAc::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Sanyo.cpp:470
IRSanyoAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Sanyo.cpp:418
kSanyoAcSwingVUpperMiddle
const uint8_t kSanyoAcSwingVUpperMiddle
0b101
Definition: ir_Sanyo.h:100
SanyoProtocol::Mode
uint8_t Mode
Definition: ir_Sanyo.h:59
SanyoProtocol
Native representation of a Sanyo A/C message.
Definition: ir_Sanyo.h:38
IRSanyoAc::getTemp
uint8_t getTemp(void) const
Get the current desired temperature setting.
Definition: ir_Sanyo.cpp:437
IRSanyoAc::getSwingV
uint8_t getSwingV(void) const
Get the vertical swing setting of the A/C.
Definition: ir_Sanyo.cpp:495
kSanyoAcFanMedium
const uint8_t kSanyoAcFanMedium
0b11
Definition: ir_Sanyo.h:91
IRSanyoAc::setSleep
void setSleep(const bool on)
Set the Sleep (Night Setback) setting of the A/C.
Definition: ir_Sanyo.cpp:540
SanyoProtocol::Temp
uint8_t Temp
Definition: ir_Sanyo.h:45
kSanyoAcPowerOn
const uint8_t kSanyoAcPowerOn
On.
Definition: ir_Sanyo.h:95
kSanyoAcTempMax
const uint8_t kSanyoAcTempMax
Celsius.
Definition: ir_Sanyo.h:79
IRSanyoAc::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Sanyo.cpp:457
kSanyoAcFanLow
const uint8_t kSanyoAcFanLow
0b10
Definition: ir_Sanyo.h:90
kSanyoAcSwingVLowest
const uint8_t kSanyoAcSwingVLowest
0b010
Definition: ir_Sanyo.h:97
SanyoProtocol::Power
uint8_t Power
Definition: ir_Sanyo.h:64
kSanyoAcSwingVLowerMiddle
const uint8_t kSanyoAcSwingVLowerMiddle
0b100
Definition: ir_Sanyo.h:99
IRSanyoAc::setBeep
void setBeep(const bool on)
Set the Beep setting of the A/C.
Definition: ir_Sanyo.cpp:566
kSanyoAcStateLength
const uint16_t kSanyoAcStateLength
Definition: IRremoteESP8266.h:1049
IRSanyoAc::getRaw
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol with all integrity checks passing.
Definition: ir_Sanyo.cpp:329
IRSanyoAc::setSensorTemp
void setSensorTemp(const uint8_t degrees)
Set the sensor temperature.
Definition: ir_Sanyo.cpp:443
IRSanyoAc::stateReset
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition: ir_Sanyo.cpp:309
IRSanyoAc::on
void on(void)
Set the requested power state of the A/C to on.
Definition: ir_Sanyo.cpp:365
SanyoProtocol::Sum
uint8_t Sum
Definition: ir_Sanyo.h:72
IRSanyoAc::setRaw
void setRaw(const uint8_t newState[])
Set the internal state from a valid code for this protocol.
Definition: ir_Sanyo.cpp:336
IRSanyoAc::setOffTimer
void setOffTimer(const uint16_t mins)
Set the nr of minutes for the Off Timer.
Definition: ir_Sanyo.cpp:591
IRSanyoAc::validChecksum
static bool validChecksum(const uint8_t state[], const uint16_t length=kSanyoAcStateLength)
Verify the checksum is valid for a given state.
Definition: ir_Sanyo.cpp:353
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
SanyoProtocol::Sensor
uint8_t Sensor
Sensor location (0 = remote, 1 = A/C)
Definition: ir_Sanyo.h:49
IRSanyoAc::getBeep
bool getBeep(void) const
Get the Beep setting of the A/C.
Definition: ir_Sanyo.cpp:572
IRSanyoAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Sanyo.cpp:484
IRSanyoAc::off
void off(void)
Set the requested power state of the A/C to off.
Definition: ir_Sanyo.cpp:368
SanyoProtocol::SwingV
uint8_t SwingV
Definition: ir_Sanyo.h:62
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46