Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of Toshiba Remote Control B #2093

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 19 additions & 1 deletion src/ir_Toshiba.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ void IRToshibaAC::send(const uint16_t repeat) {
uint16_t IRToshibaAC::getInternalStateLength(const uint8_t state[],
const uint16_t size) {
if (size < kToshibaAcLengthByte) return 0;
return std::min((uint16_t)(state[kToshibaAcLengthByte] + kToshibaAcMinLength),
// Fix: Extract the last 4 bits instead
return std::min((uint16_t)((state[kToshibaAcLengthByte] & 0xF) + kToshibaAcMinLength),
kToshibaACStateLengthLong);
}

Expand Down Expand Up @@ -493,6 +494,23 @@ String IRToshibaAC::toString(void) const {
return result;
}

void IRToshibaAC::setRemoteControl(const uint8_t remote_type) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use model, as example see

void IRVoltas::setModel(const voltas_ac_remote_model_t model) {

switch (remote_type)
{
case kToshibaAcRemoteA:
case kToshibaAcRemoteB:
_.Remote = remote_type;
break;
default:
_.Remote = kToshibaAcRemoteA;
break;
}
}

uint8_t IRToshibaAC::getRemoteControl() const {
return _.Remote;
}

#if DECODE_TOSHIBA_AC
/// Decode the supplied Toshiba A/C message.
/// Status: STABLE / Working.
Expand Down
11 changes: 10 additions & 1 deletion src/ir_Toshiba.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ union ToshibaProtocol{
///< 1 (56 bit message)
///< 3 (72 bit message)
///< 4 (80 bit message)
uint8_t Length :8;
uint8_t Length :4;
// Toshiba remote type
// 0 - Remote control A
// 1 - Remote control B
uint8_t Remote :4;
// Byte[3] - The bit-inverted value of the "length" byte.
uint8_t :8;
// Byte[4]
Expand Down Expand Up @@ -111,6 +115,9 @@ const uint8_t kToshibaAcFanMax = 5; // 0b101
const uint8_t kToshibaAcTurboOn = 1; // 0b01
const uint8_t kToshibaAcEconoOn = 3; // 0b11

const uint8_t kToshibaAcRemoteA = 0; // 0b0000
const uint8_t kToshibaAcRemoteB = 1; // 0b0001

// Legacy defines. (Deprecated)
#define TOSHIBA_AC_AUTO kToshibaAcAuto
#define TOSHIBA_AC_COOL kToshibaAcCool
Expand Down Expand Up @@ -140,6 +147,8 @@ class IRToshibaAC {
void begin(void);
void on(void);
void off(void);
void setRemoteControl(const uint8_t remote_type);
uint8_t getRemoteControl() const;
void setPower(const bool on);
bool getPower(void) const;
void setTemp(const uint8_t degrees);
Expand Down
Loading