nRF module as option

This commit is contained in:
giuliof 2019-04-19 10:06:23 +02:00
parent d91ab82014
commit b35e7b926c
1 changed files with 17 additions and 7 deletions

View File

@ -18,16 +18,22 @@
// version MEGA01_2 Added end number information. Needs Archeryclock2401 or newer. (older archeryclock versions don't sent the end number information to arduine)
// version MEGA02_1 Changes because of a change in protocoll for AC 241 (nr of archers and E and F shooters) and added functionality: emergency stop, add archers E and F. Changes for signal robustness. (0 (0000) is sent as 12 (1100) to prevent decoding issues when 3 times 0 is sent (000000000000)
#include "utils.h"
#include <SPI.h>
#include <RF24.h>
// #define GOLEM_PANEL
// Uncomment to enable nRF24 module
// #define HAS_WIFI
#include "utils.h"
#ifdef HAS_WIFI
#include <SPI.h>
#include <RF24.h>
#endif
/* * * * * * * * * * NRF24 Radio Module * * * * * * * * * */
uint64_t device_address = 0x0110104334LL;
//Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 40 (CE) & 41 (CSN)
RF24 radio(40, 41);
#ifdef HAS_WIFI
uint64_t device_address = 0x0110104334LL;
//Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 40 (CE) & 41 (CSN)
RF24 radio(40, 41);
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// Commands data structures
@ -156,6 +162,7 @@ boolean parseCommand(ReceivedCommand_t &ReceivedCommand)
// A command is received
char digit;
#ifdef HAS_WIFI
// Parse command from nRF packets
if (radio.available())
{
@ -167,6 +174,7 @@ boolean parseCommand(ReceivedCommand_t &ReceivedCommand)
return 1;
}
#endif
if (dataAvailable(digit))
{
@ -225,6 +233,7 @@ void setup()
// Communication w/XBEE
Serial1.begin(9600);
#ifdef HAS_WIFI
// Communication with nRF24
radio.begin();
// Set the PA Level low to prevent power supply related issues since this is a
@ -241,6 +250,7 @@ void setup()
// Start the radio listening for data
radio.startListening();
#endif
}
void loop()