IRremote
ir_JVC.cpp
Go to the documentation of this file.
1 #include "IRremote.h"
2 
3 //==============================================================================
4 // JJJJJ V V CCCC
5 // J V V C
6 // J V V C
7 // J J V V C
8 // J V CCCC
9 //==============================================================================
10 
11 #define JVC_BITS 16
12 #define JVC_HDR_MARK 8000
13 #define JVC_HDR_SPACE 4000
14 #define JVC_BIT_MARK 600
15 #define JVC_ONE_SPACE 1600
16 #define JVC_ZERO_SPACE 550
17 #define JVC_RPT_LENGTH 60000
18 
19 //+=============================================================================
20 // JVC does NOT repeat by sending a separate code (like NEC does).
21 // The JVC protocol repeats by skipping the header.
22 // To send a JVC repeat signal, send the original code value
23 // and set 'repeat' to true
24 //
25 #if SEND_JVC
26 void IRsend::sendJVC(unsigned long data, int nbits, bool repeat) {
27  // Set IR carrier frequency
28  enableIROut(38);
29 
30  // Only send the Header if this is NOT a repeat command
31  if (!repeat) {
34  }
35 
36  // Data
37  for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
38  if (data & mask) {
41  } else {
44  }
45  }
46 
47  // Footer
49  space(0); // Always end with the LED off
50 }
51 #endif
52 
53 //+=============================================================================
54 #if DECODE_JVC
55 bool IRrecv::decodeJVC(decode_results *results) {
56  long data = 0;
57  int offset = 1; // Skip first space
58 
59  // Check for repeat
60  if ((irparams.rawlen - 1 == 33) && MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)
61  && MATCH_MARK(results->rawbuf[irparams.rawlen - 1], JVC_BIT_MARK)) {
62  results->bits = 0;
63  results->value = REPEAT;
64  results->decode_type = JVC;
65  return true;
66  }
67 
68  // Initial mark
69  if (!MATCH_MARK(results->rawbuf[offset], JVC_HDR_MARK)) {
70  return false;
71  }
72  offset++;
73 
74  if (irparams.rawlen < (2 * JVC_BITS) + 1) {
75  return false;
76  }
77 
78  // Initial space
79  if (!MATCH_SPACE(results->rawbuf[offset], JVC_HDR_SPACE)) {
80  return false;
81  }
82  offset++;
83 
84  for (int i = 0; i < JVC_BITS; i++) {
85  if (!MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)) {
86  return false;
87  }
88  offset++;
89 
90  if (MATCH_SPACE(results->rawbuf[offset], JVC_ONE_SPACE)) {
91  data = (data << 1) | 1;
92  } else if (MATCH_SPACE(results->rawbuf[offset], JVC_ZERO_SPACE)) {
93  data = (data << 1) | 0;
94  } else {
95  return false;
96  }
97  offset++;
98  }
99 
100  // Stop bit
101  if (!MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)) {
102  return false;
103  }
104 
105  // Success
106  results->bits = JVC_BITS;
107  results->value = data;
108  results->decode_type = JVC;
109 
110  return true;
111 }
112 #endif
113 
JVC_BIT_MARK
#define JVC_BIT_MARK
Definition: ir_JVC.cpp:14
JVC_ONE_SPACE
#define JVC_ONE_SPACE
Definition: ir_JVC.cpp:15
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::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
decode_results::decode_type
decode_type_t decode_type
UNKNOWN, NEC, SONY, RC5, ...
Definition: IRremote.h:176
JVC
@ JVC
Definition: IRremote.h:120
MATCH_SPACE
int MATCH_SPACE(int measured_ticks, int desired_us)
Definition: IRremote.cpp:89
irparams
volatile irparams_t irparams
Allow all parts of the code access to the ISR data NB.
IRsend::sendJVC
void sendJVC(unsigned long data, int nbits, bool repeat)
Definition: ir_JVC.cpp:26
JVC_HDR_SPACE
#define JVC_HDR_SPACE
Definition: ir_JVC.cpp:13
JVC_HDR_MARK
#define JVC_HDR_MARK
Definition: ir_JVC.cpp:12
IRremote.h
Public API to the library.
IRsend::space
void space(unsigned int usec)
Definition: irSend.cpp:103
REPEAT
#define REPEAT
Decoded value for NEC when a repeat code is received.
Definition: IRremote.h:188
decode_results::value
unsigned long value
Decoded value [max 32-bits].
Definition: IRremote.h:178
JVC_ZERO_SPACE
#define JVC_ZERO_SPACE
Definition: ir_JVC.cpp:16
MATCH_MARK
int MATCH_MARK(int measured_ticks, int desired_us)
Definition: IRremote.cpp:63
JVC_BITS
#define JVC_BITS
Definition: ir_JVC.cpp:11
irparams_t::rawlen
unsigned int rawlen
counter of entries in rawbuf
Definition: IRremoteInt.h:45