mirror of
https://github.com/Theaninova/Arduino-IRremote.git
synced 2025-12-11 08:56:14 +00:00
Added Whynter A/C remote protocol
Tested with Whynter ARC-110WD
This commit is contained in:
87
IRremote.cpp
87
IRremote.cpp
@@ -15,6 +15,7 @@
|
||||
*
|
||||
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
|
||||
* LG added by Darryl Smith (based on the JVC protocol)
|
||||
* Whynter A/C ARC-110WD added by Francesco Meschia
|
||||
*/
|
||||
|
||||
#include "IRremote.h"
|
||||
@@ -93,6 +94,27 @@ void IRsend::sendNEC(unsigned long data, int nbits)
|
||||
space(0);
|
||||
}
|
||||
|
||||
void IRsend::sendWhynter(unsigned long data, int nbits) {
|
||||
enableIROut(38);
|
||||
mark(WHYNTER_ZERO_MARK);
|
||||
space(WHYNTER_ZERO_SPACE);
|
||||
mark(WHYNTER_HDR_MARK);
|
||||
space(WHYNTER_HDR_SPACE);
|
||||
for (int i = 0; i < nbits; i++) {
|
||||
if (data & TOPBIT) {
|
||||
mark(WHYNTER_ONE_MARK);
|
||||
space(WHYNTER_ONE_SPACE);
|
||||
}
|
||||
else {
|
||||
mark(WHYNTER_ZERO_MARK);
|
||||
space(WHYNTER_ZERO_SPACE);
|
||||
}
|
||||
data <<= 1;
|
||||
}
|
||||
mark(WHYNTER_ZERO_MARK);
|
||||
space(WHYNTER_ZERO_SPACE);
|
||||
}
|
||||
|
||||
void IRsend::sendSony(unsigned long data, int nbits) {
|
||||
enableIROut(40);
|
||||
mark(SONY_HDR_MARK);
|
||||
@@ -478,6 +500,12 @@ int IRrecv::decode(decode_results *results) {
|
||||
if (decodeSAMSUNG(results)) {
|
||||
return DECODED;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
Serial.println("Attempting Whynter decode");
|
||||
#endif
|
||||
if (decodeWhynter(results)) {
|
||||
return DECODED;
|
||||
}
|
||||
// decodeHash returns a hash on any input.
|
||||
// Thus, it needs to be last in the list.
|
||||
// If you add any decodes, add them before this.
|
||||
@@ -590,6 +618,65 @@ long IRrecv::decodeSony(decode_results *results) {
|
||||
return DECODED;
|
||||
}
|
||||
|
||||
long IRrecv::decodeWhynter(decode_results *results) {
|
||||
long data = 0;
|
||||
|
||||
if (irparams.rawlen < 2 * WHYNTER_BITS + 6) {
|
||||
return ERR;
|
||||
}
|
||||
|
||||
int offset = 1; // skip initial space
|
||||
|
||||
// sequence begins with a bit mark and a zero space
|
||||
if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) {
|
||||
return ERR;
|
||||
}
|
||||
offset++;
|
||||
if (!MATCH_SPACE(results->rawbuf[offset], WHYNTER_ZERO_SPACE)) {
|
||||
return ERR;
|
||||
}
|
||||
offset++;
|
||||
|
||||
// header mark and space
|
||||
if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_HDR_MARK)) {
|
||||
return ERR;
|
||||
}
|
||||
offset++;
|
||||
if (!MATCH_SPACE(results->rawbuf[offset], WHYNTER_HDR_SPACE)) {
|
||||
return ERR;
|
||||
}
|
||||
offset++;
|
||||
|
||||
// data bits
|
||||
for (int i = 0; i < WHYNTER_BITS; i++) {
|
||||
if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) {
|
||||
return ERR;
|
||||
}
|
||||
offset++;
|
||||
if (MATCH_SPACE(results->rawbuf[offset], WHYNTER_ONE_SPACE)) {
|
||||
data = (data << 1) | 1;
|
||||
}
|
||||
else if (MATCH_SPACE(results->rawbuf[offset],WHYNTER_ZERO_SPACE)) {
|
||||
data <<= 1;
|
||||
}
|
||||
else {
|
||||
return ERR;
|
||||
}
|
||||
offset++;
|
||||
}
|
||||
|
||||
// trailing mark
|
||||
if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) {
|
||||
return ERR;
|
||||
}
|
||||
// Success
|
||||
results->bits = WHYNTER_BITS;
|
||||
results->value = data;
|
||||
results->decode_type = WHYNTER;
|
||||
return DECODED;
|
||||
}
|
||||
|
||||
|
||||
// I think this is a Sanyo decoder - serial = SA 8650B
|
||||
// Looks like Sony except for timings, 48 chars of data and time/space different
|
||||
long IRrecv::decodeSanyo(decode_results *results) {
|
||||
|
||||
14
IRremote.h
14
IRremote.h
@@ -10,7 +10,8 @@
|
||||
* Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
|
||||
*
|
||||
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
|
||||
* LG added by Darryl Smith (based on the JVC protocol)
|
||||
* LG added by Darryl Smith (based on the JVC protocol)
|
||||
* Whynter A/C ARC-110WD added by Francesco Meschia
|
||||
*/
|
||||
|
||||
#ifndef IRremote_h
|
||||
@@ -21,7 +22,7 @@
|
||||
// If DEBUG is defined, a lot of debugging output will be printed during decoding.
|
||||
// TEST must be defined for the IRtest unittests to work. It will make some
|
||||
// methods virtual, which will be slightly slower, which is why it is optional.
|
||||
// #define DEBUG
|
||||
//#define DEBUG
|
||||
// #define TEST
|
||||
|
||||
// Results returned from the decoder
|
||||
@@ -51,6 +52,7 @@ public:
|
||||
#define MITSUBISHI 10
|
||||
#define SAMSUNG 11
|
||||
#define LG 12
|
||||
#define WHYNTER 13
|
||||
#define UNKNOWN -1
|
||||
|
||||
// Decoded value for NEC when a repeat code is received
|
||||
@@ -78,11 +80,11 @@ private:
|
||||
long decodeLG(decode_results *results);
|
||||
long decodeJVC(decode_results *results);
|
||||
long decodeSAMSUNG(decode_results *results);
|
||||
long decodeWhynter(decode_results *results);
|
||||
long decodeHash(decode_results *results);
|
||||
int compare(unsigned int oldval, unsigned int newval);
|
||||
|
||||
}
|
||||
;
|
||||
} ;
|
||||
|
||||
// Only used for testing; can remove virtual for shorter code
|
||||
#ifdef TEST
|
||||
@@ -95,6 +97,7 @@ class IRsend
|
||||
{
|
||||
public:
|
||||
IRsend() {}
|
||||
void sendWhynter(unsigned long data, int nbits);
|
||||
void sendNEC(unsigned long data, int nbits);
|
||||
void sendSony(unsigned long data, int nbits);
|
||||
// Neither Sanyo nor Mitsubishi send is implemented yet
|
||||
@@ -113,8 +116,7 @@ public:
|
||||
void enableIROut(int khz);
|
||||
VIRTUAL void mark(int usec);
|
||||
VIRTUAL void space(int usec);
|
||||
}
|
||||
;
|
||||
} ;
|
||||
|
||||
// Some useful constants
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
* Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
|
||||
*
|
||||
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
|
||||
* Whynter A/C ARC-110WD added by Francesco Meschia
|
||||
*/
|
||||
|
||||
#ifndef IRremoteint_h
|
||||
@@ -94,6 +95,14 @@
|
||||
// Pulse parms are *50-100 for the Mark and *50+100 for the space
|
||||
// First MARK is the one after the long gap
|
||||
// pulse parameters in usec
|
||||
#define WHYNTER_HDR_MARK 2850
|
||||
#define WHYNTER_HDR_SPACE 2850
|
||||
#define WHYNTER_BIT_MARK 750
|
||||
#define WHYNTER_ONE_MARK 750
|
||||
#define WHYNTER_ONE_SPACE 2150
|
||||
#define WHYNTER_ZERO_MARK 750
|
||||
#define WHYNTER_ZERO_SPACE 750
|
||||
|
||||
#define NEC_HDR_MARK 9000
|
||||
#define NEC_HDR_SPACE 4500
|
||||
#define NEC_BIT_MARK 560
|
||||
@@ -227,6 +236,7 @@ extern volatile irparams_t irparams;
|
||||
#define JVC_BITS 16
|
||||
#define LG_BITS 28
|
||||
#define SAMSUNG_BITS 32
|
||||
#define WHYNTER_BITS 32
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -55,6 +55,9 @@ void dump(decode_results *results) {
|
||||
else if (results->decode_type == JVC) {
|
||||
Serial.print("Decoded JVC: ");
|
||||
}
|
||||
else if (results->decode_type == WHYNTER) {
|
||||
Serial.print("Decoded Whynter: ");
|
||||
}
|
||||
Serial.print(results->value, HEX);
|
||||
Serial.print(" (");
|
||||
Serial.print(results->bits, DEC);
|
||||
|
||||
Reference in New Issue
Block a user