Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions examples/TestRhossAC/TestRhossAC.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* Copyright 2021 Tom Rosenback
*/


#include <Arduino.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>
#include <IRrecv.h>
#include <IRutils.h>
#include <ir_Rhoss.h>

const uint16_t kIrLed = 4; // ESP8266 GPIO pin to use. Recommended: 4 (D2).
const uint16_t kIrRecvLed = 14; // ESP8266 GPIO pin to use. Recommended: 14 (D5).
const uint16_t kIrMaxBuffer = 1024;
const uint16_t kIrTimeout = 50;
IRRhossAc ac(kIrLed); // Set the GPIO to be used to sending the message.
IRrecv irrecv(kIrRecvLed, kIrMaxBuffer, kIrTimeout, true);
decode_results decode_results; // Somewhere to store the results

void setup() {
irrecv.enableIRIn();
Serial.begin(115200);

#if SEND_RHOSS
ac.begin();
#endif // SEND_RHOSS
}

void loop() {
#if DECODE_RHOSS
if(irrecv.decode(&decode_results)) {
Serial.println("Decoded a message");

if(decode_results.decode_type == RHOSS) {
Serial.println("Rhoss message decoded");
Serial.println(resultToSourceCode(&decode_results));
Serial.println(resultToHumanReadableBasic(&decode_results));
ac.setRaw(decode_results.state);
Serial.println(ac.toString());

// relay received signal
#if SEND_RHOSS
// disable receiving while sending
irrecv.disableIRIn();
Serial.println("Sending...");
// Now send the IR signal.
ac.send();
irrecv.enableIRIn();
#else // SEND_RHOSS
Serial.println("Can't send because SEND_RHOSS has been disabled.");
#endif // SEND_RHOSS
}
}
#endif
}
18 changes: 18 additions & 0 deletions examples/TestRhossAC/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[platformio]
src_dir = .

[env]
lib_extra_dirs = ../../
lib_ldf_mode = deep+
lib_ignore = examples
framework = arduino
monitor_speed = 115200
build_flags = ; -D_IR_LOCALE_=en-AU

[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2

[env:esp32dev]
platform = espressif32
board = esp32dev
55 changes: 55 additions & 0 deletions src/IRac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "ir_Vestel.h"
#include "ir_Voltas.h"
#include "ir_Whirlpool.h"
#include "ir_Rhoss.h"

/// Class constructor
/// @param[in] pin Gpio pin to use when transmitting IR messages.
Expand Down Expand Up @@ -300,6 +301,9 @@ bool IRac::isProtocolSupported(const decode_type_t protocol) {
#endif
#if SEND_VOLTAS
case decode_type_t::VOLTAS:
#endif
#if SEND_RHOSS
case decode_type_t::RHOSS:
#endif
case decode_type_t::WHIRLPOOL_AC:
return true;
Expand Down Expand Up @@ -2348,6 +2352,34 @@ void IRac::transcold(IRTranscoldAc *ac,
}
#endif // SEND_TRANSCOLD

#if SEND_RHOSS
/// Send an Rhoss A/C message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRRhossAc object to use.
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] fan The speed setting for the fan.
void IRac::rhoss(IRRhossAc *ac,
const bool on, const stdAc::opmode_t mode, const float degrees,
const stdAc::fanspeed_t fan, const stdAc::swingv_t swing) {
ac->begin();
ac->setPower(on);
ac->setMode(ac->convertMode(mode));
ac->setSwing(ac->convertSwing(swing));
ac->setTemp(degrees);
ac->setFan(ac->convertFan(fan));
// No Quiet setting available.
// No Light setting available.
// No Filter setting available.
// No Turbo setting available.
// No Economy setting available.
// No Clean setting available.
// No Beep setting available.
// No Sleep setting available.
ac->send();
}
#endif // SEND_RHOSS

/// Create a new state base on the provided state that has been suitably fixed.
/// @note This is for use with Home Assistant, which requires mode to be off if
/// the power is off.
Expand Down Expand Up @@ -3015,6 +3047,14 @@ bool IRac::sendAc(const stdAc::state_t desired, const stdAc::state_t *prev) {
break;
}
#endif // SEND_TRANSCOLD_AC
#if SEND_RHOSS
case RHOSS:
{
IRRhossAc ac(_pin, _inverted, _modulation);
rhoss(&ac, send.power, send.mode, degC, send.fanspeed, send.swingv);
break;
}
#endif // SEND_RHOSS
default:
return false; // Fail, didn't match anything.
}
Expand Down Expand Up @@ -3767,6 +3807,13 @@ namespace IRAcUtils {
return ac.toString();
}
#endif // DECODE_TRANSCOLD
#if DECODE_RHOSS
case decode_type_t::RHOSS: {
IRRhossAc ac(kGpioUnused);
ac.setRaw(result->state);
return ac.toString();
}
#endif // DECODE_RHOSS
default:
return "";
}
Expand Down Expand Up @@ -4232,6 +4279,14 @@ namespace IRAcUtils {
break;
}
#endif // DECODE_TRANSCOLD
#if DECODE_RHOSS
case decode_type_t::RHOSS: {
IRRhossAc ac(kGpioUnused);
ac.setRaw(decode->state);
*result = ac.toCommon();
break;
}
#endif // DECODE_RHOSS
default:
return false;
}
Expand Down
6 changes: 6 additions & 0 deletions src/IRac.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "ir_Vestel.h"
#include "ir_Voltas.h"
#include "ir_Whirlpool.h"
#include "ir_Rhoss.h"

// Constants
const int8_t kGpioUnused = -1; ///< A placeholder for not using an actual GPIO.
Expand Down Expand Up @@ -489,6 +490,11 @@ void electra(IRElectraAc *ac,
const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv, const stdAc::swingh_t swingh);
#endif // SEND_TRANSCOLD
#if SEND_RHOSS
void rhoss(IRRhossAc *ac,
const bool on, const stdAc::opmode_t mode, const float degrees,
const stdAc::fanspeed_t fan, const stdAc::swingv_t swing);
#endif // SEND_RHOSS
static stdAc::state_t cleanState(const stdAc::state_t state);
static stdAc::state_t handleToggles(const stdAc::state_t desired,
const stdAc::state_t *prev = NULL);
Expand Down
8 changes: 7 additions & 1 deletion src/IRrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,10 @@ bool IRrecv::decode(decode_results *results, irparams_t *save,
DPRINTLN("Attempting Arris decode");
if (decodeArris(results, offset)) return true;
#endif // DECODE_ARRIS
#if DECODE_RHOSS
DPRINTLN("Attempting Rhoss decode");
if (decodeRhoss(results, offset)) return true;
#endif // DECODE_RHOSS
// Typically new protocols are added above this line.
}
#if DECODE_HASH
Expand Down Expand Up @@ -1433,10 +1437,13 @@ uint16_t IRrecv::_matchGeneric(volatile uint16_t *data_ptr,
const uint8_t tolerance,
const int16_t excess,
const bool MSBfirst) {

// If we are expecting byte sizes, check it's a factor of 8 or fail.
if (!use_bits && nbits % 8 != 0) return 0;

// Calculate if we expect a trailing space in the data section.
const bool kexpectspace = footermark || (onespace != zerospace);

// Calculate how much remaining buffer is required.
uint16_t min_remaining = nbits * 2 - (kexpectspace ? 0 : 1);

Expand All @@ -1455,7 +1462,6 @@ uint16_t IRrecv::_matchGeneric(volatile uint16_t *data_ptr,
if (hdrspace && !matchSpace(*(data_ptr + offset++), hdrspace, tolerance,
excess))
return 0;

// Data
if (use_bits) { // Bits.
match_result_t result = IRrecv::matchData(data_ptr + offset, nbits,
Expand Down
4 changes: 4 additions & 0 deletions src/IRrecv.h
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,10 @@ class IRrecv {
bool decodeBose(decode_results *results, uint16_t offset = kStartOffset,
const uint16_t nbits = kBoseBits, const bool strict = true);
#endif // DECODE_BOSE
#if DECODE_RHOSS
bool decodeRhoss(decode_results *results, uint16_t offset = kStartOffset,
const uint16_t nbits = kRhossBits, const bool strict = true);
#endif // DECODE_RHOSS
};

#endif // IRRECV_H_
15 changes: 13 additions & 2 deletions src/IRremoteESP8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,13 @@
#define SEND_ARRIS _IR_ENABLE_DEFAULT_
#endif // SEND_ARRIS

#ifndef DECODE_RHOSS
#define DECODE_RHOSS _IR_ENABLE_DEFAULT_
#endif // DECODE_RHOSS
#ifndef SEND_RHOSS
#define SEND_RHOSS _IR_ENABLE_DEFAULT_
#endif // SEND_RHOSS

#if (DECODE_ARGO || DECODE_DAIKIN || DECODE_FUJITSU_AC || DECODE_GREE || \
DECODE_KELVINATOR || DECODE_MITSUBISHI_AC || DECODE_TOSHIBA_AC || \
DECODE_TROTEC || DECODE_HAIER_AC || DECODE_HITACHI_AC || \
Expand All @@ -811,7 +818,7 @@
DECODE_HITACHI_AC344 || DECODE_CORONA_AC || DECODE_SANYO_AC || \
DECODE_VOLTAS || DECODE_MIRAGE || DECODE_HAIER_AC176 || \
DECODE_TEKNOPOINT || DECODE_KELON || DECODE_TROTEC_3550 || \
DECODE_SANYO_AC88 || \
DECODE_SANYO_AC88 || DECODE_RHOSS || \
false)
// Add any DECODE to the above if it uses result->state (see kStateSizeMax)
// you might also want to add the protocol to hasACState function
Expand Down Expand Up @@ -959,8 +966,9 @@ enum decode_type_t {
SANYO_AC88, // 105
BOSE,
ARRIS,
RHOSS,
// Add new entries before this one, and update it to point to the last entry.
kLastDecodeType = ARRIS,
kLastDecodeType = RHOSS,
};

// Message lengths & required repeat values
Expand Down Expand Up @@ -1204,6 +1212,9 @@ const uint16_t kMilesTag2ShotBits = 14;
const uint16_t kMilesTag2MsgBits = 24;
const uint16_t kMilesMinRepeat = 0;
const uint16_t kBoseBits = 16;
const uint16_t kRhossBits = 97;
const uint16_t kRhossStateLength = 12;
const uint16_t kRhossDefaultRepeat = 0;


// Legacy defines. (Deprecated)
Expand Down
7 changes: 7 additions & 0 deletions src/IRsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,8 @@ uint16_t IRsend::defaultBits(const decode_type_t protocol) {
return kWhirlpoolAcBits;
case XMP:
return kXmpBits;
case RHOSS:
return kRhossBits;
// No default amount of bits.
case FUJITSU_AC:
case MWM:
Expand Down Expand Up @@ -1303,6 +1305,11 @@ bool IRsend::send(const decode_type_t type, const uint8_t *state,
sendWhirlpoolAC(state, nbytes);
break;
#endif // SEND_WHIRLPOOL_AC
#if SEND_RHOSS
case RHOSS:
sendRhoss(state, nbytes);
break;
#endif
default:
return false;
}
Expand Down
5 changes: 5 additions & 0 deletions src/IRsend.h
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,11 @@ class IRsend {
static uint32_t toggleArrisRelease(const uint32_t data);
static uint32_t encodeArris(const uint32_t command, const bool release);
#endif // SEND_ARRIS
#if SEND_RHOSS
void sendRhoss(const unsigned char data[],
const uint16_t nbytes = kRhossStateLength,
const uint16_t repeat = kRhossDefaultRepeat);
#endif // SEND_RHOSS

protected:
#ifdef UNIT_TEST
Expand Down
1 change: 1 addition & 0 deletions src/IRtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,5 +301,6 @@ const PROGMEM char *kAllProtocolNamesStr =
D_STR_SANYO_AC88 "\x0"
D_STR_BOSE "\x0"
D_STR_ARRIS "\x0"
D_STR_RHOSS "\x0"
///< New protocol strings should be added just above this line.
"\x0"; ///< This string requires double null termination.
1 change: 1 addition & 0 deletions src/IRutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ bool hasACState(const decode_type_t protocol) {
case TROTEC_3550:
case VOLTAS:
case WHIRLPOOL_AC:
case RHOSS:
return true;
default:
return false;
Expand Down
Loading