Skip to content

Commit

Permalink
Initial support for York AC protocol (#1889)
Browse files Browse the repository at this point in the history
The protocol is known to almost every detail, checksum is calculated properly.
Some basic tests have been added.

Setting the sleep timer, scheduled power on, scheduled power off do not work
since there are some flags within byte 12 which is not correctly populated ATM.

Co-authored-by: David Conran <crankyoldgit@users.noreply.github.com>
  • Loading branch information
danielegobbetti and crankyoldgit committed Apr 26, 2023
1 parent e52495f commit fdf35b4
Show file tree
Hide file tree
Showing 13 changed files with 649 additions and 2 deletions.
18 changes: 18 additions & 0 deletions src/IRac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ bool IRac::isProtocolSupported(const decode_type_t protocol) {
#endif
#if SEND_VOLTAS
case decode_type_t::VOLTAS:
#endif
#if SEND_YORK
case decode_type_t::YORK:
#endif
case decode_type_t::WHIRLPOOL_AC:
return true;
Expand Down Expand Up @@ -4493,6 +4496,13 @@ namespace IRAcUtils {
return ac.toString();
}
#endif // DECODE_WHIRLPOOL_AC
#if DECODE_YORK
case decode_type_t::YORK: {
IRYorkAc ac(kGpioUnused);
ac.setRaw(result->state);
return ac.toString();
}
#endif // DECODE_YORK
default:
return "";
}
Expand Down Expand Up @@ -5029,6 +5039,14 @@ namespace IRAcUtils {
break;
}
#endif // DECODE_WHIRLPOOL_AC
#if DECODE_YORK
case decode_type_t::YORK: {
IRYorkAc ac(kGpioUnused);
ac.setRaw(decode->state);
*result = ac.toCommon(prev);
break;
}
#endif // DECODE_YORK
default:
return false;
}
Expand Down
1 change: 1 addition & 0 deletions src/IRac.h
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_York.h"

// Constants
const int8_t kGpioUnused = -1; ///< A placeholder for not using an actual GPIO.
Expand Down
4 changes: 4 additions & 0 deletions src/IRrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,10 @@ bool IRrecv::decode(decode_results *results, irparams_t *save,
DPRINTLN("Attempting Carrier A/C 84-bit decode");
if (decodeCarrierAC84(results, offset)) return true;
#endif // DECODE_CARRIER_AC84
#if DECODE_YORK
DPRINTLN("Attempting York decode");
if (decodeYork(results, offset, kYorkBits)) return true;
#endif // DECODE_YORK
// Typically new protocols are added above this line.
}
#if DECODE_HASH
Expand Down
6 changes: 6 additions & 0 deletions src/IRrecv.h
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,12 @@ class IRrecv {
const uint16_t nbits = kWowweeBits,
const bool strict = true);
#endif // DECODE_WOWWEE
#if DECODE_YORK
bool decodeYork(decode_results *results,
uint16_t kStartOffset,
const uint16_t kYorkBits,
const bool strict = true);
#endif // DECODE_YORK
};

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

#ifndef DECODE_YORK
#define DECODE_YORK _IR_ENABLE_DEFAULT_
#endif // DECODE_YORK
#ifndef SEND_YORK
#define SEND_YORK _IR_ENABLE_DEFAULT_
#endif // SEND_YORK

#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 @@ -963,7 +970,7 @@
DECODE_KELON168 || DECODE_HITACHI_AC296 || DECODE_CARRIER_AC128 || \
DECODE_DAIKIN200 || DECODE_HAIER_AC160 || DECODE_TCL96AC || \
DECODE_BOSCH144 || DECODE_SANYO_AC152 || DECODE_DAIKIN312 || \
DECODE_CARRIER_AC84 || \
DECODE_CARRIER_AC84 || DECODE_YORK || \
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 @@ -1129,8 +1136,9 @@ enum decode_type_t {
GORENJE,
WOWWEE,
CARRIER_AC84, // 125
YORK,
// Add new entries before this one, and update it to point to the last entry.
kLastDecodeType = CARRIER_AC84,
kLastDecodeType = YORK,
};

// Message lengths & required repeat values
Expand Down Expand Up @@ -1423,6 +1431,8 @@ const uint16_t kRhossStateLength = 12;
const uint16_t kRhossBits = kRhossStateLength * 8;
const uint16_t kRhossDefaultRepeat = 0;
const uint16_t kClimaButlerBits = 52;
const uint16_t kYorkBits = 136;
const uint16_t kYorkStateLength = 17;


// 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 @@ -796,6 +796,8 @@ uint16_t IRsend::defaultBits(const decode_type_t protocol) {
return kWhirlpoolAcBits;
case XMP:
return kXmpBits;
case YORK:
return kYorkBits;
// No default amount of bits.
case FUJITSU_AC:
case MWM:
Expand Down Expand Up @@ -1427,6 +1429,11 @@ bool IRsend::send(const decode_type_t type, const uint8_t *state,
sendWhirlpoolAC(state, nbytes);
break;
#endif // SEND_WHIRLPOOL_AC
#if SEND_YORK
case YORK:
sendYork(state, nbytes);
break;
#endif // SEND_YORK
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 @@ -879,6 +879,11 @@ class IRsend {
void sendWowwee(const uint64_t data, const uint16_t nbits = kWowweeBits,
const uint16_t repeat = kWowweeDefaultRepeat);
#endif // SEND_WOWWEE
#if SEND_YORK
void sendYork(const unsigned char data[],
const uint16_t nbytes = kYorkStateLength,
const uint16_t repeat = kNoRepeat);
#endif // SEND_YORK

protected:
#ifdef UNIT_TEST
Expand Down
2 changes: 2 additions & 0 deletions src/IRtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,8 @@ IRTEXT_CONST_BLOB_DECL(kAllProtocolNamesStr) {
D_STR_WOWWEE, D_STR_UNSUPPORTED) "\x0"
COND(DECODE_CARRIER_AC84 || SEND_CARRIER_AC84,
D_STR_CARRIER_AC84, D_STR_UNSUPPORTED) "\x0"
COND(DECODE_YORK || SEND_YORK,
D_STR_YORK, D_STR_UNSUPPORTED) "\x0"
///< New protocol (macro) strings should be added just above this line.
"\x0" ///< This string requires double null termination.
};
Expand Down
1 change: 1 addition & 0 deletions src/IRutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ bool hasACState(const decode_type_t protocol) {
case TROTEC_3550:
case VOLTAS:
case WHIRLPOOL_AC:
case YORK:
return true;
default:
return false;
Expand Down

0 comments on commit fdf35b4

Please sign in to comment.