IRremote
ir_Panasonic.cpp
Go to the documentation of this file.
1 #include "IRremote.h"
2 
3 //==============================================================================
4 // PPPP AAA N N AAA SSSS OOO N N IIIII CCCC
5 // P P A A NN N A A S O O NN N I C
6 // PPPP AAAAA N N N AAAAA SSS O O N N N I C
7 // P A A N NN A A S O O N NN I C
8 // P A A N N A A SSSS OOO N N IIIII CCCC
9 //==============================================================================
10 
11 #define PANASONIC_BITS 48
12 #define PANASONIC_HDR_MARK 3502
13 #define PANASONIC_HDR_SPACE 1750
14 #define PANASONIC_BIT_MARK 502
15 #define PANASONIC_ONE_SPACE 1244
16 #define PANASONIC_ZERO_SPACE 400
17 
18 //+=============================================================================
19 #if SEND_PANASONIC
20 void IRsend::sendPanasonic(unsigned int address, unsigned long data) {
21  // Set IR carrier frequency
22  enableIROut(37); // 36.7kHz is the correct frequency
23 
24  // Header
27 
28  // Address
29  for (unsigned long mask = 1UL << (16 - 1); mask; mask >>= 1) {
31  if (address & mask)
33  else
35  }
36 
37  // Data
38  for (unsigned long mask = 1UL << (32 - 1); mask; mask >>= 1) {
40  if (data & mask)
42  else
44  }
45 
46  // Footer
48  space(0); // Always end with the LED off
49 }
50 #endif
51 
52 //+=============================================================================
53 #if DECODE_PANASONIC
54 bool IRrecv::decodePanasonic(decode_results *results) {
55  unsigned long long data = 0;
56  int offset = 1;
57 
58  if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_HDR_MARK)) {
59  return false;
60  }
61  offset++;
62  if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_HDR_SPACE)) {
63  return false;
64  }
65  offset++;
66 
67  // decode address
68  for (int i = 0; i < PANASONIC_BITS; i++) {
69  if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_BIT_MARK)) {
70  return false;
71  }
72  offset++;
73 
74  if (MATCH_SPACE(results->rawbuf[offset], PANASONIC_ONE_SPACE)) {
75  data = (data << 1) | 1;
76  } else if (MATCH_SPACE(results->rawbuf[offset], PANASONIC_ZERO_SPACE)) {
77  data = (data << 1) | 0;
78  } else {
79  return false;
80  }
81  offset++;
82  }
83 
84  results->value = (unsigned long) data;
85  results->address = (unsigned int) (data >> 32);
86  results->decode_type = PANASONIC;
87  results->bits = PANASONIC_BITS;
88 
89  return true;
90 }
91 #endif
92 
PANASONIC_HDR_SPACE
#define PANASONIC_HDR_SPACE
Definition: ir_Panasonic.cpp:13
PANASONIC_BITS
#define PANASONIC_BITS
Definition: ir_Panasonic.cpp:11
decode_results
Results returned from the decoder.
Definition: IRremote.h:174
decode_results::bits
int bits
Number of bits in decoded value.
Definition: IRremote.h:179
decode_results::address
unsigned int address
Used by Panasonic & Sharp [16-bits].
Definition: IRremote.h:177
decode_results::rawbuf
volatile unsigned int * rawbuf
Raw intervals in 50uS ticks.
Definition: IRremote.h:180
IRsend::mark
void mark(unsigned int usec)
Definition: irSend.cpp:69
IRsend::enableIROut
void enableIROut(int khz)
Definition: irSend.cpp:127
IRsend::sendPanasonic
void sendPanasonic(unsigned int address, unsigned long data)
Definition: ir_Panasonic.cpp:20
decode_results::decode_type
decode_type_t decode_type
UNKNOWN, NEC, SONY, RC5, ...
Definition: IRremote.h:176
MATCH_SPACE
int MATCH_SPACE(int measured_ticks, int desired_us)
Definition: IRremote.cpp:89
PANASONIC_ONE_SPACE
#define PANASONIC_ONE_SPACE
Definition: ir_Panasonic.cpp:15
PANASONIC_HDR_MARK
#define PANASONIC_HDR_MARK
Definition: ir_Panasonic.cpp:12
IRremote.h
Public API to the library.
PANASONIC
@ PANASONIC
Definition: IRremote.h:119
PANASONIC_ZERO_SPACE
#define PANASONIC_ZERO_SPACE
Definition: ir_Panasonic.cpp:16
IRsend::space
void space(unsigned int usec)
Definition: irSend.cpp:103
PANASONIC_BIT_MARK
#define PANASONIC_BIT_MARK
Definition: ir_Panasonic.cpp:14
decode_results::value
unsigned long value
Decoded value [max 32-bits].
Definition: IRremote.h:178
MATCH_MARK
int MATCH_MARK(int measured_ticks, int desired_us)
Definition: IRremote.cpp:63