Skip to content

Commit

Permalink
Add basic Zepeal protocol support (#1178)
Browse files Browse the repository at this point in the history
  • Loading branch information
NiKiZe authored Jun 8, 2020
1 parent 373afa5 commit bb527d9
Show file tree
Hide file tree
Showing 9 changed files with 442 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/IRrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,10 @@ bool IRrecv::decode(decode_results *results, irparams_t *save,
DPRINTLN("Attempting Midea-Nec decode");
if (decodeMidea24(results, offset)) return true;
#endif // DECODE_MIDEA24
#if DECODE_ZEPEAL
DPRINTLN("Attempting Zepeal decode");
if (decodeZepeal(results, offset)) return true;
#endif // DECODE_ZEPEAL
// Typically new protocols are added above this line.
}
#if DECODE_HASH
Expand Down
5 changes: 5 additions & 0 deletions src/IRrecv.h
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,11 @@ class IRrecv {
const uint16_t nbits = kCoronaAcBitsShort,
const bool strict = true);
#endif // DECODE_CORONA_AC
#if DECODE_ZEPEAL
bool decodeZepeal(decode_results *results, uint16_t offset = kStartOffset,
const uint16_t nbits = kZepealBits,
const bool strict = true);
#endif // DECODE_ZEPEAL
};

#endif // IRRECV_H_
11 changes: 10 additions & 1 deletion src/IRremoteESP8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,12 @@
#ifndef SEND_MULTIBRACKETS
#define SEND_MULTIBRACKETS _IR_ENABLE_DEFAULT_
#endif // SEND_MULTIBRACKETS
#ifndef DECODE_ZEPEAL
#define DECODE_ZEPEAL _IR_ENABLE_DEFAULT_
#endif // DECODE_ZEPEAL
#ifndef SEND_ZEPEAL
#define SEND_ZEPEAL _IR_ENABLE_DEFAULT_
#endif // SEND_ZEPEAL

#ifndef DECODE_CORONA_AC
#define DECODE_CORONA_AC _IR_ENABLE_DEFAULT_
Expand Down Expand Up @@ -794,8 +800,9 @@ enum decode_type_t {
HITACHI_AC344, // 85
CORONA_AC,
MIDEA24,
ZEPEAL,
// Add new entries before this one, and update it to point to the last entry.
kLastDecodeType = MIDEA24,
kLastDecodeType = ZEPEAL,
};

// Message lengths & required repeat values
Expand Down Expand Up @@ -999,6 +1006,8 @@ const uint16_t kWhirlpoolAcBits = kWhirlpoolAcStateLength * 8;
const uint16_t kWhirlpoolAcDefaultRepeat = kNoRepeat;
const uint16_t kWhynterBits = 32;
const uint8_t kVestelAcBits = 56;
const uint16_t kZepealBits = 16;
const uint16_t kZepealMinRepeat = 4;


// Legacy defines. (Deprecated)
Expand Down
8 changes: 8 additions & 0 deletions src/IRsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,8 @@ uint16_t IRsend::minRepeats(const decode_type_t protocol) {
return kSonyMinRepeat + 1;
case SYMPHONY:
return kSymphonyDefaultRepeat;
case ZEPEAL:
return kZepealMinRepeat;
default:
return kNoRepeat;
}
Expand Down Expand Up @@ -617,6 +619,7 @@ uint16_t IRsend::defaultBits(const decode_type_t protocol) {
case LEGOPF:
case MITSUBISHI:
case MITSUBISHI2:
case ZEPEAL:
return 16;
case RC6:
case SONY:
Expand Down Expand Up @@ -978,6 +981,11 @@ bool IRsend::send(const decode_type_t type, const uint64_t data,
case WHYNTER:
sendWhynter(data, nbits, min_repeat);
break;
#endif
#if SEND_ZEPEAL
case ZEPEAL:
sendZepeal(data, nbits, min_repeat);
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 @@ -624,6 +624,11 @@ class IRsend {
const uint16_t nbytes = kCoronaAcStateLength,
const uint16_t repeat = kNoRepeat);
#endif // SEND_CORONA_AC
#if SEND_ZEPEAL
void sendZepeal(const uint64_t data,
const uint16_t nbits = kZepealBits,
const uint16_t repeat = kZepealMinRepeat);
#endif

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 @@ -262,5 +262,6 @@ const PROGMEM char *kAllProtocolNamesStr =
D_STR_HITACHI_AC344 "\x0"
D_STR_CORONA_AC "\x0"
D_STR_MIDEA24 "\x0"
D_STR_ZEPEAL "\x0"
// New protocol strings should be added just above this line.
"\x0"; // This string requires double null termination.
94 changes: 94 additions & 0 deletions src/ir_Zepeal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Copyright 2020 Christian Nilsson (nikize)

/// @file
/// @brief Support for Zepeal protocol.
/// This protocol uses fixed length bit encoding.
/// Most official information about Zepeal seems to be from Denkyosha
/// @see https://www.denkyosha.co.jp/

// Supports:
// Brand: Zepeal, Model: DRT-A3311(BG) floor fan
// Brand: Zepeal, Model: DRT-A3311(BG) 5 button remote

#include "IRrecv.h"
#include "IRsend.h"
#include "IRutils.h"

// Constants

const uint16_t kZepealHdrMark = 2330;
const uint16_t kZepealHdrSpace = 3380;
const uint16_t kZepealOneMark = 1300;
const uint16_t kZepealZeroMark = 420;
const uint16_t kZepealOneSpace = kZepealZeroMark;
const uint16_t kZepealZeroSpace = kZepealOneMark;
const uint16_t kZepealFooterMark = 420;
const uint16_t kZepealGap = 6750;

const uint8_t kZepealTolerance = 40;

// Signature limits possible false possitvies,
// but might need change (removal) if more devices are detected
const uint8_t kZepealSignature = 0x6C;

// Known Zepeal DRT-A3311(BG) Buttons - documentation rather than actual usage
const uint16_t kZepealCommandSpeed = 0x6C82;
const uint16_t kZepealCommandOffOn = 0x6C81;
const uint16_t kZepealCommandRhythm = 0x6C84;
const uint16_t kZepealCommandOffTimer = 0x6C88;
const uint16_t kZepealCommandOnTimer = 0x6CC3;

#if SEND_ZEPEAL
/// Send a Zepeal formatted message.
/// Status: STABLE / Works on real device.
/// @param[in] data The message to be sent.
/// @param[in] nbits The bit size of the message being sent.
/// @param[in] repeat The number of times the message is to be repeated.
void IRsend::sendZepeal(const uint64_t data, const uint16_t nbits,
const uint16_t repeat) {
sendGeneric(kZepealHdrMark, kZepealHdrSpace,
kZepealOneMark, kZepealOneSpace,
kZepealZeroMark, kZepealZeroSpace,
kZepealFooterMark, kZepealGap,
data, nbits, 38, true, repeat, kDutyDefault);
}
#endif // SEND_ZEPEAL

#if DECODE_ZEPEAL
/// Decode the supplied Zepeal message.
/// Status: STABLE / Works on real device.
/// @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. Typically kZepealBits.
/// @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.
bool IRrecv::decodeZepeal(decode_results *results, uint16_t offset,
const uint16_t nbits, const bool strict) {
if (results->rawlen < 2 * nbits + kHeader + kFooter - 1 + offset)
return false; // Can't possibly be a valid message.
if (strict && nbits != kZepealBits)
return false; // Not strictly a message.

uint64_t data = 0;
uint16_t used;
used = matchGeneric(results->rawbuf + offset, &data,
results->rawlen - offset, nbits,
kZepealHdrMark, kZepealHdrSpace,
kZepealOneMark, kZepealOneSpace,
kZepealZeroMark, kZepealZeroSpace,
kZepealFooterMark, kZepealGap, true,
kZepealTolerance);
if (!used) return false;
if (strict && (data >> 8) != kZepealSignature) return false;

// Success
results->value = data;
results->decode_type = decode_type_t::ZEPEAL;
results->bits = nbits;
results->address = 0;
results->command = 0;
return true;
}
#endif // DECODE_ZEPEAL
3 changes: 3 additions & 0 deletions src/locale/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,9 @@
#ifndef D_STR_WHYNTER
#define D_STR_WHYNTER "WHYNTER"
#endif // D_STR_WHYNTER
#ifndef D_STR_ZEPEAL
#define D_STR_ZEPEAL "ZEPEAL"
#endif // D_STR_ZEPEAL

// IRrecvDumpV2+
#ifndef D_STR_TIMESTAMP
Expand Down
Loading

0 comments on commit bb527d9

Please sign in to comment.