# 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
// Constants
// Sanyo A/C
// Ref: https://docs.google.com/spreadsheets/d/1dYfLsnYvpjV-SgO8pdinpfuBIpSzm8Q1R5SabrLeskw/edit?usp=sharing
// Byte[0] - 0x6A (Fixed?)
// Byte[1] - Address + Temperature
const uint8_t kSanyoAcTempByte = 1;
const uint8_t kSanyoAcTempOffset = 0;
const uint8_t kSanyoAcTempSize = 5;
const uint8_t kSanyoAcTempMin = 16;
const uint8_t kSanyoAcTempMax = 30;
const uint8_t kSanyoAcTempDelta = 4;
// Byte[2] - Ambient Temp + Sensor
const uint8_t kSanyoAcSensorByte = 2;
const uint8_t kSanyoAcSensorBit = 2;
// Ambient Temp Mask 0b000xxxxx
const uint8_t kSanyoAcBeepBit = 6;
// Byte[3] - Off Hour
const uint8_t kSanyoAcOffHourByte = 3;
const uint8_t kSanyoAcOffHourOffset = 0;
const uint8_t kSanyoAcOffHourSize = 4;
const uint8_t kSanyoAcHourMax = 15;
// Byte[4] - Mode + Fan + Timer Enables
const uint8_t kSanyoAcModeByte = 4;
const uint8_t kSanyoAcModeOffset = 4;
const uint8_t kSanyoAcModeSize = 3;
const uint8_t kSanyoAcHeat = 1;
const uint8_t kSanyoAcCool = 2;
const uint8_t kSanyoAcDry = 3;
const uint8_t kSanyoAcAuto = 4;
const uint8_t kSanyoAcOffTimerEnableBit = 2;
const uint8_t kSanyoAcFanOffset = 0;
const uint8_t kSanyoAcFanSize = 2;
const uint8_t kSanyoAcFanAuto = 0;
const uint8_t kSanyoAcFanHigh = 1;
const uint8_t kSanyoAcFanLow = 2;
const uint8_t kSanyoAcFanMedium = 3;
// Byte[5] - Power + SwingV
const uint8_t kSanyoAcPowerByte = 5;
const uint8_t kSanyoAcPowerOffset = 6;
const uint8_t kSanyoAcPowerSize = 2;
// const uint8_t kSanyoAcPowerStandby = 0b00; ///< Standby?
const uint8_t kSanyoAcPowerOff = 0b01;
const uint8_t kSanyoAcPowerOn = 0b10;
const uint8_t kSanyoAcSwingVOffset = 0;
const uint8_t kSanyoAcSwingVSize = 3;
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;
// Byte[6] - Sleep
const uint8_t kSanyoAcSleepByte = 6;
const uint8_t kSanyoAcSleepBit = 3;
// Byte[8] - Checksum (8-bit Sum of all preceeding nibbles)
// 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);
void setTemp(const uint8_t degrees);
uint8_t getTemp(void);
void setSensorTemp(const uint8_t degrees);
uint8_t getSensorTemp(void);
void setFan(const uint8_t speed);
uint8_t getFan(void);
void setMode(const uint8_t mode);
uint8_t getMode(void);
void setSleep(const bool on);
bool getSleep(void);
void setSensor(const bool location);
bool getSensor(void);
void setBeep(const bool on);
bool getBeep(void);
void setSwingV(const uint8_t setting);
uint8_t getSwingV(void);
void setRaw(const uint8_t newState[]);
uint8_t* getRaw(void);
uint16_t getOffTimer(void);
void setOffTimer(const uint16_t mins);
static bool validChecksum(const uint8_t state[],
const uint16_t length = kSanyoAcStateLength);
uint8_t convertMode(const stdAc::opmode_t mode);
uint8_t convertFan(const stdAc::fanspeed_t speed);
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);
String toString(void);
#ifndef UNIT_TEST
private:
IRsend _irsend;
#else // UNIT_TEST
IRsendTest _irsend;
#endif // UNIT_TEST
uint8_t remote_state[kSanyoAcStateLength];
void checksum(void);
static uint8_t calcChecksum(const uint8_t state[],
const uint16_t length = kSanyoAcStateLength);
void _setTemp(uint8_t *ptr, const uint8_t degrees);
uint8_t _getTemp(uint8_t *ptr);
};
#endif // IR_SANYO_H_
kSanyoAcSensorBit
const uint8_t kSanyoAcSensorBit
Mask 0b00x00000.
Definition: ir_Sanyo.h:51
kSanyoAcTempByte
const uint8_t kSanyoAcTempByte
Index.
Definition: ir_Sanyo.h:43
kSanyoAcModeSize
const uint8_t kSanyoAcModeSize
Mask 0b0xxx0000.
Definition: ir_Sanyo.h:62
kSanyoAcTempDelta
const uint8_t kSanyoAcTempDelta
Celsius to Native Temp difference.
Definition: ir_Sanyo.h:48
stdAc::swingv_t
swingv_t
Common A/C settings for Vertical Swing.
Definition: IRsend.h:70
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
IRSanyoAc::remote_state
uint8_t remote_state[kSanyoAcStateLength]
The state in IR code form.
Definition: ir_Sanyo.h:155
IRSanyoAc::convertSwingV
uint8_t convertSwingV(const stdAc::swingv_t position)
Convert a stdAc::swingv_t enum into it's native setting.
Definition: ir_Sanyo.cpp:536
kSanyoAcHourMax
const uint8_t kSanyoAcHourMax
0b1111
Definition: ir_Sanyo.h:58
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:346
kSanyoAcOffHourSize
const uint8_t kSanyoAcOffHourSize
Mask 0b0000xxxx.
Definition: ir_Sanyo.h:57
IRSanyoAc::_setTemp
void _setTemp(uint8_t *ptr, const uint8_t degrees)
Set the temperature at a given location.
Definition: ir_Sanyo.cpp:436
kSanyoAcCool
const uint8_t kSanyoAcCool
0b010
Definition: ir_Sanyo.h:64
kSanyoAcPowerOffset
const uint8_t kSanyoAcPowerOffset
Mask 0bxx000000.
Definition: ir_Sanyo.h:76
kSanyoAcPowerSize
const uint8_t kSanyoAcPowerSize
Mask 0bxx000000.
Definition: ir_Sanyo.h:77
IRSanyoAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Sanyo.h:149
IRsend.h
kSanyoAcSleepBit
const uint8_t kSanyoAcSleepBit
Mask 0b0000x000.
Definition: ir_Sanyo.h:92
IRSanyoAc::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Sanyo.cpp:374
kSanyoAcTempSize
const uint8_t kSanyoAcTempSize
Mask 0b000xxxxx.
Definition: ir_Sanyo.h:45
IRSanyoAc::send
void send(const uint16_t repeat=kNoRepeat)
Send the current internal state as IR messages.
Definition: ir_Sanyo.cpp:323
kSanyoAcDry
const uint8_t kSanyoAcDry
0b011
Definition: ir_Sanyo.h:65
IRSanyoAc::getOffTimer
uint16_t getOffTimer(void)
Get the nr of minutes the Off Timer is set to.
Definition: ir_Sanyo.cpp:604
IRSanyoAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Sanyo.cpp:396
kSanyoAcFanOffset
const uint8_t kSanyoAcFanOffset
Mask 0b000000xx.
Definition: ir_Sanyo.h:68
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:182
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:88
IRSanyoAc
Class for handling detailed Sanyo A/C messages.
Definition: ir_Sanyo.h:98
kSanyoAcPowerOff
const uint8_t kSanyoAcPowerOff
Off.
Definition: ir_Sanyo.h:79
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:577
String
std::string String
Definition: IRremoteESP8266.h:1178
IRSanyoAc::getMode
uint8_t getMode(void)
Get the operating mode setting of the A/C.
Definition: ir_Sanyo.cpp:388
kSanyoAcFanAuto
const uint8_t kSanyoAcFanAuto
0b00
Definition: ir_Sanyo.h:70
IRSanyoAc::setTemp
void setTemp(const uint8_t degrees)
Set the desired temperature.
Definition: ir_Sanyo.cpp:452
IRSanyoAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Sanyo.h:109
kSanyoAcSwingVHighest
const uint8_t kSanyoAcSwingVHighest
0b111
Definition: ir_Sanyo.h:89
IRremoteESP8266.h
IRSanyoAc::getTemp
uint8_t getTemp(void)
Get the current desired temperature setting.
Definition: ir_Sanyo.cpp:458
kSanyoAcSensorByte
const uint8_t kSanyoAcSensorByte
Index.
Definition: ir_Sanyo.h:50
kSanyoAcSwingVAuto
const uint8_t kSanyoAcSwingVAuto
0b000
Definition: ir_Sanyo.h:83
kNoRepeat
const uint16_t kNoRepeat
Definition: IRremoteESP8266.h:875
kSanyoAcModeOffset
const uint8_t kSanyoAcModeOffset
Mask 0b0xxx0000.
Definition: ir_Sanyo.h:61
IRSanyoAc::getFan
uint8_t getFan(void)
Get the current fan speed setting.
Definition: ir_Sanyo.cpp:483
kSanyoAcTempMin
const uint8_t kSanyoAcTempMin
Celsius.
Definition: ir_Sanyo.h:46
kSanyoAcFanHigh
const uint8_t kSanyoAcFanHigh
0b01
Definition: ir_Sanyo.h:71
kSanyoAcSwingVLow
const uint8_t kSanyoAcSwingVLow
0b011
Definition: ir_Sanyo.h:85
IRSanyoAc::IRSanyoAc
IRSanyoAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Sanyo.cpp:305
IRSanyoAc::getSleep
bool getSleep(void)
Get the Sleep (Night Setback) setting of the A/C.
Definition: ir_Sanyo.cpp:570
IRSanyoAc::getSensor
bool getSensor(void)
Get the Sensor Location setting of the A/C. i.e. Where the ambient temperature is measured.
Definition: ir_Sanyo.cpp:584
IRSanyoAc::checksum
void checksum(void)
Calculate & set the checksum for the current internal state of the remote.
Definition: ir_Sanyo.cpp:360
kSanyoAcAuto
const uint8_t kSanyoAcAuto
0b100
Definition: ir_Sanyo.h:66
IRSanyoAc::getBeep
bool getBeep(void)
Get the Beep setting of the A/C.
Definition: ir_Sanyo.cpp:596
IRSanyoAc::convertMode
uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Sanyo.cpp:412
IRSanyoAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Sanyo.cpp:318
kSanyoAcSleepByte
const uint8_t kSanyoAcSleepByte
Index.
Definition: ir_Sanyo.h:91
kSanyoAcOffTimerEnableBit
const uint8_t kSanyoAcOffTimerEnableBit
Mask 0b00000x00.
Definition: ir_Sanyo.h:67
kSanyoAcHeat
const uint8_t kSanyoAcHeat
0b001
Definition: ir_Sanyo.h:63
IRSanyoAc::setSwingV
void setSwingV(const uint8_t setting)
Set the vertical swing setting of the A/C.
Definition: ir_Sanyo.cpp:523
kSanyoAcModeByte
const uint8_t kSanyoAcModeByte
Index.
Definition: ir_Sanyo.h:60
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:550
IRSanyoAc::convertFan
uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Sanyo.cpp:491
IRSanyoAc::getSensorTemp
uint8_t getSensorTemp(void)
Get the current sensor temperature setting.
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:424
kSanyoAcSwingVUpperMiddle
const uint8_t kSanyoAcSwingVUpperMiddle
0b101
Definition: ir_Sanyo.h:87
kSanyoAcSwingVSize
const uint8_t kSanyoAcSwingVSize
Mask 0b00000xxx.
Definition: ir_Sanyo.h:82
kSanyoAcTempOffset
const uint8_t kSanyoAcTempOffset
Mask 0b000xxxxx.
Definition: ir_Sanyo.h:44
IRSanyoAc::_getTemp
uint8_t _getTemp(uint8_t *ptr)
Get the temperature from a given location.
Definition: ir_Sanyo.cpp:445
kSanyoAcSwingVOffset
const uint8_t kSanyoAcSwingVOffset
Mask 0b00000xxx.
Definition: ir_Sanyo.h:81
kSanyoAcFanMedium
const uint8_t kSanyoAcFanMedium
0b11
Definition: ir_Sanyo.h:73
IRSanyoAc::getPower
bool getPower(void)
Get the value of the current power setting.
Definition: ir_Sanyo.cpp:381
IRSanyoAc::setSleep
void setSleep(const bool on)
Set the Sleep (Night Setback) setting of the A/C.
Definition: ir_Sanyo.cpp:564
kSanyoAcPowerOn
const uint8_t kSanyoAcPowerOn
On.
Definition: ir_Sanyo.h:80
kSanyoAcTempMax
const uint8_t kSanyoAcTempMax
Celsius.
Definition: ir_Sanyo.h:47
kSanyoAcOffHourOffset
const uint8_t kSanyoAcOffHourOffset
Mask 0b0000xxxx.
Definition: ir_Sanyo.h:56
IRSanyoAc::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Sanyo.cpp:476
kSanyoAcFanLow
const uint8_t kSanyoAcFanLow
0b10
Definition: ir_Sanyo.h:72
kSanyoAcSwingVLowest
const uint8_t kSanyoAcSwingVLowest
0b010
Definition: ir_Sanyo.h:84
kSanyoAcPowerByte
const uint8_t kSanyoAcPowerByte
Index.
Definition: ir_Sanyo.h:75
kSanyoAcOffHourByte
const uint8_t kSanyoAcOffHourByte
Index.
Definition: ir_Sanyo.h:55
kSanyoAcSwingVLowerMiddle
const uint8_t kSanyoAcSwingVLowerMiddle
0b100
Definition: ir_Sanyo.h:86
IRSanyoAc::getSwingV
uint8_t getSwingV(void)
Get the vertical swing setting of the A/C.
Definition: ir_Sanyo.cpp:516
kSanyoAcFanSize
const uint8_t kSanyoAcFanSize
Mask 0b000000xx.
Definition: ir_Sanyo.h:69
IRSanyoAc::setBeep
void setBeep(const bool on)
Set the Beep setting of the A/C.
Definition: ir_Sanyo.cpp:590
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:331
IRSanyoAc::setSensorTemp
void setSensorTemp(const uint8_t degrees)
Set the sensor temperature.
Definition: ir_Sanyo.cpp:464
IRSanyoAc::stateReset
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition: ir_Sanyo.cpp:311
IRSanyoAc::toCommon
stdAc::state_t toCommon(void)
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Sanyo.cpp:625
IRSanyoAc::on
void on(void)
Set the requested power state of the A/C to on.
Definition: ir_Sanyo.cpp:367
IRSanyoAc::setRaw
void setRaw(const uint8_t newState[])
Set the internal state from a valid code for this protocol.
Definition: ir_Sanyo.cpp:338
IRSanyoAc::setOffTimer
void setOffTimer(const uint16_t mins)
Set the nr of minutes for the Off Timer.
Definition: ir_Sanyo.cpp:616
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:355
IRSanyoAc::toString
String toString(void)
Convert the current internal state into a human readable string.
Definition: ir_Sanyo.cpp:651
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
IRSanyoAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Sanyo.cpp:505
kSanyoAcBeepBit
const uint8_t kSanyoAcBeepBit
Mask 0b0x000000.
Definition: ir_Sanyo.h:53
IRSanyoAc::off
void off(void)
Set the requested power state of the A/C to off.
Definition: ir_Sanyo.cpp:370
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46