mirror of
https://github.com/Theaninova/Arduino-IRremote.git
synced 2025-12-11 08:56:14 +00:00
Added Aiwa protocol (remote control RC-T501).
Added Aiwa protocol (remote control RC-T501) based on lirc file. Updated IRrecvDump example, added SendDemo example (AiwaRCT501SendDemo).
This commit is contained in:
116
IRremote.cpp
116
IRremote.cpp
@@ -506,6 +506,13 @@ int IRrecv::decode(decode_results *results) {
|
||||
if (decodeWhynter(results)) {
|
||||
return DECODED;
|
||||
}
|
||||
// Aiwa RC-T501
|
||||
#ifdef DEBUG
|
||||
Serial.println("Attempting Aiwa RC-T501 decode");
|
||||
#endif
|
||||
if (decodeAiwaRCT501(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.
|
||||
@@ -1117,6 +1124,65 @@ long IRrecv::decodeSAMSUNG(decode_results *results) {
|
||||
return DECODED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aiwa system
|
||||
* Remote control RC-T501
|
||||
* Lirc file http://lirc.sourceforge.net/remotes/aiwa/RC-T501
|
||||
*
|
||||
*/
|
||||
long IRrecv::decodeAiwaRCT501(decode_results *results) {
|
||||
int data = 0;
|
||||
int offset = 1; // skip first garbage read
|
||||
|
||||
// Check SIZE
|
||||
if(irparams.rawlen < 2 * (AIWA_RC_T501_SUM_BITS) + 4) {
|
||||
return ERR;
|
||||
}
|
||||
|
||||
// Check HDR
|
||||
if(!MATCH_MARK(results->rawbuf[offset], AIWA_RC_T501_HDR_MARK)) {
|
||||
return ERR;
|
||||
}
|
||||
offset++;
|
||||
|
||||
// Check HDR space
|
||||
if(!MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_HDR_SPACE)) {
|
||||
return ERR;
|
||||
}
|
||||
offset++;
|
||||
|
||||
offset += 26; // skip pre-data - optional
|
||||
while(offset < irparams.rawlen - 4) {
|
||||
if(MATCH_MARK(results->rawbuf[offset], AIWA_RC_T501_BIT_MARK)) {
|
||||
offset++;
|
||||
}
|
||||
else {
|
||||
return ERR;
|
||||
}
|
||||
|
||||
// ONE & ZERO
|
||||
if(MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ONE_SPACE)) {
|
||||
data = (data << 1) | 1;
|
||||
}
|
||||
else if(MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ZERO_SPACE)) {
|
||||
data <<= 1;
|
||||
}
|
||||
else {
|
||||
// End of one & zero detected
|
||||
break;
|
||||
}
|
||||
offset++;
|
||||
}
|
||||
|
||||
results->bits = (offset - 1) / 2;
|
||||
if(results->bits < 42) {
|
||||
return ERR;
|
||||
}
|
||||
results->value = data;
|
||||
results->decode_type = AIWA_RC_T501;
|
||||
return DECODED;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
* hashdecode - decode an arbitrary IR code.
|
||||
* Instead of decoding using a standard encoding scheme
|
||||
@@ -1239,3 +1305,53 @@ void IRsend::sendDISH(unsigned long data, int nbits) {
|
||||
data <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Aiwa system
|
||||
* Remote control RC-T501
|
||||
* Lirc file http://lirc.sourceforge.net/remotes/aiwa/RC-T501
|
||||
*
|
||||
*/
|
||||
void IRsend::sendAiwaRCT501(int code) {
|
||||
// PRE-DATA, 26 bits, 0x227EEC0
|
||||
long int pre = 0x227EEC0;
|
||||
int i;
|
||||
|
||||
enableIROut(AIWA_RC_T501_HZ);
|
||||
|
||||
// HDR mark + HDR space
|
||||
mark(AIWA_RC_T501_HDR_MARK);
|
||||
space(AIWA_RC_T501_HDR_SPACE);
|
||||
|
||||
// Skip leading zero's
|
||||
pre <<= 6;
|
||||
// Send pre-data
|
||||
for(i=0; i < 26; i++) {
|
||||
mark(AIWA_RC_T501_BIT_MARK);
|
||||
if(pre & TOPBIT) {
|
||||
space(AIWA_RC_T501_ONE_SPACE);
|
||||
} else {
|
||||
space(AIWA_RC_T501_ZERO_SPACE);
|
||||
}
|
||||
pre <<= 1;
|
||||
}
|
||||
|
||||
// Skip firts code bit
|
||||
code <<= 1;
|
||||
// Send code
|
||||
for(i=0; i < 15; i++) {
|
||||
mark(AIWA_RC_T501_BIT_MARK);
|
||||
if(code & TOPBIT) {
|
||||
space(AIWA_RC_T501_ONE_SPACE);
|
||||
} else {
|
||||
space(AIWA_RC_T501_ZERO_SPACE);
|
||||
}
|
||||
code <<= 1;
|
||||
}
|
||||
// POST-DATA, 1 bit, 0x0
|
||||
mark(AIWA_RC_T501_BIT_MARK);
|
||||
space(AIWA_RC_T501_ZERO_SPACE);
|
||||
|
||||
mark(AIWA_RC_T501_BIT_MARK);
|
||||
space(0);
|
||||
}
|
||||
@@ -53,6 +53,7 @@ public:
|
||||
#define SAMSUNG 11
|
||||
#define LG 12
|
||||
#define WHYNTER 13
|
||||
#define AIWA_RC_T501 14
|
||||
#define UNKNOWN -1
|
||||
|
||||
// Decoded value for NEC when a repeat code is received
|
||||
@@ -81,6 +82,7 @@ private:
|
||||
long decodeJVC(decode_results *results);
|
||||
long decodeSAMSUNG(decode_results *results);
|
||||
long decodeWhynter(decode_results *results);
|
||||
long decodeAiwaRCT501(decode_results *results);
|
||||
long decodeHash(decode_results *results);
|
||||
int compare(unsigned int oldval, unsigned int newval);
|
||||
|
||||
@@ -111,6 +113,7 @@ public:
|
||||
void sendSharpRaw(unsigned long data, int nbits);
|
||||
void sendPanasonic(unsigned int address, unsigned long data);
|
||||
void sendJVC(unsigned long data, int nbits, int repeat); // *Note instead of sending the REPEAT constant if you want the JVC repeat signal sent, send the original code value and change the repeat argument from 0 to 1. JVC protocol repeats by skipping the header NOT by sending a separate code value like NEC does.
|
||||
void sendAiwaRCT501(int code);
|
||||
// private:
|
||||
void sendSAMSUNG(unsigned long data, int nbits);
|
||||
void enableIROut(int khz);
|
||||
|
||||
@@ -190,6 +190,20 @@
|
||||
#define SHARP_BITS 15
|
||||
#define DISH_BITS 16
|
||||
|
||||
// AIWA RC T501
|
||||
// Lirc file http://lirc.sourceforge.net/remotes/aiwa/RC-T501
|
||||
#define AIWA_RC_T501_HZ 38
|
||||
#define AIWA_RC_T501_BITS 15
|
||||
#define AIWA_RC_T501_PRE_BITS 26
|
||||
#define AIWA_RC_T501_POST_BITS 1
|
||||
#define AIWA_RC_T501_SUM_BITS AIWA_RC_T501_PRE_BITS+AIWA_RC_T501_BITS+AIWA_RC_T501_POST_BITS
|
||||
#define AIWA_RC_T501_HDR_MARK 8800
|
||||
#define AIWA_RC_T501_HDR_SPACE 4500
|
||||
#define AIWA_RC_T501_BIT_MARK 500
|
||||
#define AIWA_RC_T501_ONE_SPACE 600
|
||||
#define AIWA_RC_T501_ZERO_SPACE 1700
|
||||
|
||||
|
||||
#define TOLERANCE 25 // percent tolerance in measurements
|
||||
#define LTOL (1.0 - TOLERANCE/100.)
|
||||
#define UTOL (1.0 + TOLERANCE/100.)
|
||||
|
||||
25
examples/AiwaRCT501SendDemo/AiwaRCT501SendDemo.ino
Normal file
25
examples/AiwaRCT501SendDemo/AiwaRCT501SendDemo.ino
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
|
||||
* An IR LED must be connected to Arduino PWM pin 3.
|
||||
* Version 0.1 July, 2009
|
||||
* Copyright 2009 Ken Shirriff
|
||||
* http://arcfn.com
|
||||
*/
|
||||
|
||||
#include "IRremote.h"
|
||||
|
||||
#define POWER 0x7F80
|
||||
|
||||
IRsend irsend;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("Arduino Ready");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (Serial.read() != -1) {
|
||||
irsend.sendAiwaRCT501(POWER);
|
||||
delay(60); // Optional
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,10 @@ void dump(decode_results *results) {
|
||||
}
|
||||
else if (results->decode_type == JVC) {
|
||||
Serial.print("Decoded JVC: ");
|
||||
|
||||
}
|
||||
else if (results->decode_type == AIWA_RC_T501) {
|
||||
Serial.print("Decoded AIWA RC T501: ");
|
||||
}
|
||||
else if (results->decode_type == WHYNTER) {
|
||||
Serial.print("Decoded Whynter: ");
|
||||
|
||||
Reference in New Issue
Block a user