Skip to content

Commit 350bf56

Browse files
committed
Merge pull request arduino#386 from mysensors/add-optional-before-method
Add before() for initialisations before radio hogs SPI
2 parents 72a40d6 + 469cbb7 commit 350bf56

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

libraries/MySensors/core/MySensorCore.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ void _begin() {
6464
hwInit();
6565
#endif
6666

67+
// Call before() in sketch (if it exists)
68+
if (before) before();
69+
6770
debug(PSTR("Starting " MY_NODE_TYPE " (" MY_CAPABILIIES ", " LIBRARY_VERSION ")\n"));
6871

6972
signerInit();

libraries/MySensors/core/MySensorCore.h

+1
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ extern MyMessage _msgTmp; // Buffer for temporary messages (acks and nonces amo
236236
void receive(const MyMessage &message) __attribute__((weak));
237237
void receiveTime(unsigned long) __attribute__((weak));
238238
void presentation() __attribute__((weak));
239+
void before() __attribute__((weak));
239240
void setup() __attribute__((weak));
240241
void loop() __attribute__((weak));
241242

libraries/MySensors/examples/RelayActuator/RelayActuator.ino

+5-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
#define RELAY_OFF 0 // GPIO value to write to turn off attached relay
4747

4848

49-
void setup()
50-
{
49+
void before() {
5150
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
5251
// Then set relay pins in output mode
5352
pinMode(pin, OUTPUT);
@@ -56,6 +55,10 @@ void setup()
5655
}
5756
}
5857

58+
void setup() {
59+
60+
}
61+
5962
void presentation()
6063
{
6164
// Send the sketch version information to the gateway and Controller

libraries/MySensors/keywords.txt

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ wait KEYWORD2
2121
receive KEYWORD2
2222
receiveTime KEYWORD2
2323
loop KEYWORD2
24+
before KEYWORD2
2425
setup KEYWORD2
2526
presentation KEYWORD2
2627
sleep KEYWORD2

0 commit comments

Comments
 (0)