Sitelet https://github.com/angeldeejay/IRremoteESP8266/commit/26d30f9662847952ac036f5d8e21239b8f5fb5e5
Skip to content

Commit 26d30f9

Browse files
authored
Add support for SYMPHONY 11 bit protocol. (crankyoldgit#1058)
* basic `sendSymphony()`/`decodeSymphony()` added. * Update basic housekeeping to support new protocol. * Unit tests for new protocol. Fixes crankyoldgit#1057
1 parent ce495a4 commit 26d30f9

11 files changed

Lines changed: 300 additions & 6 deletions

File tree

‎SupportedProtocols.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--- WARNING: Do NOT edit this file directly.
22
It is generated by './tools/scrape_supported_devices.py'.
3-
Last generated: Wed Feb 26 16:31:08 2020 --->
3+
Last generated: Sat Mar 7 23:57:26 2020 --->
44
# IR Protocols supported by this library
55

66
| Protocol | Brand | Model | A/C Model | Detailed A/C Support |
@@ -61,6 +61,7 @@
6161
| [Sharp](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/ir_Sharp.cpp) | **[Sharp](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/ir_Sharp.h)** | AY-ZP40KR A/C<BR>LC-52D62U TV | | Yes |
6262
| [Sherwood](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/ir_Sherwood.cpp) | **Sherwood** | RC-138 remote<BR>RD6505(B) Receiver | | - |
6363
| [Sony](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/ir_Sony.cpp) | **Sony** | HT-CT380 Soundbar (Uses 38kHz & 3 repeats) | | - |
64+
| [Symphony](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/ir_Symphony.cpp) | **Symphony** | Air Cooler 3Di | | - |
6465
| [Tcl](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/ir_Tcl.cpp) | **[Leberg](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/ir_Tcl.h)** | LBS-TOR07 A/C | | Yes |
6566
| [Teco](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/ir_Teco.cpp) | **[Alaska](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/ir_Teco.h)** | SAC9010QC A/C<BR>SAC9010QC remote | | Yes |
6667
| [Toshiba](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/ir_Toshiba.cpp) | **[Toshiba](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/ir_Toshiba.h)** | Akita EVO II<BR>RAS 18SKP-ES<BR>RAS-B13N3KV2<BR>RAS-B13N3KVP-E<BR>WC-L03SE<BR>WH-TA04NE | | Yes |
@@ -144,6 +145,7 @@
144145
- SHARP
145146
- SHARP_AC
146147
- SONY
148+
- SYMPHONY
147149
- TCL112AC
148150
- TECO
149151
- TOSHIBA_AC

‎src/IRrecv.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,8 +763,12 @@ bool IRrecv::decode(decode_results *results, irparams_t *save,
763763
DPRINTLN("Attempting Mitsubishi136 decode");
764764
if (decodeMitsubishi136(results, offset)) return true;
765765
#endif // DECODE_MITSUBISHI136
766-
}
766+
#if DECODE_SYMPHONY
767+
DPRINTLN("Attempting Symphony decode");
768+
if (decodeSymphony(results, offset)) return true;
769+
#endif // DECODE_SYMPHONY
767770
// Typically new protocols are added above this line.
771+
}
768772
#if DECODE_HASH
769773
// decodeHash returns a hash on any input.
770774
// Thus, it needs to be last in the list.

‎src/IRrecv.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,11 @@ class IRrecv {
558558
const uint16_t nbits = kEpsonBits,
559559
const bool strict = true);
560560
#endif // DECODE_EPSON
561+
#if DECODE_SYMPHONY
562+
bool decodeSymphony(decode_results *results, uint16_t offset = kStartOffset,
563+
const uint16_t nbits = kSymphonyBits,
564+
const bool strict = true);
565+
#endif // DECODE_SYMPHONY
561566
};
562567

563568
#endif // IRRECV_H_

‎src/IRremoteESP8266.h‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,13 @@
572572
#define SEND_EPSON _IR_ENABLE_DEFAULT_
573573
#endif // SEND_EPSON
574574

575+
#ifndef DECODE_SYMPHONY
576+
#define DECODE_SYMPHONY _IR_ENABLE_DEFAULT_
577+
#endif // DECODE_SYMPHONY
578+
#ifndef SEND_SYMPHONY
579+
#define SEND_SYMPHONY _IR_ENABLE_DEFAULT_
580+
#endif // SEND_SYMPHONY
581+
575582
#if (DECODE_ARGO || DECODE_DAIKIN || DECODE_FUJITSU_AC || DECODE_GREE || \
576583
DECODE_KELVINATOR || DECODE_MITSUBISHI_AC || DECODE_TOSHIBA_AC || \
577584
DECODE_TROTEC || DECODE_HAIER_AC || DECODE_HITACHI_AC || \
@@ -695,8 +702,9 @@ enum decode_type_t {
695702
HITACHI_AC424,
696703
SONY_38K,
697704
EPSON, // 75
705+
SYMPHONY,
698706
// Add new entries before this one, and update it to point to the last entry.
699-
kLastDecodeType = EPSON,
707+
kLastDecodeType = SYMPHONY,
700708
};
701709

702710
// Message lengths & required repeat values
@@ -857,6 +865,8 @@ const uint16_t kSony15Bits = 15;
857865
const uint16_t kSony20Bits = 20;
858866
const uint16_t kSonyMinBits = 12;
859867
const uint16_t kSonyMinRepeat = 2;
868+
const uint16_t kSymphonyBits = 11;
869+
const uint16_t kSymphonyDefaultRepeat = kSingleRepeat;
860870
const uint16_t kTcl112AcStateLength = 14;
861871
const uint16_t kTcl112AcBits = kTcl112AcStateLength * 8;
862872
const uint16_t kTcl112AcDefaultRepeat = kNoRepeat;

‎src/IRsend.cpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ uint16_t IRsend::minRepeats(const decode_type_t protocol) {
509509
case MITSUBISHI2:
510510
case MITSUBISHI_AC:
511511
case SHERWOOD:
512+
case SYMPHONY:
512513
case TOSHIBA_AC:
513514
return kSingleRepeat;
514515
// Special
@@ -532,6 +533,8 @@ uint16_t IRsend::minRepeats(const decode_type_t protocol) {
532533
// int16_t: The number of bits.
533534
uint16_t IRsend::defaultBits(const decode_type_t protocol) {
534535
switch (protocol) {
536+
case SYMPHONY:
537+
return 11;
535538
case RC5:
536539
return 12;
537540
case LASERTAG:
@@ -834,6 +837,11 @@ bool IRsend::send(const decode_type_t type, const uint64_t data,
834837
sendSony38(data, nbits, min_repeat);
835838
break;
836839
#endif
840+
#if SEND_SYMPHONY
841+
case SYMPHONY:
842+
sendSymphony(data, nbits, min_repeat);
843+
break;
844+
#endif
837845
#if SEND_TECO
838846
case TECO:
839847
sendTeco(data, nbits, min_repeat);

‎src/IRsend.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,10 @@ class IRsend {
539539
void sendEpson(uint64_t data, uint16_t nbits = kEpsonBits,
540540
uint16_t repeat = kEpsonMinRepeat);
541541
#endif
542+
#if SEND_SYMPHONY
543+
void sendSymphony(uint64_t data, uint16_t nbits = kSymphonyBits,
544+
uint16_t repeat = kSymphonyDefaultRepeat);
545+
#endif
542546

543547
protected:
544548
#ifdef UNIT_TEST

‎src/IRutils.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ decode_type_t strToDecodeType(const char * const str) {
232232
return decode_type_t::SONY;
233233
else if (!strcasecmp(str, "SONY_38K"))
234234
return decode_type_t::SONY_38K;
235+
else if (!strcasecmp(str, "SYMPHONY"))
236+
return decode_type_t::SYMPHONY;
235237
else if (!strcasecmp(str, "TCL112AC"))
236238
return decode_type_t::TCL112AC;
237239
else if (!strcasecmp(str, "TECO"))
@@ -471,6 +473,9 @@ String typeToString(const decode_type_t protocol, const bool isRepeat) {
471473
case SONY_38K:
472474
result = F("SONY_38K");
473475
break;
476+
case SYMPHONY:
477+
result = F("SYMPHONY");
478+
break;
474479
case TCL112AC:
475480
result = F("TCL112AC");
476481
break;

‎src/ir_Symphony.cpp‎

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Copyright 2020 David Conran
2+
3+
// Send & decode support for Symphony added by David Conran
4+
5+
// Supports:
6+
// Brand: Symphony, Model: Air Cooler 3Di
7+
8+
#include <algorithm>
9+
#include "IRrecv.h"
10+
#include "IRsend.h"
11+
#include "IRtimer.h"
12+
#include "IRutils.h"
13+
14+
// Constants
15+
// Ref:
16+
// https://github.com/crankyoldgit/IRremoteESP8266/issues/1057
17+
const uint16_t kSymphonyZeroMark = 1250;
18+
const uint16_t kSymphonyZeroSpace = 400;
19+
const uint16_t kSymphonyOneMark = kSymphonyZeroSpace;
20+
const uint16_t kSymphonyOneSpace = kSymphonyZeroMark;
21+
const uint16_t kSymphonyFooterMark = kSymphonyOneMark;
22+
const uint32_t kSymphonyFooterGap = 8000;
23+
24+
#if SEND_SYMPHONY
25+
// Send a Symphony packet.
26+
//
27+
// Args:
28+
// data: The data we want to send. MSB first.
29+
// nbits: The number of bits of data to send. (Typically 12, 24, or 32[Nokia])
30+
// repeat: The nr. of times the message should be sent.
31+
//
32+
// Status: BETA / Should be working.
33+
//
34+
// Ref:
35+
// https://github.com/crankyoldgit/IRremoteESP8266/issues/1057
36+
void IRsend::sendSymphony(uint64_t data, uint16_t nbits, uint16_t repeat) {
37+
sendGeneric(0, 0,
38+
kSymphonyOneMark, kSymphonyOneSpace,
39+
kSymphonyZeroMark, kSymphonyZeroSpace,
40+
kSymphonyFooterMark, kSymphonyFooterGap,
41+
data, nbits, 38000, true, repeat, kDutyDefault);
42+
}
43+
#endif // SEND_SYMPHONY
44+
45+
#if DECODE_SYMPHONY
46+
// Decode a Symphony packet if possible.
47+
// Places successful decode information in the results pointer.
48+
// Args:
49+
// results: Ptr to the data to decode and where to store the decode result.
50+
// offset: The starting index to use when attempting to decode the raw data.
51+
// Typically/Defaults to kStartOffset.
52+
// nbits: Nr. of bits to expect in the data portion. Typically kSymphonyBits
53+
// strict: Flag to indicate if we strictly adhere to the specification.
54+
// Returns:
55+
// boolean: True if it can decode it, false if it can't.
56+
//
57+
// Status: BETA / Should be working.
58+
//
59+
// Ref:
60+
//
61+
bool IRrecv::decodeSymphony(decode_results *results, uint16_t offset,
62+
const uint16_t nbits, const bool strict) {
63+
uint64_t data = 0;
64+
65+
if (results->rawlen < 2 * nbits + kFooter + offset - 1)
66+
return false; // Not enough entries to ever be SYMPHONY.
67+
// Compliance
68+
if (strict && nbits != kSymphonyBits) return false;
69+
70+
if (!matchGeneric(results->rawbuf + offset, &data, results->rawlen - offset,
71+
nbits,
72+
0, 0, // No Header
73+
kSymphonyOneMark, kSymphonyOneSpace,
74+
kSymphonyZeroMark, kSymphonyZeroSpace,
75+
kSymphonyFooterMark, kSymphonyFooterGap, true,
76+
_tolerance, 0))
77+
return false;
78+
79+
// Success
80+
results->value = data;
81+
results->decode_type = decode_type_t::SYMPHONY;
82+
results->bits = nbits;
83+
results->address = 0;
84+
results->command = 0;
85+
return true;
86+
}
87+
#endif // DECODE_SYMPHONY

‎test/Makefile‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ TESTS = IRutils_test IRsend_test ir_NEC_test ir_GlobalCache_test \
3939
ir_Whirlpool_test ir_Lutron_test ir_Electra_test ir_Pioneer_test \
4040
ir_MWM_test ir_Vestel_test ir_Teco_test ir_Tcl_test ir_Lego_test IRac_test \
4141
ir_MitsubishiHeavy_test ir_Trotec_test ir_Argo_test ir_Goodweather_test \
42-
ir_Inax_test ir_Neoclima_test ir_Amcor_test ir_Epson_test
42+
ir_Inax_test ir_Neoclima_test ir_Amcor_test ir_Epson_test ir_Symphony_test
4343

4444
# All Google Test headers. Usually you shouldn't change this
4545
# definition.
@@ -85,7 +85,7 @@ PROTOCOLS = ir_NEC.o ir_Sony.o ir_Samsung.o ir_JVC.o ir_RCMM.o ir_RC5_RC6.o \
8585
ir_Hitachi.o ir_GICable.o ir_Whirlpool.o ir_Lutron.o ir_Electra.o \
8686
ir_Pioneer.o ir_MWM.o ir_Vestel.o ir_Teco.o ir_Tcl.o ir_Lego.o ir_Argo.o \
8787
ir_Trotec.o ir_MitsubishiHeavy.o ir_Goodweather.o ir_Inax.o ir_Neoclima.o \
88-
ir_Amcor.o ir_Epson.o
88+
ir_Amcor.o ir_Epson.o ir_Symphony.o
8989

9090
# All the IR Protocol header files.
9191
PROTOCOLS_H = $(USER_DIR)/ir_Amcor.h \
@@ -632,3 +632,12 @@ ir_Epson_test.o : ir_Epson_test.cpp $(COMMON_TEST_DEPS) $(GTEST_HEADERS)
632632

633633
ir_Epson_test : $(COMMON_OBJ) ir_Epson_test.o
634634
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@
635+
636+
ir_Symphony.o : $(USER_DIR)/ir_Symphony.cpp $(COMMON_DEPS)
637+
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) -c $(USER_DIR)/ir_Symphony.cpp
638+
639+
ir_Symphony_test.o : ir_Symphony_test.cpp $(COMMON_TEST_DEPS) $(GTEST_HEADERS)
640+
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) -c ir_Symphony_test.cpp
641+
642+
ir_Symphony_test : $(COMMON_OBJ) ir_Symphony_test.o
643+
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@

0 commit comments

Comments
 (0)