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_Sony.cpp
00001 #include "IRremote.h" 00002 #include "IRremoteInt.h" 00003 00004 //============================================================================== 00005 // SSSS OOO N N Y Y 00006 // S O O NN N Y Y 00007 // SSS O O N N N Y 00008 // S O O N NN Y 00009 // SSSS OOO N N Y 00010 //============================================================================== 00011 00012 #define SONY_BITS 12 00013 #define SONY_HDR_MARK 2400 00014 #define SONY_HDR_SPACE 600 00015 #define SONY_ONE_MARK 1200 00016 #define SONY_ZERO_MARK 600 00017 #define SONY_RPT_LENGTH 45000 00018 #define SONY_DOUBLE_SPACE_USECS 500 // usually ssee 713 - not using ticks as get number wrapround 00019 00020 //+============================================================================= 00021 #if SEND_SONY 00022 void IRsend::sendSony (unsigned long data, int nbits) 00023 { 00024 // Set IR carrier frequency 00025 enableIROut(40); 00026 00027 // Header 00028 mark(SONY_HDR_MARK); 00029 space(SONY_HDR_SPACE); 00030 00031 // Data 00032 for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) { 00033 if (data & mask) { 00034 mark(SONY_ONE_MARK); 00035 space(SONY_HDR_SPACE); 00036 } else { 00037 mark(SONY_ZERO_MARK); 00038 space(SONY_HDR_SPACE); 00039 } 00040 } 00041 00042 // We will have ended with LED off 00043 } 00044 #endif 00045 00046 //+============================================================================= 00047 #if DECODE_SONY 00048 bool IRrecv::decodeSony (decode_results *results) 00049 { 00050 long data = 0; 00051 int offset = 0; // Dont skip first space, check its size 00052 00053 if (irparams.rawlen < (2 * SONY_BITS) + 2) return false ; 00054 00055 // Some Sony's deliver repeats fast after first 00056 // unfortunately can't spot difference from of repeat from two fast clicks 00057 if (results->rawbuf[offset] < SONY_DOUBLE_SPACE_USECS) { 00058 results->bits = 0; 00059 results->value = REPEAT; 00060 00061 # ifdef DECODE_SANYO 00062 results->decode_type = SANYO; 00063 # else 00064 results->decode_type = UNKNOWN; 00065 # endif 00066 00067 return true; 00068 } 00069 offset++; 00070 00071 // Initial mark 00072 if (!MATCH_MARK(results->rawbuf[offset++], SONY_HDR_MARK)) return false ; 00073 00074 while (offset + 1 < irparams.rawlen) { 00075 if (!MATCH_SPACE(results->rawbuf[offset++], SONY_HDR_SPACE)) break ; 00076 00077 if (MATCH_MARK(results->rawbuf[offset], SONY_ONE_MARK)) data = (data << 1) | 1 ; 00078 else if (MATCH_MARK(results->rawbuf[offset], SONY_ZERO_MARK)) data = (data << 1) | 0 ; 00079 else return false ; 00080 offset++; 00081 } 00082 00083 // Success 00084 results->bits = (offset - 1) / 2; 00085 if (results->bits < 12) { 00086 results->bits = 0; 00087 return false; 00088 } 00089 results->value = data; 00090 results->decode_type = SONY; 00091 return true; 00092 } 00093 #endif 00094
Generated on Tue Jul 12 2022 18:56:50 by
