Skip to content

Commit 1fa587d

Browse files
committed
NRF5 support
1 parent 2992d5e commit 1fa587d

File tree

15 files changed

+526
-474
lines changed

15 files changed

+526
-474
lines changed

.github/workflows/LibraryBuild.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454
- arduino:samd:arduino_zero_native
5555
- esp32:esp32:featheresp32:FlashFreq=80
5656
- SparkFun:avr:promicro
57+
- sandeepmistry:nRF5:BBCmicrobit
5758

5859
# Specify parameters for each board.
5960
# With sketches-exclude you may exclude specific examples for a board. Use a comma separated list.
@@ -75,6 +76,10 @@ jobs:
7576
arduino-platform: arduino:avr,SparkFun:avr
7677
platform-url: https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json # Arduino URL is not required here
7778

79+
- arduino-boards-fqbn: sandeepmistry:nRF5:BBCmicrobit
80+
platform-url: https://sandeepmistry.github.io/arduino-nRF5/package_nRF5_boards_index.json
81+
sketches-exclude: AiwaRCT501SendDemo,BoseWaveSendDemo,IRrecord,IRsendDemo,IRsendProntoDemo,IRsendRawDemo,IRtest,IRtest2,LegoPowerFunctionsSendDemo,JVCPanasonicSendDemo,LGACSendDemo,MicroGirs # no sending yet
82+
7883

7984
# Do not cancel all jobs / architectures if one job fails
8085
fail-fast: false

examples/IRrecord/IRrecord.ino

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ int STATUS_PIN = LED_BUILTIN;
2727

2828
IRrecv irrecv(IR_RECEIVE_PIN);
2929
IRsend irsend;
30-
decode_results results;
3130

3231
// On the Zero and others we switch explicitly to SerialUSB
3332
#if defined(ARDUINO_ARCH_SAMD)
@@ -64,24 +63,24 @@ int toggle = 0; // The RC5/6 toggle state
6463

6564
// Stores the code for later playback
6665
// Most of this code is just logging
67-
void storeCode(decode_results *aResults) {
68-
codeType = results->decode_type;
69-
// int count = results->rawlen;
66+
void storeCode() {
67+
codeType = irrecv.results.decode_type;
68+
// int count = irrecv.results.rawlen;
7069
if (codeType == UNKNOWN) {
7170
Serial.println("Received unknown code, saving as raw");
72-
codeLen = results->rawlen - 1;
71+
codeLen = irrecv.results.rawlen - 1;
7372
// To store raw codes:
7473
// Drop first value (gap)
7574
// Convert from ticks to microseconds
7675
// Tweak marks shorter, and spaces longer to cancel out IR receiver distortion
7776
for (int i = 1; i <= codeLen; i++) {
7877
if (i % 2) {
7978
// Mark
80-
rawCodes[i - 1] = results->rawbuf[i] * MICROS_PER_TICK - MARK_EXCESS_MICROS;
79+
rawCodes[i - 1] = irrecv.results.rawbuf[i] * MICROS_PER_TICK - MARK_EXCESS_MICROS;
8180
Serial.print(" m");
8281
} else {
8382
// Space
84-
rawCodes[i - 1] = results->rawbuf[i] * MICROS_PER_TICK + MARK_EXCESS_MICROS;
83+
rawCodes[i - 1] = irrecv.results.rawbuf[i] * MICROS_PER_TICK + MARK_EXCESS_MICROS;
8584
Serial.print(" s");
8685
}
8786
Serial.print(rawCodes[i - 1], DEC);
@@ -90,7 +89,7 @@ void storeCode(decode_results *aResults) {
9089
} else {
9190
if (codeType == NEC) {
9291
Serial.print("Received NEC: ");
93-
if (results->value == REPEAT) {
92+
if (irrecv.results.value == REPEAT) {
9493
// Don't record a NEC repeat value as that's useless.
9594
Serial.println("repeat; ignoring.");
9695
return;
@@ -112,9 +111,9 @@ void storeCode(decode_results *aResults) {
112111
Serial.print(codeType, DEC);
113112
Serial.println("");
114113
}
115-
Serial.println(results->value, HEX);
116-
codeValue = results->value;
117-
codeLen = results->bits;
114+
Serial.println(irrecv.results.value, HEX);
115+
codeValue = irrecv.results.value;
116+
codeLen = irrecv.results.bits;
118117
}
119118
}
120119

@@ -180,9 +179,9 @@ void loop() {
180179
sendCode(lastButtonState == buttonState);
181180
digitalWrite(STATUS_PIN, LOW);
182181
delay(50); // Wait a bit between retransmissions
183-
} else if (irrecv.decode(&results)) {
182+
} else if (irrecv.decode()) {
184183
digitalWrite(STATUS_PIN, HIGH);
185-
storeCode(&results);
184+
storeCode();
186185
irrecv.resume(); // resume receiver
187186
digitalWrite(STATUS_PIN, LOW);
188187
}

examples/IRrecvDump/IRrecvDump.ino

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ int IR_RECEIVE_PIN = 11;
2323

2424
IRrecv irrecv(IR_RECEIVE_PIN);
2525

26-
decode_results results;
27-
2826
// On the Zero and others we switch explicitly to SerialUSB
2927
#if defined(ARDUINO_ARCH_SAMD)
3028
#define Serial SerialUSB
@@ -49,60 +47,61 @@ void setup() {
4947
Serial.println(IR_RECEIVE_PIN);
5048
}
5149

52-
void dump(decode_results *aResults) {
50+
void dump() {
5351
// Dumps out the decode_results structure.
5452
// Call this after IRrecv::decode()
55-
int count = results->rawlen;
56-
if (results->decode_type == UNKNOWN) {
53+
int count = irrecv.results.rawlen;
54+
if (irrecv.results.decode_type == UNKNOWN) {
5755
Serial.print("Unknown encoding: ");
58-
} else if (results->decode_type == NEC) {
56+
} else if (irrecv.results.decode_type == NEC_STANDARD) {
57+
Serial.print("Decoded NEC_STANDARD: ");
58+
} else if (irrecv.results.decode_type == NEC) {
5959
Serial.print("Decoded NEC: ");
60-
61-
} else if (results->decode_type == SONY) {
60+
} else if (irrecv.results.decode_type == SONY) {
6261
Serial.print("Decoded SONY: ");
63-
} else if (results->decode_type == RC5) {
62+
} else if (irrecv.results.decode_type == RC5) {
6463
Serial.print("Decoded RC5: ");
65-
} else if (results->decode_type == RC6) {
64+
} else if (irrecv.results.decode_type == RC6) {
6665
Serial.print("Decoded RC6: ");
67-
} else if (results->decode_type == PANASONIC) {
66+
} else if (irrecv.results.decode_type == PANASONIC) {
6867
Serial.print("Decoded PANASONIC - Address: ");
69-
Serial.print(results->address, HEX);
68+
Serial.print(irrecv.results.address, HEX);
7069
Serial.print(" Value: ");
71-
} else if (results->decode_type == LG) {
70+
} else if (irrecv.results.decode_type == LG) {
7271
Serial.print("Decoded LG: ");
73-
} else if (results->decode_type == JVC) {
72+
} else if (irrecv.results.decode_type == JVC) {
7473
Serial.print("Decoded JVC: ");
75-
} else if (results->decode_type == AIWA_RC_T501) {
74+
} else if (irrecv.results.decode_type == AIWA_RC_T501) {
7675
Serial.print("Decoded AIWA RC T501: ");
77-
} else if (results->decode_type == WHYNTER) {
76+
} else if (irrecv.results.decode_type == WHYNTER) {
7877
Serial.print("Decoded Whynter: ");
79-
} else if (results->decode_type == BOSEWAVE) {
78+
} else if (irrecv.results.decode_type == BOSEWAVE) {
8079
Serial.print("Decoded Bose Wave Radio / CD: ");
8180
}
82-
Serial.print(results->value, HEX);
81+
Serial.print(irrecv.results.value, HEX);
8382
Serial.print(" (");
84-
Serial.print(results->bits, DEC);
83+
Serial.print(irrecv.results.bits, DEC);
8584
Serial.println(" bits)");
8685
Serial.print("Raw (");
8786
Serial.print(count, DEC);
8887
Serial.print("): ");
8988

9089
for (int i = 1; i < count; i++) {
9190
if (i & 1) {
92-
Serial.print(results->rawbuf[i] * MICROS_PER_TICK, DEC);
91+
Serial.print(irrecv.results.rawbuf[i] * MICROS_PER_TICK, DEC);
9392
} else {
9493
Serial.write('-');
95-
Serial.print((unsigned long) results->rawbuf[i] * MICROS_PER_TICK, DEC);
94+
Serial.print((unsigned long) irrecv.results.rawbuf[i] * MICROS_PER_TICK, DEC);
9695
}
9796
Serial.print(" ");
9897
}
9998
Serial.println();
10099
}
101100

102101
void loop() {
103-
if (irrecv.decode(&results)) {
104-
Serial.println(results.value, HEX);
105-
dump(&results);
102+
if (irrecv.decode()) {
103+
Serial.println(irrecv.results.value, HEX);
104+
dump();
106105
irrecv.resume(); // Receive the next value
107106
}
108107
}

examples/IRrecvDumpV2/IRrecvDumpV2.ino

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,22 @@ void setup() {
3535
//+=============================================================================
3636
// Display IR code
3737
//
38-
void ircode(decode_results *aResults) {
38+
void ircode() {
3939
// Panasonic has an Address
40-
if (results->decode_type == PANASONIC) {
41-
Serial.print(results->address, HEX);
40+
if (irrecv.results.decode_type == PANASONIC) {
41+
Serial.print(irrecv.results.address, HEX);
4242
Serial.print(":");
4343
}
4444

4545
// Print Code
46-
Serial.print(results->value, HEX);
46+
Serial.print(irrecv.results.value, HEX);
4747
}
4848

4949
//+=============================================================================
5050
// Display encoding type
5151
//
52-
void encoding(decode_results *aResults) {
53-
switch (results->decode_type) {
52+
void encoding() {
53+
switch (irrecv.results.decode_type) {
5454
default:
5555
case UNKNOWN:
5656
Serial.print("UNKNOWN");
@@ -112,37 +112,37 @@ void encoding(decode_results *aResults) {
112112
//+=============================================================================
113113
// Dump out the decode_results structure.
114114
//
115-
void dumpInfo(decode_results *aResults) {
115+
void dumpInfo() {
116116
// Check if the buffer overflowed
117-
if (results->overflow) {
117+
if (irrecv.results.overflow) {
118118
Serial.println("IR code too long. Edit IRremoteInt.h and increase RAW_BUFFER_LENGTH");
119119
return;
120120
}
121121

122122
// Show Encoding standard
123123
Serial.print("Encoding : ");
124-
encoding(results);
124+
encoding();
125125
Serial.println("");
126126

127127
// Show Code & length
128128
Serial.print("Code : 0x");
129-
ircode(results);
129+
ircode();
130130
Serial.print(" (");
131-
Serial.print(results->bits, DEC);
131+
Serial.print(irrecv.results.bits, DEC);
132132
Serial.println(" bits)");
133133
}
134134

135135
//+=============================================================================
136136
// Dump out the decode_results structure.
137137
//
138-
void dumpRaw(decode_results *aResults) {
138+
void dumpRaw() {
139139
// Print Raw data
140140
Serial.print("Timing[");
141-
Serial.print(results->rawlen - 1, DEC);
141+
Serial.print(irrecv.results.rawlen - 1, DEC);
142142
Serial.println("]: ");
143143

144-
for (unsigned int i = 1; i < results->rawlen; i++) {
145-
unsigned long x = results->rawbuf[i] * MICROS_PER_TICK;
144+
for (unsigned int i = 1; i < irrecv.results.rawlen; i++) {
145+
unsigned long x = irrecv.results.rawbuf[i] * MICROS_PER_TICK;
146146
if (!(i & 1)) { // even
147147
Serial.print("-");
148148
if (x < 1000)
@@ -158,7 +158,7 @@ void dumpRaw(decode_results *aResults) {
158158
if (x < 100)
159159
Serial.print(" ");
160160
Serial.print(x, DEC);
161-
if (i < results->rawlen - 1)
161+
if (i < irrecv.results.rawlen - 1)
162162
Serial.print(", "); //',' not needed for last one
163163
}
164164
if (!(i % 8))
@@ -170,17 +170,17 @@ void dumpRaw(decode_results *aResults) {
170170
//+=============================================================================
171171
// Dump out the decode_results structure.
172172
//
173-
void dumpCode(decode_results *aResults) {
173+
void dumpCode() {
174174
// Start declaration
175175
Serial.print("unsigned int "); // variable type
176176
Serial.print("rawData["); // array name
177-
Serial.print(results->rawlen - 1, DEC); // array size
177+
Serial.print(irrecv.results.rawlen - 1, DEC); // array size
178178
Serial.print("] = {"); // Start declaration
179179

180180
// Dump data
181-
for (unsigned int i = 1; i < results->rawlen; i++) {
182-
Serial.print(results->rawbuf[i] * MICROS_PER_TICK, DEC);
183-
if (i < results->rawlen - 1)
181+
for (unsigned int i = 1; i < irrecv.results.rawlen; i++) {
182+
Serial.print(irrecv.results.rawbuf[i] * MICROS_PER_TICK, DEC);
183+
if (i < irrecv.results.rawlen - 1)
184184
Serial.print(","); // ',' not needed on last one
185185
if (!(i & 1))
186186
Serial.print(" ");
@@ -191,50 +191,48 @@ void dumpCode(decode_results *aResults) {
191191

192192
// Comment
193193
Serial.print(" // ");
194-
encoding(results);
194+
encoding();
195195
Serial.print(" ");
196-
ircode(results);
196+
ircode();
197197

198198
// Newline
199199
Serial.println("");
200200

201201
// Now dump "known" codes
202-
if (results->decode_type != UNKNOWN) {
202+
if (irrecv.results.decode_type != UNKNOWN) {
203203

204204
// Some protocols have an address
205-
if (results->decode_type == PANASONIC) {
205+
if (irrecv.results.decode_type == PANASONIC) {
206206
Serial.print("unsigned int addr = 0x");
207-
Serial.print(results->address, HEX);
207+
Serial.print(irrecv.results.address, HEX);
208208
Serial.println(";");
209209
}
210210

211211
// All protocols have data
212212
Serial.print("unsigned int data = 0x");
213-
Serial.print(results->value, HEX);
213+
Serial.print(irrecv.results.value, HEX);
214214
Serial.println(";");
215215
}
216216
}
217217

218218
//+=============================================================================
219219
// Dump out the raw data as Pronto Hex.
220220
//
221-
void dumpPronto(decode_results *aResults) {
221+
void dumpPronto() {
222222
Serial.print("Pronto Hex: ");
223-
irrecv.dumpPronto(Serial, results);
223+
irrecv.dumpPronto(Serial);
224224
Serial.println();
225225
}
226226

227227
//+=============================================================================
228228
// The repeating section of the code
229229
//
230230
void loop() {
231-
decode_results results; // Somewhere to store the results
232-
233-
if (irrecv.decode(&results)) { // Grab an IR code
234-
dumpInfo(&results); // Output the results
235-
dumpRaw(&results); // Output the results in RAW format
236-
dumpPronto(&results);
237-
dumpCode(&results); // Output the results as source code
231+
if (irrecv.decode()) { // Grab an IR code
232+
dumpInfo(); // Output the results
233+
dumpRaw(); // Output the results in RAW format
234+
dumpPronto();
235+
dumpCode(); // Output the results as source code
238236
Serial.println(""); // Blank line between entries
239237
irrecv.resume(); // Prepare for the next value
240238
}

0 commit comments

Comments
 (0)