@@ -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::sendAiwaRCT501 (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+ }
0 commit comments