# IRremoteESP8266: src/ir_Samsung.h Source File

ir_Samsung.h
Go to the documentation of this file.
// Copyright 2018 David Conran
// Supports:
// Brand: Samsung, Model: UA55H6300 TV (SAMSUNG)
// Brand: Samsung, Model: BN59-01178B TV remote (SAMSUNG)
// Brand: Samsung, Model: DB63-03556X003 remote
// Brand: Samsung, Model: DB93-16761C remote
// Brand: Samsung, Model: IEC-R03 remote
// Brand: Samsung, Model: AK59-00167A Bluray remote (SAMSUNG36)
// Brand: Samsung, Model: AH59-02692E Soundbar remote (SAMSUNG36)
// Brand: Samsung, Model: HW-J551 Soundbar (SAMSUNG36)
// Brand: Samsung, Model: AR09FSSDAWKNFA A/C (SAMSUNG_AC)
// Brand: Samsung, Model: AR12KSFPEWQNET A/C (SAMSUNG_AC)
// Brand: Samsung, Model: AR12HSSDBWKNEU A/C (SAMSUNG_AC)
// Brand: Samsung, Model: AR12NXCXAWKXEU A/C (SAMSUNG_AC)
#ifndef IR_SAMSUNG_H_
#define IR_SAMSUNG_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
// Constants
// SamsungAc
// Byte[1]
// Checksum 0b11110000 ???
const uint8_t kSamsungAcPower1Offset = 5; // Mask 0b00100000
const uint8_t kSamsungAcQuiet1Offset = 4; // Mask 0b00010000
// Byte[5]
const uint8_t kSamsungAcQuiet5Offset = 5;
// Byte[6]
const uint8_t kSamsungAcPower6Offset = 4; // Mask 0b00110000
const uint8_t kSamsungAcPower6Size = 2; // Bits
// Byte[8]
// Checksum 0b11110000 ???
const uint8_t kSamsungAcPowerfulMask8 = 0b01010000;
// Byte[9]
const uint8_t kSamsungAcSwingOffset = 4; // Mask 0b01110000
const uint8_t kSamsungAcSwingSize = 3; // Bits
const uint8_t kSamsungAcSwingMove = 0b010;
const uint8_t kSamsungAcSwingStop = 0b111;
// Byte[10]
const uint8_t kSamsungAcPowerful10Offset = 1; // Mask 0b00001110
const uint8_t kSamsungAcPowerful10Size = 3; // Mask 0b00001110
const uint8_t kSamsungAcPowerful10On = 0b011;
// Breeze (aka. WindFree)
const uint8_t kSamsungAcBreezeOffset = kSamsungAcPowerful10Offset;
const uint8_t kSamsungAcBreezeSize = kSamsungAcPowerful10Size;
const uint8_t kSamsungAcBreezeOn = 0b101;
const uint8_t kSamsungAcDisplayOffset = 4; // Mask 0b00010000
const uint8_t kSamsungAcClean10Offset = 7; // Mask 0b10000000
// Byte[11]
const uint8_t kSamsungAcIonOffset = 0; // Mask 0b00000001
const uint8_t kSamsungAcClean11Offset = 1; // Mask 0b00000010
const uint8_t kSamsungAcMinTemp = 16; // C Mask 0b11110000
const uint8_t kSamsungAcMaxTemp = 30; // C Mask 0b11110000
const uint8_t kSamsungAcAutoTemp = 25; // C Mask 0b11110000
// Byte[12]
const uint8_t kSamsungAcModeOffset = 4; // Mask 0b01110000
const uint8_t kSamsungAcAuto = 0;
const uint8_t kSamsungAcCool = 1;
const uint8_t kSamsungAcDry = 2;
const uint8_t kSamsungAcFan = 3;
const uint8_t kSamsungAcHeat = 4;
const uint8_t kSamsungAcFanOffest = 1; // Mask 0b00001110
const uint8_t kSamsungAcFanSize = 3; // Bits
const uint8_t kSamsungAcFanAuto = 0;
const uint8_t kSamsungAcFanLow = 2;
const uint8_t kSamsungAcFanMed = 4;
const uint8_t kSamsungAcFanHigh = 5;
const uint8_t kSamsungAcFanAuto2 = 6;
const uint8_t kSamsungAcFanTurbo = 7;
// Byte[13]
const uint8_t kSamsungAcBeepOffset = 1; // Mask 0b00000010
const uint16_t kSamsungAcSectionLength = 7;
const uint64_t kSamsungAcPowerSection = 0x1D20F00000000;
// Classes
class IRSamsungAc {
public:
explicit IRSamsungAc(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
void stateReset(const bool forcepower = true, const bool initialPower = true);
#if SEND_SAMSUNG_AC
void send(const uint16_t repeat = kSamsungAcDefaultRepeat,
const bool calcchecksum = true);
void sendExtended(const uint16_t repeat = kSamsungAcDefaultRepeat,
const bool calcchecksum = true);
void sendOn(const uint16_t repeat = kSamsungAcDefaultRepeat);
void sendOff(const uint16_t repeat = kSamsungAcDefaultRepeat);
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif // SEND_SAMSUNG_AC
void begin(void);
void on(void);
void off(void);
void setPower(const bool on);
bool getPower(void);
void setTemp(const uint8_t temp);
uint8_t getTemp(void);
void setFan(const uint8_t speed);
uint8_t getFan(void);
void setMode(const uint8_t mode);
uint8_t getMode(void);
void setSwing(const bool on);
bool getSwing(void);
void setBeep(const bool on);
bool getBeep(void);
void setClean(const bool on);
bool getClean(void);
void setQuiet(const bool on);
bool getQuiet(void);
void setPowerful(const bool on);
bool getPowerful(void);
void setBreeze(const bool on);
bool getBreeze(void);
void setDisplay(const bool on);
bool getDisplay(void);
void setIon(const bool on);
bool getIon(void);
uint8_t* getRaw(void);
void setRaw(const uint8_t new_code[],
const uint16_t length = kSamsungAcStateLength);
static bool validChecksum(const uint8_t state[],
const uint16_t length = kSamsungAcStateLength);
static uint8_t calcChecksum(const uint8_t state[],
const uint16_t length = kSamsungAcStateLength);
uint8_t convertMode(const stdAc::opmode_t mode);
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
uint8_t remote_state[kSamsungAcExtendedStateLength];
bool _forcepower;
bool _lastsentpowerstate;
void checksum(const uint16_t length = kSamsungAcStateLength);
};
#endif // IR_SAMSUNG_H_
IRSamsungAc::getIon
bool getIon(void)
Get the Ion (Filter) setting of the A/C.
Definition: ir_Samsung.cpp:644
kSamsungAcDry
const uint8_t kSamsungAcDry
Definition: ir_Samsung.h:78
IRSamsungAc
Class for handling detailed Samsung A/C messages.
Definition: ir_Samsung.h:97
IRSamsungAc::_forcepower
bool _forcepower
Hack to know when we need to send a special power mesg.
Definition: ir_Samsung.h:165
kSamsungAcCool
const uint8_t kSamsungAcCool
Definition: ir_Samsung.h:77
IRSamsungAc::setQuiet
void setQuiet(const bool on)
Set the Quiet setting of the A/C.
Definition: ir_Samsung.cpp:571
kSamsungAcFanMed
const uint8_t kSamsungAcFanMed
Definition: ir_Samsung.h:85
IRSamsungAc::send
void send(const uint16_t repeat=kSamsungAcDefaultRepeat, const bool calcchecksum=true)
Send the current internal state as an IR message.
Definition: ir_Samsung.cpp:345
kSamsungAcFanAuto2
const uint8_t kSamsungAcFanAuto2
Definition: ir_Samsung.h:87
kSamsungAcAuto
const uint8_t kSamsungAcAuto
Definition: ir_Samsung.h:76
IRSamsungAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Samsung.h:158
IRSamsungAc::IRSamsungAc
IRSamsungAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Samsung.cpp:272
kSamsungAcFanHigh
const uint8_t kSamsungAcFanHigh
Definition: ir_Samsung.h:86
kSamsungAcBreezeSize
const uint8_t kSamsungAcBreezeSize
Definition: ir_Samsung.h:64
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
kSamsungAcFan
const uint8_t kSamsungAcFan
Definition: ir_Samsung.h:79
IRSamsungAc::getBreeze
bool getBreeze(void)
Are the vanes closed over the fan outlet, to stop direct wind? Aka. WindFree.
Definition: ir_Samsung.cpp:611
IRSamsungAc::setBreeze
void setBreeze(const bool on)
Closes the vanes over the fan outlet, to stop direct wind. Aka. WindFree.
Definition: ir_Samsung.cpp:620
IRSamsungAc::toCommon
stdAc::state_t toCommon(void)
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Samsung.cpp:709
kSamsungAcSwingStop
const uint8_t kSamsungAcSwingStop
Definition: ir_Samsung.h:57
kSamsungAcPower1Offset
const uint8_t kSamsungAcPower1Offset
Definition: ir_Samsung.h:43
IRSamsungAc::getDisplay
bool getDisplay(void)
Get the Display (Light/LED) setting of the A/C.
Definition: ir_Samsung.cpp:632
IRSamsungAc::getMode
uint8_t getMode(void)
Get the operating mode setting of the A/C.
Definition: ir_Samsung.cpp:488
kSamsungAcDefaultRepeat
const uint16_t kSamsungAcDefaultRepeat
Definition: IRremoteESP8266.h:1048
kSamsungAcPowerful10On
const uint8_t kSamsungAcPowerful10On
Definition: ir_Samsung.h:61
IRSamsungAc::getPower
bool getPower(void)
Get the value of the current power setting.
Definition: ir_Samsung.cpp:446
IRsend.h
IRSamsungAc::setSwing
void setSwing(const bool on)
Set the vertical swing setting of the A/C.
Definition: ir_Samsung.cpp:531
IRSamsungAc::toString
String toString(void)
Convert the current internal state into a human readable string.
Definition: ir_Samsung.cpp:736
kSamsungAcSectionLength
const uint16_t kSamsungAcSectionLength
Definition: ir_Samsung.h:92
IRSamsungAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Samsung.cpp:293
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:182
IRSamsungAc::setIon
void setIon(const bool on)
Set the Ion (Filter) setting of the A/C.
Definition: ir_Samsung.cpp:650
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
IRSamsungAc::setRaw
void setRaw(const uint8_t new_code[], const uint16_t length=kSamsungAcStateLength)
Set the internal state from a valid code for this protocol.
Definition: ir_Samsung.cpp:420
String
std::string String
Definition: IRremoteESP8266.h:1178
IRSamsungAc::getTemp
uint8_t getTemp(void)
Get the current temperature setting.
Definition: ir_Samsung.cpp:463
IRSamsungAc::sendOff
void sendOff(const uint16_t repeat=kSamsungAcDefaultRepeat)
Send the special extended "Off" message as the library can't seem to reproduce this message automatic...
Definition: ir_Samsung.cpp:400
kSamsungAcQuiet1Offset
const uint8_t kSamsungAcQuiet1Offset
Definition: ir_Samsung.h:44
IRSamsungAc::getPowerful
bool getPowerful(void)
Get the Powerful (Turbo) setting of the A/C.
Definition: ir_Samsung.cpp:583
IRSamsungAc::on
void on(void)
Set the requested power state of the A/C to on.
Definition: ir_Samsung.cpp:431
IRSamsungAc::getBeep
bool getBeep(void)
Get the Beep setting of the A/C.
Definition: ir_Samsung.cpp:538
kSamsungAcFanSize
const uint8_t kSamsungAcFanSize
Definition: ir_Samsung.h:82
IRSamsungAc::convertFan
uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Samsung.cpp:670
IRSamsungAc::remote_state
uint8_t remote_state[kSamsungAcExtendedStateLength]
State in code form.
Definition: ir_Samsung.h:164
kSamsungAcPowerfulMask8
const uint8_t kSamsungAcPowerfulMask8
Definition: ir_Samsung.h:52
kSamsungAcStateLength
const uint16_t kSamsungAcStateLength
Definition: IRremoteESP8266.h:1044
IRSamsungAc::validChecksum
static bool validChecksum(const uint8_t state[], const uint16_t length=kSamsungAcStateLength)
Verify the checksum is valid for a given state.
Definition: ir_Samsung.cpp:318
IRremoteESP8266.h
IRSamsungAc::setTemp
void setTemp(const uint8_t temp)
Set the temperature.
Definition: ir_Samsung.cpp:454
kSamsungAcSwingOffset
const uint8_t kSamsungAcSwingOffset
Definition: ir_Samsung.h:54
kSamsungAcPowerSection
const uint64_t kSamsungAcPowerSection
Definition: ir_Samsung.h:93
IRSamsungAc::setPowerful
void setPowerful(const bool on)
Set the Powerful (Turbo) setting of the A/C.
Definition: ir_Samsung.cpp:592
kSamsungAcModeOffset
const uint8_t kSamsungAcModeOffset
Definition: ir_Samsung.h:75
kSamsungAcExtendedStateLength
const uint16_t kSamsungAcExtendedStateLength
Definition: IRremoteESP8266.h:1046
IRSamsungAc::getQuiet
bool getQuiet(void)
Get the Quiet setting of the A/C.
Definition: ir_Samsung.cpp:564
kSamsungAcDisplayOffset
const uint8_t kSamsungAcDisplayOffset
Definition: ir_Samsung.h:66
IRSamsungAc::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Samsung.cpp:438
IRSamsungAc::setDisplay
void setDisplay(const bool on)
Set the Display (Light/LED) setting of the A/C.
Definition: ir_Samsung.cpp:638
IRSamsungAc::getFan
uint8_t getFan(void)
Get the current fan speed setting.
Definition: ir_Samsung.cpp:514
kSamsungAcBreezeOn
const uint8_t kSamsungAcBreezeOn
Definition: ir_Samsung.h:65
kSamsungAcPowerful10Offset
const uint8_t kSamsungAcPowerful10Offset
Definition: ir_Samsung.h:59
IRSamsungAc::stateReset
void stateReset(const bool forcepower=true, const bool initialPower=true)
Reset the internal state of the emulation.
Definition: ir_Samsung.cpp:282
IRSamsungAc::calcChecksum
static uint8_t calcChecksum(const uint8_t state[], const uint16_t length=kSamsungAcStateLength)
Calculate the checksum for a given state.
Definition: ir_Samsung.cpp:299
IRSamsungAc::_lastsentpowerstate
bool _lastsentpowerstate
Definition: ir_Samsung.h:166
kSamsungAcAutoTemp
const uint8_t kSamsungAcAutoTemp
Definition: ir_Samsung.h:73
kSamsungAcSwingMove
const uint8_t kSamsungAcSwingMove
Definition: ir_Samsung.h:56
IRSamsungAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Samsung.cpp:470
kSamsungAcBreezeOffset
const uint8_t kSamsungAcBreezeOffset
Definition: ir_Samsung.h:63
kSamsungAcSwingSize
const uint8_t kSamsungAcSwingSize
Definition: ir_Samsung.h:55
kSamsungAcFanLow
const uint8_t kSamsungAcFanLow
Definition: ir_Samsung.h:84
IRSamsungAc::setClean
void setClean(const bool on)
Set the Clean setting of the A/C.
Definition: ir_Samsung.cpp:557
kSamsungAcHeat
const uint8_t kSamsungAcHeat
Definition: ir_Samsung.h:80
IRSamsungAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Samsung.cpp:684
IRSamsungAc::sendOn
void sendOn(const uint16_t repeat=kSamsungAcDefaultRepeat)
Send the special extended "On" message as the library can't seem to reproduce this message automatica...
Definition: ir_Samsung.cpp:387
kSamsungAcFanAuto
const uint8_t kSamsungAcFanAuto
Definition: ir_Samsung.h:83
kSamsungAcClean11Offset
const uint8_t kSamsungAcClean11Offset
Definition: ir_Samsung.h:70
IRSamsungAc::checksum
void checksum(const uint16_t length=kSamsungAcStateLength)
Update the checksum for the internal state.
Definition: ir_Samsung.cpp:331
IRSamsungAc::setBeep
void setBeep(const bool on)
Set the Beep setting of the A/C.
Definition: ir_Samsung.cpp:544
IRSamsungAc::getClean
bool getClean(void)
Get the Clean setting of the A/C.
Definition: ir_Samsung.cpp:550
kSamsungAcFanOffest
const uint8_t kSamsungAcFanOffest
Definition: ir_Samsung.h:81
IRSamsungAc::convertMode
uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Samsung.cpp:657
IRSamsungAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Samsung.h:113
IRSamsungAc::sendExtended
void sendExtended(const uint16_t repeat=kSamsungAcDefaultRepeat, const bool calcchecksum=true)
Send the extended current internal state as an IR message.
Definition: ir_Samsung.cpp:366
IRSamsungAc::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Samsung.cpp:494
kSamsungAcMaxTemp
const uint8_t kSamsungAcMaxTemp
Definition: ir_Samsung.h:72
kSamsungAcIonOffset
const uint8_t kSamsungAcIonOffset
Definition: ir_Samsung.h:69
kSamsungAcPower6Offset
const uint8_t kSamsungAcPower6Offset
Definition: ir_Samsung.h:48
kSamsungAcPowerful10Size
const uint8_t kSamsungAcPowerful10Size
Definition: ir_Samsung.h:60
kSamsungAcClean10Offset
const uint8_t kSamsungAcClean10Offset
Definition: ir_Samsung.h:67
IRSamsungAc::getSwing
bool getSwing(void)
Get the vertical swing setting of the A/C.
Definition: ir_Samsung.cpp:522
IRSamsungAc::off
void off(void)
Set the requested power state of the A/C to off.
Definition: ir_Samsung.cpp:434
kSamsungAcPower6Size
const uint8_t kSamsungAcPower6Size
Definition: ir_Samsung.h:49
IRSamsungAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Samsung.cpp:697
kSamsungAcBeepOffset
const uint8_t kSamsungAcBeepOffset
Definition: ir_Samsung.h:90
IRSamsungAc::getRaw
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol.
Definition: ir_Samsung.cpp:412
kSamsungAcQuiet5Offset
const uint8_t kSamsungAcQuiet5Offset
Definition: ir_Samsung.h:46
kSamsungAcFanTurbo
const uint8_t kSamsungAcFanTurbo
Definition: ir_Samsung.h:88
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
kSamsungAcMinTemp
const uint8_t kSamsungAcMinTemp
Definition: ir_Samsung.h:71
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46