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_LG.cpp
00001 #include "IRremote.h" 00002 #include "IRremoteInt.h" 00003 00004 //============================================================================== 00005 // L GGGG 00006 // L G 00007 // L G GG 00008 // L G G 00009 // LLLLL GGG 00010 //============================================================================== 00011 00012 #define LG_BITS 28 00013 00014 #define LG_HDR_MARK 8000 00015 #define LG_HDR_SPACE 4000 00016 #define LG_BIT_MARK 600 00017 #define LG_ONE_SPACE 1600 00018 #define LG_ZERO_SPACE 550 00019 #define LG_RPT_LENGTH 60000 00020 00021 //+============================================================================= 00022 #if DECODE_LG 00023 bool IRrecv::decodeLG (decode_results *results) 00024 { 00025 long data = 0; 00026 int offset = 1; // Skip first space 00027 00028 // Check we have the right amount of data 00029 if (irparams.rawlen < (2 * LG_BITS) + 1 ) return false ; 00030 00031 // Initial mark/space 00032 if (!MATCH_MARK(results->rawbuf[offset++], LG_HDR_MARK)) return false ; 00033 if (!MATCH_SPACE(results->rawbuf[offset++], LG_HDR_SPACE)) return false ; 00034 00035 for (int i = 0; i < LG_BITS; i++) { 00036 if (!MATCH_MARK(results->rawbuf[offset++], LG_BIT_MARK)) return false ; 00037 00038 if (MATCH_SPACE(results->rawbuf[offset], LG_ONE_SPACE)) data = (data << 1) | 1 ; 00039 else if (MATCH_SPACE(results->rawbuf[offset], LG_ZERO_SPACE)) data = (data << 1) | 0 ; 00040 else return false ; 00041 offset++; 00042 } 00043 00044 // Stop bit 00045 if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)) return false ; 00046 00047 // Success 00048 results->bits = LG_BITS; 00049 results->value = data; 00050 results->decode_type = LG; 00051 return true; 00052 } 00053 #endif 00054 00055 //+============================================================================= 00056 #if SEND_LG 00057 void IRsend::sendLG (unsigned long data, int nbits) 00058 { 00059 // Set IR carrier frequency 00060 enableIROut(38); 00061 00062 // Header 00063 mark(LG_HDR_MARK); 00064 space(LG_HDR_SPACE); 00065 mark(LG_BIT_MARK); 00066 00067 // Data 00068 for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) { 00069 if (data & mask) { 00070 space(LG_ONE_SPACE); 00071 mark(LG_BIT_MARK); 00072 } else { 00073 space(LG_ZERO_SPACE); 00074 mark(LG_BIT_MARK); 00075 } 00076 } 00077 space(0); // Always end with the LED off 00078 } 00079 #endif 00080
Generated on Tue Jul 12 2022 18:56:50 by
