8000 Merge pull request #61 from crash7/master · ajitjadhav28/Arduino-IRremote@ce1c79b · GitHub
[go: up one dir, main page]

Skip to content

Commit ce1c79b

Browse files
committed
Merge pull request Arduino-IRremote#61 from crash7/master
Added Aiwa protocol (remote control RC-T501).
2 parents c2bf981 + bed4cc5 commit ce1c79b

File tree

5 files changed

+162
-0
lines changed

5 files changed

+162
-0
lines changed

IRremote.cpp

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,13 @@ int IRrecv::decode(decode_results *results) {
506506
if (decodeWhynter(results)) {
507507
return DECODED;
508508
}
509+
// Aiwa RC-T501
510+
#ifdef DEBUG
511+
Serial.println("Attempting Aiwa RC-T501 decode");
512+
#endif
513+
if (decodeAiwaRCT501(results)) {
514+
return DECODED;
515+
}
509516
// decodeHash returns a hash on any input.
510517
// Thus, it needs to be last in the list.
511518
// If you add any decodes, add them before this.
@@ -1117,6 +1124,65 @@ long IRrecv::decodeSAMSUNG(decode_results *results) {
11171124
return DECODED;
11181125
}
11191126

1127+
/**
1128+
* Aiwa system
1129+
* Remote control RC-T501
1130+
* Lirc file http://lirc.sourceforge.net/remotes/aiwa/RC-T501
1131+
*
1132+
*/
1133+
long IRrecv::decodeAiwaRCT501(decode_results *results) {
1134+
int data = 0;
1135+
int offset = 1; // skip first garbage read
1136+
1137+
// Check SIZE
1138+
if(irparams.rawlen < 2 * (AIWA_RC_T501_SUM_BITS) + 4) {
1139+
return ERR;
1140+
}
1141+
1142+
// Check HDR
1143+
if(!MATCH_MARK(results->rawbuf[offset], AIWA_RC_T501_HDR_MARK)) {
1144+
return ERR;
1145+
}
1146+
offset++;
1147+
1148+
// Check HDR space
1149+
if(!MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_HDR_SPACE)) {
1150+
return ERR;
1151+
}
1152+
offset++;
1153+
1154+
offset += 26; // skip pre-data - optional
1155+
while(offset < irparams.rawlen - 4) {
1156+
if(MATCH_MARK(results->rawbuf[offset], AIWA_RC_T501_BIT_MARK)) {
1157+
offset++;
1158+
}
1159+
else {
1160+
return ERR;
1161+
}
1162+
1163+
// ONE & ZERO
1164+
if(MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ONE_SPACE)) {
1165+
data = (data << 1) | 1;
1166+
}
1167+
else if(MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ZERO_SPACE)) {
1168+
data <<= 1;
1169+
}
1170+
else {
1171+
// End of one & zero detected
1172+
break;
1173+
}
1174+
offset++;
1175+
}
1176+
1177+
results->bits = (offset - 1) / 2;
1178+
if(results->bits < 42) {
1179+
return ERR;
1180+
}
1181+
results->value = data;
1182+
results->decode_type = AIWA_RC_T501;
1183+
return DECODED;
1184+
}
1185+
11201186
/* -----------------------------------------------------------------------
11211187
* hashdecode - decode an arbitrary IR code.
11221188
* Instead of decoding using a standard encoding scheme
@@ -1239,3 +1305,53 @@ void IRsend::sendDISH(unsigned long data, int nbits) {
12391305
data <<= 1;
12401306
}
12411307
}
1308+
1309+
/**
1310+
* Aiwa system
1311+
* Remote control RC-T501
1312+
* Lirc file http://lirc.sourceforge.net/remotes/aiwa/RC-T501
1313+
*
1314+
*/
1315+
void IRsend::sen 57AE dAiwaRCT501(int code) {
1316+
// PRE-DATA, 26 bits, 0x227EEC0
1317+
long int pre = 0x227EEC0;
1318+
int i;
1319+
1320+
enableIROut(AIWA_RC_T501_HZ);
1321+
1322+
// HDR mark + HDR space
1323+
mark(AIWA_RC_T501_HDR_MARK);
1324+
space(AIWA_RC_T501_HDR_SPACE);
1325+
1326+
// Skip leading zero's
1327+
pre <<= 6;
1328+
// Send pre-data
1329+
for(i=0; i < 26; i++) {
1330+
mark(AIWA_RC_T501_BIT_MARK);
1331+
if(pre & TOPBIT) {
1332+
space(AIWA_RC_T501_ONE_SPACE);
1333+
} else {
1334+
space(AIWA_RC_T501_ZERO_SPACE);
1335+
}
1336+
pre <<= 1;
1337+
}
1338+
1339+
// Skip firts code bit
1340+
code <<= 1;
1341+
// Send code
1342+
for(i=0; i < 15; i++) {
1343+
mark(AIWA_RC_T501_BIT_MARK);
1344+
if(code & TOPBIT) {
1345+
space(AIWA_RC_T501_ONE_SPACE);
1346+
} else {
1347+
space(AIWA_RC_T501_ZERO_SPACE);
1348+
}
1349+
code <<= 1;
1350+
}
1351+
// POST-DATA, 1 bit, 0x0
1352+
mark(AIWA_RC_T501_BIT_MARK);
1353+
space(AIWA_RC_T501_ZERO_SPACE);
1354+
1355+
mark(AIWA_RC_T501_BIT_MARK);
1356+
space(0);
1357+
}

IRremote.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class decode_results {
5353
#define SAMSUNG 11
5454
#define LG 12
5555
#define WHYNTER 13
56+
#define AIWA_RC_T501 14
5657
#define UNKNOWN -1
5758

5859
// Decoded value for NEC when a repeat code is received
@@ -81,6 +82,7 @@ class IRrecv
8182
long decodeJVC(decode_results *results);
8283
long decodeSAMSUNG(decode_results *results);
8384
long decodeWhynter(decode_results *results);
85+
long decodeAiwaRCT501(decode_results *results);
8486
long decodeHash(decode_results *results);
8587
int compare(unsigned int oldval, unsigned int newval);
8688

@@ -111,6 +113,7 @@ class IRsend
111113
void sendSharpRaw(unsigned long data, int nbits);
112114
void sendPanasonic(unsigned int address, unsigned long data);
113115
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.
116+
void sendAiwaRCT501(int code);
114117
// private:
115118
void sendSAMSUNG(unsigned long data, int nbits);
116119
void enableIROut(int khz);

IRremoteInt.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,20 @@
190190
#define SHARP_BITS 15
191191
#define DISH_BITS 16
192192

193+
// AIWA RC T501
194+
// Lirc file http://lirc.sourceforge.net/remotes/aiwa/RC-T501
195+
#define AIWA_RC_T501_HZ 38
196+
#define AIWA_RC_T501_BITS 15
197+
#define AIWA_RC_T501_PRE_BITS 26
198+
#define AIWA_RC_T501_POST_BITS 1
199+
#define AIWA_RC_T501_SUM_BITS AIWA_RC_T501_PRE_BITS+AIWA_RC_T501_BITS+AIWA_RC_T501_POST_BITS
200+
#define AIWA_RC_T501_HDR_MARK 8800
201+
#define AIWA_RC_T501_HDR_SPACE 4500
202+
#define AIWA_RC_T501_BIT_MARK 500
203+
#define AIWA_RC_T501_ONE_SPACE 600
204+
#define AIWA_RC_T501_ZERO_SPACE 1700
205+
206+
193207
#define TOLERANCE 25 // percent tolerance in measurements
194208
#define LTOL (1.0 - TOLERANCE/100.)
195209
#define UTOL (1.0 + TOLERANCE/100.)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
3+
* An IR LED must be connected to Arduino PWM pin 3.
4+
* Version 0.1 July, 2009
5+
* Copyright 2009 Ken Shirriff
6+
* http://arcfn.com
7+
*/
8+
9+
#include "IRremote.h"
10+
11+
#define POWER 0x7F80
12+
13+
IRsend irsend;
14+
15+
void setup() {
16+
Serial.begin(9600);
17+
Serial.println("Arduino Ready");
18+
}
19+
20+
void loop() {
21+
if (Serial.read() != -1) {
22+
irsend.sendAiwaRCT501(POWER);
23+
delay(60); // Optional
24+
}
25+
}

examples/IRrecvDump/IRrecvDump.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ void dump(decode_results *results) {
5454
}
5555
else if (results->decode_type == JVC) {
5656
Serial.print("Decoded JVC: ");
57+
58+
}
59+
else if (results->decode_type == AIWA_RC_T501) {
60+
Serial.print("Decoded AIWA RC T501: ");
5761
}
5862
else if (results->decode_type == WHYNTER) {
5963
Serial.print("Decoded Whynter: ");

0 commit comments

Comments
 (0)
0