1+ /*
2+ Name: NRF_Radio.ino
3+ Created: 11/30/2018 2:40:19 AM
4+ Author: michael
5+ */
6+
7+ #include " NRF51_Radio_library.h"
8+
9+
10+ NRF51_Radio MicrobitRadio = NRF51_Radio();
11+
12+ FrameBuffer *myDataSendData;
13+ const int COL1 = 3 ; // Column #1 control
14+ const int LED = 26 ; // 'row 1' led
15+ const long interval = 5000 ;
16+
17+ // define prototypes for any methods that use 'user types' created in .ino code or use cpp/h files
18+ //
19+ void test (NRF51_Radio _lib1);
20+
21+
22+ // methods below here
23+ //
24+
25+ // the setup function runs once when you press reset or power the board
26+ void setup () {
27+ Serial.begin (115200 );
28+ Serial.println (" Starting the Radio Library" );
29+ pinMode (COL1, OUTPUT);
30+ digitalWrite (COL1, LOW);
31+ pinMode (LED, OUTPUT);
32+
33+
34+ myDataSendData = new FrameBuffer ();
35+ MicrobitRadio.hello (" Test" );
36+ MicrobitRadio.enable ();
37+ }
38+
39+ // the loop function runs over and over again until power down or reset
40+ void loop () {
41+ digitalWrite (LED, HIGH);
42+
43+ static long currentMillis;
44+
45+
46+ FrameBuffer* myData = MicrobitRadio.recv ();
47+ if (myData != NULL ) {
48+ Serial.print (myData->length );
49+ Serial.print (" " );
50+ Serial.print (myData->version );
51+ Serial.print (" " );
52+ Serial.print (myData->group );
53+ Serial.print (" " );
54+ Serial.print (myData->protocol );
55+ Serial.print (" " );
56+ Serial.print (myData->payload [10 ]);
57+ Serial.print (" " );
58+ Serial.println (MicrobitRadio.dataReady ());
59+ delete myData;
60+
61+ myDataSendData->length = 3 ;
62+ myDataSendData->group = 10 ;
63+ myDataSendData->version = 12 ;
64+ myDataSendData->protocol = 14 ;
65+
66+
67+ if (millis () - currentMillis >= interval)
68+ {
69+
70+ Serial.println (currentMillis);
71+ MicrobitRadio.send (myDataSendData);
72+ currentMillis = millis ();
73+ }
74+ }
75+
76+ delay (10 );
77+ digitalWrite (LED, LOW);
78+ delay (10 );
79+ }
80+
81+ // This method demonstrates 1) using a library 2) using user types as function params
82+ void test (NRF51_Radio _lib1)
83+ {
84+ MicrobitRadio.hello (" Hello Visual Micro" );
85+ }
0 commit comments