Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions src/IRrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,10 @@ bool IRrecv::decode(decode_results *results, irparams_t *save,
DPRINTLN("Attempting Sanyo AC 152-bit decode");
if (decodeSanyoAc152(results, offset)) return true;
#endif // DECODE_SANYO_AC152
#if DECODE_DAIKIN312
DPRINTLN("Attempting Daikin 312-bit decode");
if (decodeDaikin312(results, offset)) return true;
#endif // DECODE_DAIKIN312
// Typically new protocols are added above this line.
}
#if DECODE_HASH
Expand Down
7 changes: 6 additions & 1 deletion src/IRrecv.h
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,12 @@ class IRrecv {
bool decodeDaikin216(decode_results *results, uint16_t offset = kStartOffset,
const uint16_t nbits = kDaikin216Bits,
const bool strict = true);
#endif
#endif // DECODE_DAIKIN216
#if DECODE_DAIKIN312
bool decodeDaikin312(decode_results *results, uint16_t offset = kStartOffset,
const uint16_t nbits = kDaikin312Bits,
const bool strict = true);
#endif // DECODE_DAIKIN312
#if DECODE_TOSHIBA_AC
bool decodeToshibaAC(decode_results *results, uint16_t offset = kStartOffset,
const uint16_t nbits = kToshibaACBits,
Expand Down
15 changes: 13 additions & 2 deletions src/IRremoteESP8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,13 @@
#define SEND_BOSCH144 _IR_ENABLE_DEFAULT_
#endif // SEND_BOSCH144

#ifndef DECODE_DAIKIN312
#define DECODE_DAIKIN312 _IR_ENABLE_DEFAULT_
#endif // DECODE_DAIKIN312
#ifndef SEND_DAIKIN312
#define SEND_DAIKIN312 _IR_ENABLE_DEFAULT_
#endif // SEND_DAIKIN312

#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 @@ -934,7 +941,7 @@
DECODE_SANYO_AC88 || DECODE_RHOSS || DECODE_HITACHI_AC264 || \
DECODE_KELON168 || DECODE_HITACHI_AC296 || DECODE_CARRIER_AC128 || \
DECODE_DAIKIN200 || DECODE_HAIER_AC160 || DECODE_TCL96AC || \
DECODE_BOSCH144 || DECODE_SANYO_AC152 || \
DECODE_BOSCH144 || DECODE_SANYO_AC152 || DECODE_DAIKIN312 || \
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 @@ -1096,8 +1103,9 @@ enum decode_type_t {
TCL96AC,
BOSCH144, // 120
SANYO_AC152,
DAIKIN312,
// Add new entries before this one, and update it to point to the last entry.
kLastDecodeType = SANYO_AC152,
kLastDecodeType = DAIKIN312,
};

// Message lengths & required repeat values
Expand Down Expand Up @@ -1164,6 +1172,9 @@ const uint16_t kDaikin200DefaultRepeat = kNoRepeat;
const uint16_t kDaikin216StateLength = 27;
const uint16_t kDaikin216Bits = kDaikin216StateLength * 8;
const uint16_t kDaikin216DefaultRepeat = kNoRepeat;
const uint16_t kDaikin312StateLength = 39;
const uint16_t kDaikin312Bits = kDaikin312StateLength * 8;
const uint16_t kDaikin312DefaultRepeat = kNoRepeat;
const uint16_t kDelonghiAcBits = 64;
const uint16_t kDelonghiAcDefaultRepeat = kNoRepeat;
const uint16_t kTechnibelAcBits = 56;
Expand Down
7 changes: 7 additions & 0 deletions src/IRsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,8 @@ uint16_t IRsend::defaultBits(const decode_type_t protocol) {
return kDaikin200Bits;
case DAIKIN216:
return kDaikin216Bits;
case DAIKIN312:
return kDaikin312Bits;
case DAIKIN64:
return kDaikin64Bits;
case ELECTRA_AC:
Expand Down Expand Up @@ -1207,6 +1209,11 @@ bool IRsend::send(const decode_type_t type, const uint8_t *state,
sendDaikin216(state, nbytes);
break;
#endif // SEND_DAIKIN216
#if SEND_DAIKIN312
case DAIKIN312:
sendDaikin312(state, nbytes);
break;
#endif // SEND_DAIKIN312
#if SEND_ELECTRA_AC
case ELECTRA_AC:
sendElectraAC(state, nbytes);
Expand Down
7 changes: 6 additions & 1 deletion src/IRsend.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,12 @@ class IRsend {
void sendDaikin216(const unsigned char data[],
const uint16_t nbytes = kDaikin216StateLength,
const uint16_t repeat = kDaikin216DefaultRepeat);
#endif
#endif // SEND_DAIKIN216
#if SEND_DAIKIN312
void sendDaikin312(const unsigned char data[],
const uint16_t nbytes = kDaikin312StateLength,
const uint16_t repeat = kDaikin312DefaultRepeat);
#endif // SEND_DAIKIN312
#if SEND_AIWA_RC_T501
void sendAiwaRCT501(uint64_t data, uint16_t nbits = kAiwaRcT501Bits,
uint16_t repeat = kAiwaRcT501MinRepeats);
Expand Down
1 change: 1 addition & 0 deletions src/IRtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ IRTEXT_CONST_BLOB_DECL(kAllProtocolNamesStr) {
D_STR_TCL96AC "\x0"
D_STR_BOSCH144 "\x0"
D_STR_SANYO_AC152 "\x0"
D_STR_DAIKIN312 "\x0"
///< New protocol 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 @@ -183,6 +183,7 @@ bool hasACState(const decode_type_t protocol) {
case DAIKIN2:
case DAIKIN200:
case DAIKIN216:
case DAIKIN312:
case ELECTRA_AC:
case FUJITSU_AC:
case GREE:
Expand Down
105 changes: 105 additions & 0 deletions src/ir_Daikin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3819,3 +3819,108 @@ bool IRrecv::decodeDaikin200(decode_results *results, uint16_t offset,
return true;
}
#endif // DECODE_DAIKIN200

#if SEND_DAIKIN312
/// Send a Daikin312 (312-bit / 39 byte) A/C formatted message.
/// Status: BETA / Untested on a real device.
/// @param[in] data The message to be sent.
/// @param[in] nbytes The number of bytes of message to be sent.
/// @param[in] repeat The number of times the command is to be repeated.
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/1829
void IRsend::sendDaikin312(const unsigned char data[], const uint16_t nbytes,
const uint16_t repeat) {
if (nbytes < kDaikin312Section1Length)
return; // Not enough bytes to send a partial message.

for (uint16_t r = 0; r <= repeat; r++) {
// Send the header, 0b00000
sendGeneric(0, 0, // No header for the header
kDaikin312BitMark, kDaikin312OneSpace,
kDaikin312BitMark, kDaikin312ZeroSpace,
kDaikin312BitMark, kDaikin312HdrGap,
(uint64_t)0b00000, kDaikinHeaderLength,
kDaikin2Freq, false, 0, kDutyDefault);
// Section #1
sendGeneric(kDaikin312HdrMark, kDaikin312HdrSpace, kDaikin312BitMark,
kDaikin312OneSpace, kDaikin312BitMark, kDaikin312ZeroSpace,
kDaikin312BitMark, kDaikin312SectionGap, data,
kDaikin312Section1Length,
kDaikin2Freq, false, 0, kDutyDefault);
// Section #2
sendGeneric(kDaikin312HdrMark, kDaikin312HdrSpace, kDaikin312BitMark,
kDaikin312OneSpace, kDaikin312BitMark, kDaikin312ZeroSpace,
kDaikin312BitMark, kDaikin312SectionGap,
data + kDaikin312Section1Length,
nbytes - kDaikin312Section1Length,
kDaikin2Freq, false, 0, kDutyDefault);
}
}
#endif // SEND_DAIKIN312

#if DECODE_DAIKIN312
/// Decode the supplied Daikin 312-bit / 39-byte message. (DAIKIN312)
/// Status: STABLE / Confirmed working.
/// @param[in,out] results Ptr to the data to decode & where to store the decode
/// result.
/// @param[in] offset The starting index to use when attempting to decode the
/// raw data. Typically/Defaults to kStartOffset.
/// @param[in] nbits The number of data bits to expect.
/// @param[in] strict Flag indicating if we should perform strict matching.
/// @return A boolean. True if it can decode it, false if it can't.
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/1829
bool IRrecv::decodeDaikin312(decode_results *results, uint16_t offset,
const uint16_t nbits, const bool strict) {
// Is there enough data to match successfully?
if (results->rawlen < 2 * (nbits + kDaikinHeaderLength + kHeader + kFooter) +
kFooter - 1 + offset)
return false;

// Compliance
if (strict && nbits != kDaikin312Bits) return false;

const uint8_t ksectionSize[kDaikin312Sections] = {kDaikin312Section1Length,
kDaikin312Section2Length};
// Header/Leader Section
uint64_t leaderdata = 0;
uint16_t used = matchGeneric(results->rawbuf + offset, &leaderdata,
results->rawlen - offset, kDaikinHeaderLength,
0, 0, // No Header Mark or Space for the "header"
kDaikin312BitMark, kDaikin312OneSpace,
kDaikin312BitMark, kDaikin312ZeroSpace,
kDaikin312BitMark, kDaikin312HdrGap,
false, kDaikinTolerance, 0, false);
if (!used) return false; // Failed to match.
if (leaderdata) return false; // The header bits should all be zero.

offset += used;

// Data Sections
uint16_t pos = 0;
for (uint8_t section = 0; section < kDaikin312Sections; section++) {
// Section Header + Section Data + Section Footer
used = matchGeneric(results->rawbuf + offset, results->state + pos,
results->rawlen - offset, ksectionSize[section] * 8,
kDaikin312HdrMark, kDaikin312HdrSpace,
kDaikin312BitMark, kDaikin312OneSpace,
kDaikin312BitMark, kDaikin312ZeroSpace,
kDaikin312BitMark, kDaikin312SectionGap,
section >= kDaikin312Sections - 1,
kDaikinTolerance, 0, false);
if (used == 0) return false;
offset += used;
pos += ksectionSize[section];
}
// Compliance
if (strict) {
if (pos * 8 != kDaikin312Bits) return false;
}

// Success
results->decode_type = decode_type_t::DAIKIN312;
results->bits = nbits;
// No need to record the state as we stored it as we decoded it.
// As we use result->state, we don't record value, address, or command as it
// is a union data type.
return true;
}
#endif // DECODE_DAIKIN312
17 changes: 16 additions & 1 deletion src/ir_Daikin.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2016 sillyfrog
// Copyright 2017 sillyfrog, crankyoldgit
// Copyright 2018-2021 crankyoldgit
// Copyright 2018-2022 crankyoldgit
// Copyright 2019 pasna (IRDaikin160 class / Daikin176 class)

/// @file
Expand All @@ -22,6 +22,7 @@
/// @see Daikin216 https://github.com/danny-source/Arduino_DY_IRDaikin
/// @see Daikin64 https://github.com/crankyoldgit/IRremoteESP8266/issues/1064
/// @see Daikin200 https://github.com/crankyoldgit/IRremoteESP8266/issues/1802
/// @see Daikin312 https://github.com/crankyoldgit/IRremoteESP8266/issues/1829

// Supports:
// Brand: Daikin, Model: ARC433** remote (DAIKIN)
Expand Down Expand Up @@ -50,6 +51,8 @@
// Brand: Daikin, Model: ARC484A4 remote (DAIKIN216)
// Brand: Daikin, Model: FTQ60TV16U2 A/C (DAIKIN216)
// Brand: Daikin, Model: BRC4M150W16 remote (DAIKIN200)
// Brand: Daikin, Model: FTXM20R5V1B A/C (DAIKIN312)
// Brand: Daikin, Model: ARC466A67 remote (DAIKIN312)

#ifndef IR_DAIKIN_H_
#define IR_DAIKIN_H_
Expand Down Expand Up @@ -691,6 +694,18 @@ const uint16_t kDaikin200Section1Length = 7;
const uint16_t kDaikin200Section2Length = kDaikin200StateLength -
kDaikin200Section1Length;

const uint16_t kDaikin312HdrMark = 3518;
const uint16_t kDaikin312HdrSpace = 1688;
const uint16_t kDaikin312BitMark = 453;
const uint16_t kDaikin312ZeroSpace = 414;
const uint16_t kDaikin312OneSpace = 1275;
const uint16_t kDaikin312HdrGap = 25100;
const uint16_t kDaikin312SectionGap = 35512;
const uint16_t kDaikin312Sections = 2;
const uint16_t kDaikin312Section1Length = 20;
const uint16_t kDaikin312Section2Length = kDaikin312StateLength -
kDaikin312Section1Length;

// Legacy defines.
#define DAIKIN_COOL kDaikinCool
#define DAIKIN_HEAT kDaikinHeat
Expand Down
3 changes: 3 additions & 0 deletions src/locale/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,9 @@ D_STR_INDIRECT " " D_STR_MODE
#ifndef D_STR_DAIKIN216
#define D_STR_DAIKIN216 D_STR_DAIKIN "216"
#endif // D_STR_DAIKIN216
#ifndef D_STR_DAIKIN312
#define D_STR_DAIKIN312 D_STR_DAIKIN "312"
#endif // D_STR_DAIKIN312
#ifndef D_STR_DAIKIN64
#define D_STR_DAIKIN64 D_STR_DAIKIN "64"
#endif // D_STR_DAIKIN64
Expand Down
Loading