8000 Merge pull request #105 from fmeschia/master · githubgrax/Arduino-IRremote@7c67cc5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7c67cc5

Browse files
committed
Merge pull request Arduino-IRremote#105 from fmeschia/master
Added Whynter A/C remote protocol from Arduino-IRremote#105. Credits: @fmeschia
2 parents 4fed49f + 0fce321 commit 7c67cc5

File tree

4 files changed

+108
-6
lines changed

4 files changed

+108
-6
lines changed

IRremote.cpp

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*
1616
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
1717
* LG added by Darryl Smith (based on the JVC protocol)
18+
* Whynter A/C ARC-110WD added by Francesco Meschia
1819
*/
1920

2021
#include "IRremote.h"
@@ -93,6 +94,27 @@ void IRsend::sendNEC(unsigned long data, int nbits)
9394
space(0);
9495
}
9596

97+
void IRsend::sendWhynter(unsigned long data, int nbits) {
98+
enableIROut(38);
99+
mark(WHYNTER_ZERO_MARK);
100+
space(WHYNTER_ZERO_SPACE);
101+
mark(WHYNTER_HDR_MARK);
102+
space(WHYNTER_HDR_SPACE);
103+
for (int i = 0; i < nbits; i++) {
104+
if (data & TOPBIT) {
105+
mark(WHYNTER_ONE_MARK);
106+
space(WHYNTER_ONE_SPACE);
107+
}
108+
else {
109+
mark(WHYNTER_ZERO_MARK);
110+
space(WHYNTER_ZERO_SPACE);
111+
}
112+
data <<= 1;
113+
}
114+
mark(WHYNTER_ZERO_MARK);
115+
space(WHYNTER_ZERO_SPACE);
116+
}
117+
96118
void IRsend::sendSony(unsigned long data, int nbits) {
97119
enableIROut(40);
98120
mark(SONY_HDR_MARK);
@@ -478,6 +500,12 @@ int IRrecv::decode(decode_results *results) {
478500
if (decodeSAMSUNG(results)) {
479501
return DECODED;
480502
}
503+
#ifdef DEBUG
504+
Serial.println("Attempting Whynter decode");
505+
#endif
506+
if (decodeWhynter(results)) {
507+
return DECODED;
508+
}
481509
// decodeHash returns a hash on any input.
482510
// Thus, it needs to be last in the list.
483511
// If you add any decodes, add them before this.
@@ -590,6 +618,65 @@ long IRrecv::decodeSony(decode_results *results) {
590618
return DECODED;
591619
}
592620

621+
long IRrecv::decodeWhynter(decode_results *results) {
622+
long data = 0;
623+
624+
if (irparams.rawlen < 2 * WHYNTER_BITS + 6) {
625+
return ERR;
626+
}
627+
628+
int offset = 1; // skip initial space
629+
630+
// sequence begins with a bit mark and a zero space
631+
if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) {
632+
return ERR;
633+
}
634+
offset++;
635+
if (!MATCH_SPACE(results->rawbuf[offset], WHYNTER_ZERO_SPACE)) {
636+
return ERR;
637+
}
638+
offset++;
639+
640+
// header mark and space
641+
if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_HDR_MARK)) {
642+
return ERR;
643+
}
644+
offset++;
645+
if (!MATCH_SPACE(results->rawbuf[offset], WHYNTER_HDR_SPACE)) {
646+
return ERR;
647+
}
648+
offset++;
649+
650+
// data bits
651+
for (int i = 0; i < WHYNTER_BITS; i++) {
652+
if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) {
653+
return ERR;
654+
}
655+
offset++;
656+
if (MATCH_SPACE(results->rawbuf[offset], WHYNTER_ONE_SPACE)) {
657+
data = (data << 1) | 1;
658+
}
659+
else if (MATCH_SPACE(results->rawbuf[offset],WHYNTER_ZERO_SPACE)) {
660+
data <<= 1;
661+
}
662+
else {
663+
return ERR;
664+
}
665+
offset++;
666+
}
667+
668+
// trailing mark
669+
if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) {
670+
return ERR;
671+
}
672+
// Success
673+
results->bits = WHYNTER_BITS;
674+
results->value = data;
675+
results->decode_type = WHYNTER;
676+
return DECODED;
677+
}
678+
679+
593680
// I think this is a Sanyo decoder - serial = SA 8650B
594681
// Looks like Sony except for timings, 48 chars of data and time/space different
595682
long IRrecv::decodeSanyo(decode_results *results) {

IRremote.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
* Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
1111
*
1212
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
13-
* LG added by Darryl Smith (based on the JVC protocol)
13+
* LG added by Darryl Smith (based on the JVC protocol)
14+
* Whynter A/C ARC-110WD added by Francesco Meschia
1415
*/
1516

1617
#ifndef IRremote_h
@@ -21,7 +22,7 @@
2122
// If DEBUG is defined, a lot of debugging output will be printed during decoding.
2223
// TEST must be defined for the IRtest unittests to work. It will make some
2324
// methods virtual, which will be slightly slower, which is why it is optional.
24-
// #define DEBUG
25+
//#define DEBUG
2526
// #define TEST
2627

2728
// Results returned from the decoder
@@ -51,6 +52,7 @@ class decode_results {
5152
#define MITSUBISHI 10
5253
#define SAMSUNG 11
5354
#define LG 12
55+
#define WHYNTER 13
5456
#define UNKNOWN -1
5557

5658
// Decoded value for NEC when a repeat code is received
@@ -78,11 +80,11 @@ class IRrecv
7880
long decodeLG(decode_results *results);
7981
long decodeJVC(decode_results *results);
8082
long decodeSAMSUNG(decode_results *results);
83+
long decodeWhynter(decode_results *results);
8184
long decodeHash(decode_results *results);
8285
int compare(unsigned int oldval, unsigned int newval);
8386

84-
}
85-
;
87+
} ;
8688

8789
// Only used for testing; can remove virtual for shorter code
8890
#ifdef TEST
@@ -95,6 +97,7 @@ class IRsend
9597
{
9698
public:
9799
IRsend() {}
100+
void sendWhynter(unsigned long data, int nbits);
98101
void sendNEC(unsigned long data, int nbits);
99102
void sendSony(unsigned long data, int nbits);
100103
// Neither Sanyo nor Mitsubishi send is implemented yet
@@ -113,8 +116,7 @@ class IRsend
113116
void enableIROut(int khz);
114117
VIRTUAL void mark(int usec);
115118
VIRTUAL void space(int usec);
116-
}
117-
;
119+
} ;
118120

119121
// Some useful constants
120122

IRremoteInt.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
1212
*
1313
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
14+
* Whynter A/C ARC-110WD added by Francesco Meschia
1415
*/
1516

1617
#ifndef IRremoteint_h
@@ -94,6 +95,14 @@
9495
// Pulse parms are *50-100 for the Mark and *50+100 for the space
9596
// First MARK is the one after the long gap
9697
// pulse parameters in usec
98+
#define WHYNTER_HDR_MARK 2850
99+
#define WHYNTER_HDR_SPACE 2850
100+
#define WHYNTER_BIT_MARK 750
101+
#define WHYNTER_ONE_MARK 750
102+
#define WHYNTER_ONE_SPACE 2150
103+
#define WHYNTER_ZERO_MARK 750
104+
#define WHYNTER_ZERO_SPACE 750
105+
97106
#define NEC_HDR_MARK 9000
98107
#define NEC_HDR_SPACE 4500
99108
#define NEC_BIT_MARK 560
@@ -227,6 +236,7 @@ extern volatile irparams_t irparams;
227236
#define JVC_BITS 16
228237
#define LG_BITS 28
229238
#define SAMSUNG_BITS 32
239+
#define WHYNTER_BITS 32
230240

231241

232242

examples/IRrecvDump/IRrecvDump.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ void dump(decode_results *results) {
5555
else if (results->decode_type == JVC) {
5656
Serial.print("Decoded JVC: ");
5757
}
58+
else if (results->decode_type == WHYNTER) {
59+
Serial.print("Decoded Whynter: ");
60+
}
5861
Serial.print(results->value, HEX);
5962
Serial.print(" (");
6063
Serial.print(results->bits, DEC);

0 commit comments

Comments
 (0)
0