@@ -242,10 +242,82 @@ void IRsend::sendMagiQuest(uint32_t wand_id, uint16_t magnitude)
242
242
space (MAGIQUEST_SPACE_ZERO);
243
243
}
244
244
}
245
- Serial.println ();
246
245
}
247
-
248
- void IRsend::mark (int time) {
246
+ void IRsend::sendSymaR5 (uint32_t data)
247
+ {
248
+ enableIROut (38 );
249
+ mark (SYMA_HDR_MARK); // SYMA_HDR_MARK
250
+ space (SYMA_HDR_SPACE); // SYMA_HDR_SPACE
251
+ for (uint8_t i = 0 ; i < SYMA_R5_BITS+1 ; i++) {
252
+ mark (SYMA_BIT_MARK); // SYMA_BIT_MARK
253
+ if (((int32_t )data) < 0 ) { // if negative then MSBit is one.
254
+ space (SYMA_ONE_SPACE); // SYMA_ONE_SPACE
255
+ }
256
+ else {
257
+ space (SYMA_ZERO_SPACE); // SYMA_ZERO_SPACE
258
+ }
259
+ data <<= 1 ;
260
+ }
261
+ }
262
+ void IRsend::sendSymaR3 (uint32_t data)
263
+ {
264
+ enableIROut (38 );
265
+ mark (SYMA_HDR_MARK);
266
+ space (SYMA_HDR_SPACE);
267
+ data <<= 8 ;
268
+ for (uint8_t i = 0 ; i < SYMA_R3_BITS+1 ; i++) {
269
+ mark (SYMA_BIT_MARK);
270
+ if (((int32_t )data) < 0 ) { // if negative then MSBit is one.
271
+ space (SYMA_ONE_SPACE);
272
+ }
273
+ else {
274
+ space (SYMA_ZERO_SPACE);
275
+ }
276
+ data <<= 1 ;
277
+ }
278
+ }
279
+ void IRsend::sendUseries (uint32_t data)
280
+ {
281
+ enableIROut (38 );
282
+ mark (USERIES_HDR_MARK);
283
+ for (int16_t i = 0 ; i < USERIES_BITS+1 ; i++) {
284
+ space (USERIES_BIT_SPACE);
285
+ if (((int32_t )data) < 0 ) { // if negative then MSBit is one.
286
+ mark (USERIES_ZERO_MARK);
287
+ }
288
+ else {
289
+ mark (USERIES_ONE_MARK);
290
+ }
291
+ data <<= 1 ;
292
+ }
293
+ space (0 ); // Just to be sure
294
+ }
295
+ void IRsend::sendFastLane (uint32_t data)
296
+ {
297
+ enableIROut (38 );
298
+ mark (FASTLANE_HDR_MARK);
299
+ data <<= (32 - FASTLANE_BITS); // upshift to start point of data.
300
+ for (int16_t i = 0 ; i < FASTLANE_BITS+1 ; i++) {
301
+ if (i%2 ) {
302
+ if (((int32_t )data) < 0 ) { // if negative then MSBit is one.
303
+ mark (FASTLANE_ONE);
304
+ }
305
+ else {
306
+ mark (FASTLANE_ZERO);
307
+ }
308
+ } else {
309
+ if (((int32_t )data) < 0 ) { // if negative then MSBit is one.
310
+ space (FASTLANE_ONE);
311
+ }
312
+ else {
313
+ space (FASTLANE_ZERO);
314
+ }
315
+ }
316
+ data <<= 1 ;
317
+ }
318
+ space (0 ); // Just to be sure
319
+ }
320
+ void IRsend::mark (int16_t time) {
249
321
// Sends an IR mark for the specified number of microseconds.
250
322
// The mark output is modulated at the PWM frequency.
251
323
TIMER_ENABLE_PWM; // Enable pin 3 PWM output
@@ -457,6 +529,24 @@ int16_t IRrecv::decode(decode_results *results) {
457
529
if (decodePanasonic (results)) {
458
530
return DECODED;
459
531
}
532
+ #ifdef DEBUG
533
+ Serial.println (" Attempting Syma decode" );
534
+ #endif
535
+ if (decodeSyma (results)) {
536
+ return DECODED;
537
+ }
538
+ #ifdef DEBUG
539
+ Serial.println (" Attempting Useries decode" );
540
+ #endif
541
+ if (decodeUseries (results)) {
542
+ return DECODED;
543
+ }
544
+ #ifdef DEBUG
545
+ Serial.println (" Attempting FastLane decode" );
546
+ #endif
547
+ if (decodeFastLane (results)) {
548
+ return DECODED;
549
+ }
460
550
#ifdef DEBUG
461
551
Serial.println (" Attempting JVC decode" );
462
552
#endif
@@ -874,6 +964,109 @@ int32_t IRrecv::decodePanasonic(decode_results *results) {
874
964
results->bits = PANASONIC_BITS;
875
965
return DECODED;
876
966
}
967
+ int32_t IRrecv::decodeSyma (decode_results *results) {
968
+ uint32_t data = 0 ;
969
+ int16_t offset = 1 ;
970
+ uint8_t syma_len;
971
+
972
+ if (irparams.rawlen == 2 * (SYMA_R5_BITS + 2 )) {
973
+ syma_len = SYMA_R5_BITS;
974
+ }
975
+ else if (irparams.rawlen == 2 * (SYMA_R3_BITS + 2 )) {
976
+ syma_len = SYMA_R3_BITS;
977
+ }
978
+ else {
979
+ return ERR;
980
+ }
981
+ if (!MATCH_MARK (results->rawbuf [offset], SYMA_HDR_MARK)) {
982
+ return ERR;
983
+ }
984
+ offset++;
985
+ if (!MATCH_MARK (results->rawbuf [offset], SYMA_HDR_SPACE)) {
986
+ return ERR;
987
+ }
988
+ offset++;
989
+ for (uint8_t i = 0 ; i < syma_len; i++) {
990
+ if (!MATCH_MARK (results->rawbuf [offset++], SYMA_BIT_MARK)) {
991
+ return ERR;
992
+ }
993
+ if (MATCH_SPACE (results->rawbuf [offset], SYMA_ONE_SPACE)) {
994
+ data = (data << 1 ) | 1 ;
995
+ } else if (MATCH_SPACE (results->rawbuf [offset], SYMA_ZERO_SPACE)) {
996
+ data <<= 1 ;
997
+ } else {
998
+ return ERR;
999
+ }
1000
+ offset++;
1001
+ }
1002
+ results->value = data;
1003
+ if (syma_len == SYMA_R5_BITS) {
1004
+ results->decode_type = SYMA_R5;
1005
+ }
1006
+ else if (syma_len == SYMA_R3_BITS) {
1007
+ results->decode_type = SYMA_R3;
1008
+ }
1009
+ results->bits = syma_len;
1010
+ results->helicopter .dword = data;
1011
+ return DECODED;
1012
+ }
1013
+ int32_t IRrecv::decodeUseries (decode_results *results) {
1014
+ uint32_t data = 0 ;
1015
+ int16_t offset = 1 ;
1016
+ if (irparams.rawlen < 2 * (USERIES_BITS + 2 )) {
1017
+ return ERR;
1018
+ }
1019
+ if (!MATCH_MARK (results->rawbuf [offset], USERIES_HDR_MARK)) {
1020
+ return ERR;
1021
+ }
1022
+ offset++;
1023
+ for (int16_t i = 0 ; i < USERIES_BITS; i++) {
1024
+ if (!MATCH_SPACE (results->rawbuf [offset++], USERIES_BIT_SPACE)) {
1025
+ return ERR;
1026
+ }
1027
+ if (MATCH_MARK (results->rawbuf [offset],USERIES_ONE_MARK)) {
1028
+ data <<= 1 ;
1029
+ } else if (MATCH_MARK (results->rawbuf [offset],USERIES_ZERO_MARK)) {
1030
+ data = (data << 1 ) | 1 ;
1031
+ } else {
1032
+ return ERR;
1033
+ }
1034
+ offset++;
1035
+ }
1036
+ results->value = data;
1037
+ results->helicopter .dword = data;
1038
+ results->parity = UseriesChecksum (data);
1039
+ results->decode_type = USERIES;
1040
+ results->bits = USERIES_BITS;
1041
+ return DECODED;
1042
+ }
1043
+ int32_t IRrecv::decodeFastLane (decode_results *results) {
1044
+ helicopter data;
1045
+ data.dword = 0 ;
1046
+ int16_t offset = 1 ;
1047
+ if (irparams.rawlen < (FASTLANE_BITS + 2 )) {
1048
+ return ERR;
1049
+ }
1050
+ if (!MATCH_MARK (results->rawbuf [offset], FASTLANE_HDR_MARK)) {
1051
+ return ERR;
1052
+ }
1053
+ offset++;
1054
+ for (int16_t i = 0 ; i < FASTLANE_BITS; i++) {
1055
+ if (MATCH_MARK (results->rawbuf [offset],FASTLANE_ZERO)) {
1056
+ data.dword <<= 1 ;
1057
+ } else if (MATCH_MARK (results->rawbuf [offset],FASTLANE_ONE)) {
1058
+ data.dword = (data.dword << 1 ) | 1 ;
1059
+ } else {
1060
+ return ERR;
1061
+ }
1062
+ offset++;
1063
+ }
1064
+ results->value = data.dword ;
1065
+ results->helicopter .dword = data.dword ;
1066
+ results->decode_type = FASTLANE;
1067
+ results->bits = FASTLANE_BITS;
1068
+ return DECODED;
1069
+ }
877
1070
int32_t IRrecv::decodeJVC (decode_results *results) {
878
1071
int32_t data = 0 ;
879
1072
int16_t offset = 1 ; // Skip first space
@@ -1113,3 +1306,14 @@ void IRsend::sendDISH(int32_t data, int16_t nbits)
1113
1306
data <<= 1 ;
1114
1307
}
1115
1308
}
1309
+ uint8_t UseriesChecksum (uint32_t val)
1310
+ {
1311
+ const uint8_t map[8 ] = { 0 , 1 , 3 , 2 , 6 , 7 , 5 , 4 };
1312
+ uint32_t x = val & 0xFFFFFFF8 ;
1313
+ uint32_t p = x;
1314
+ while ((x >>= 7 ) != 0 ) {
1315
+ p ^= x;
1316
+ }
1317
+ p = (p ^ (p >> 1 ) ^ (p >> 2 ) ^ (p >> 4 )) & 7 ;
1318
+ return (map[p]);
1319
+ }
0 commit comments