Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
118 lines (102 loc) · 3.51 KB

File metadata and controls

118 lines (102 loc) · 3.51 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include "IRremote.h"
//==============================================================================
// N N EEEEE CCCC
// NN N E C
// N N N EEE C
// N NN E C
// N N EEEEE CCCC
//==============================================================================
#define NEC_BITS 32
#define NEC_HEADER_MARK 9000
#define NEC_HEADER_SPACE 4500
#define NEC_BIT_MARK 560
#define NEC_ONE_SPACE 1690
#define NEC_ZERO_SPACE 560
#define NEC_REPEAT_SPACE 2250
//+=============================================================================
#if SEND_NEC
/*
* Repeat commands should be sent in a 110 ms raster.
* https://www.sbprojects.net/knowledge/ir/nec.php
*/
void IRsend::sendNEC(unsigned long data, int nbits, bool repeat) {
// Set IR carrier frequency
enableIROut(38);
// Header
mark(NEC_HEADER_MARK);
if (data == REPEAT || repeat) {
// repeat "space and data"
space(NEC_REPEAT_SPACE);
} else {
space(NEC_HEADER_SPACE);
// Data
sendPulseDistanceData(data, nbits, NEC_BIT_MARK, NEC_ONE_SPACE, NEC_ZERO_SPACE);
// for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
// if (data & mask) {
// mark(NEC_BIT_MARK);
// space(NEC_ONE_SPACE);
// } else {
// mark(NEC_BIT_MARK);
// space(NEC_ZERO_SPACE);
// }
// }
}
// Footer
mark(NEC_BIT_MARK);
space(0); // Always end with the LED off
}
#endif
//+=============================================================================
// NECs have a repeat only 4 items long
//
#if DECODE_NEC
bool IRrecv::decodeNEC(decode_results *results) {
long data = 0; // We decode in to here; Start with nothing
int offset = 1; // Index in to results; Skip first entry!?
// Check header "mark"
if (!MATCH_MARK(results->rawbuf[offset], NEC_HEADER_MARK)) {
return false;
}
offset++;
// Check for repeat
if ((irparams.rawlen == 4) && MATCH_SPACE(results->rawbuf[offset], NEC_REPEAT_SPACE)
&& MATCH_MARK(results->rawbuf[offset + 1], NEC_BIT_MARK)) {
results->bits = 0;
results->value = REPEAT;
results->decode_type = NEC;
return true;
}
// Check we have enough data
if (irparams.rawlen < (2 * NEC_BITS) + 4) {
return false;
}
// Check header "space"
if (!MATCH_SPACE(results->rawbuf[offset], NEC_HEADER_SPACE)) {
return false;
}
offset++;
data = decodePulseDistanceData(results, NEC_BITS, offset, NEC_BIT_MARK, NEC_ONE_SPACE, NEC_ZERO_SPACE);
// // Build the data
// for (int i = 0; i < NEC_BITS; i++) {
// // Check data "mark"
// if (!MATCH_MARK(results->rawbuf[offset], NEC_BIT_MARK)) {
// return false;
// }
// offset++;
//
// if (MATCH_SPACE(results->rawbuf[offset], NEC_ONE_SPACE)) {
// data = (data << 1) | 1;
// } else if (MATCH_SPACE(results->rawbuf[offset], NEC_ZERO_SPACE)) {
// data = (data << 1) | 0;
// } else {
// return false;
// }
// offset++;
// }
// Success
results->bits = NEC_BITS;
results->value = data;
results->decode_type = NEC;
return true;
}
#endif
Morty Proxy This is a proxified and sanitized view of the page, visit original site.