Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Lilnija_29012017 NucleoF042K6_IRReceiver
ir_Aiwa.cpp
00001 #include "IRremote.h" 00002 #include "IRremoteInt.h" 00003 00004 //============================================================================== 00005 // AAA IIIII W W AAA 00006 // A A I W W A A 00007 // AAAAA I W W W AAAAA 00008 // A A I W W W A A 00009 // A A IIIII WWW A A 00010 //============================================================================== 00011 00012 // Based off the RC-T501 RCU 00013 // Lirc file http://lirc.sourceforge.net/remotes/aiwa/RC-T501 00014 00015 #define AIWA_RC_T501_HZ 38 00016 #define AIWA_RC_T501_BITS 15 00017 #define AIWA_RC_T501_PRE_BITS 26 00018 #define AIWA_RC_T501_POST_BITS 1 00019 #define AIWA_RC_T501_SUM_BITS (AIWA_RC_T501_PRE_BITS + AIWA_RC_T501_BITS + AIWA_RC_T501_POST_BITS) 00020 #define AIWA_RC_T501_HDR_MARK 8800 00021 #define AIWA_RC_T501_HDR_SPACE 4500 00022 #define AIWA_RC_T501_BIT_MARK 500 00023 #define AIWA_RC_T501_ONE_SPACE 600 00024 #define AIWA_RC_T501_ZERO_SPACE 1700 00025 00026 //+============================================================================= 00027 #if SEND_AIWA_RC_T501 00028 void IRsend::sendAiwaRCT501 (int code) 00029 { 00030 unsigned long pre = 0x0227EEC0; // 26-bits 00031 00032 // Set IR carrier frequency 00033 enableIROut(AIWA_RC_T501_HZ); 00034 00035 // Header 00036 mark(AIWA_RC_T501_HDR_MARK); 00037 space(AIWA_RC_T501_HDR_SPACE); 00038 00039 // Send "pre" data 00040 for (unsigned long mask = 1UL << (26 - 1); mask; mask >>= 1) { 00041 mark(AIWA_RC_T501_BIT_MARK); 00042 if (pre & mask) space(AIWA_RC_T501_ONE_SPACE) ; 00043 else space(AIWA_RC_T501_ZERO_SPACE) ; 00044 } 00045 00046 //-v- THIS CODE LOOKS LIKE IT MIGHT BE WRONG - CHECK! 00047 // it only send 15bits and ignores the top bit 00048 // then uses TOPBIT which is 0x80000000 to check the bit code 00049 // I suspect TOPBIT should be changed to 0x00008000 00050 00051 // Skip first code bit 00052 code <<= 1; 00053 // Send code 00054 for (int i = 0; i < 15; i++) { 00055 mark(AIWA_RC_T501_BIT_MARK); 00056 if (code & 0x80000000) space(AIWA_RC_T501_ONE_SPACE) ; 00057 else space(AIWA_RC_T501_ZERO_SPACE) ; 00058 code <<= 1; 00059 } 00060 00061 //-^- THIS CODE LOOKS LIKE IT MIGHT BE WRONG - CHECK! 00062 00063 // POST-DATA, 1 bit, 0x0 00064 mark(AIWA_RC_T501_BIT_MARK); 00065 space(AIWA_RC_T501_ZERO_SPACE); 00066 00067 mark(AIWA_RC_T501_BIT_MARK); 00068 space(0); 00069 } 00070 #endif 00071 00072 //+============================================================================= 00073 #if DECODE_AIWA_RC_T501 00074 bool IRrecv::decodeAiwaRCT501 (decode_results *results) 00075 { 00076 int data = 0; 00077 int offset = 1; 00078 00079 // Check SIZE 00080 if (irparams.rawlen < 2 * (AIWA_RC_T501_SUM_BITS) + 4) return false ; 00081 00082 // Check HDR Mark/Space 00083 if (!MATCH_MARK (results->rawbuf[offset++], AIWA_RC_T501_HDR_MARK )) return false ; 00084 if (!MATCH_SPACE(results->rawbuf[offset++], AIWA_RC_T501_HDR_SPACE)) return false ; 00085 00086 offset += 26; // skip pre-data - optional 00087 while(offset < irparams.rawlen - 4) { 00088 if (MATCH_MARK(results->rawbuf[offset], AIWA_RC_T501_BIT_MARK)) offset++ ; 00089 else return false ; 00090 00091 // ONE & ZERO 00092 if (MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ONE_SPACE)) data = (data << 1) | 1 ; 00093 else if (MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ZERO_SPACE)) data = (data << 1) | 0 ; 00094 else break ; // End of one & zero detected 00095 offset++; 00096 } 00097 00098 results->bits = (offset - 1) / 2; 00099 if (results->bits < 42) return false ; 00100 00101 results->value = data; 00102 results->decode_type = AIWA_RC_T501; 00103 return true; 00104 } 00105 #endif
Generated on Tue Jul 12 2022 18:56:50 by
