Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

modify Rx range test script to print stats, and blink LED

  • Loading branch information...
commit 09621b24a50b40a4a97d2331de6ba51745f5ceb3 1 parent 9d7295c
Cliff Brake authored

Showing 1 changed file with 22 additions and 23 deletions. Show diff stats Hide diff stats

  1. +22 23 examples/JeenodeRangeRx/JeenodeRangeRx.ino
45 examples/JeenodeRangeRx/JeenodeRangeRx.ino
@@ -4,27 +4,27 @@
4 4 // Based on a sample implementation by Steve Evans (@tankslappa).
5 5
6 6 #include <JeeLib.h>
7   -#include <PortsLCD.h>
8 7
9 8 #define BUFFER_SIZE 64
10 9 #define DISPLAY_INTERVAL 500 // ms
  10 +#define LED_PIN 9 // activity LED, comment out to disable
11 11
12   -PortI2C myI2C (3);
13   -LiquidCrystalI2C lcd (myI2C);
14   -MilliTimer displayTimer;
  12 +//PortI2C myI2C (3);
  13 +MilliTimer statTimer;
15 14
16 15 byte timeBuf [BUFFER_SIZE]; // index is time slot, value is last packet
17 16 byte seqBuf [BUFFER_SIZE]; // index is last packet, value is time slot
18 17 char history [11];
19 18 byte lastSeq;
20 19
21   -static void lcd3dig (byte x, byte y, byte value, char fill =' ') {
22   - lcd.setCursor(x, y);
23   - lcd.print(value >= 100 ? (char) ('0' + value / 100) : fill);
24   - lcd.print(value >= 10 ? (char) ('0' + (value / 10) % 10) : fill);
25   - lcd.print(value % 10);
  20 +static void activityLed (byte on) {
  21 +#ifdef LED_PIN
  22 + pinMode(LED_PIN, OUTPUT);
  23 + digitalWrite(LED_PIN, !on);
  24 +#endif
26 25 }
27 26
  27 +
28 28 static void gotPacket () {
29 29 byte tenths = millis() / 100;
30 30 // remember for each time slot what the last received packet was
@@ -60,31 +60,30 @@ static void updateHistory () {
60 60 }
61 61
62 62 void setup () {
63   - lcd.begin(16, 2);
64   - lcd.setCursor(0, 0);
65   - lcd.print("xxx %/5s xxx %/s");
66   - lcd.setCursor(0, 1);
67   - lcd.print("#xxx >xxxxxxxxxx");
68   - rf12_initialize('R', RF12_868MHZ, 88);
69   - // synchronize the display to 0.1s clock transitions
70   - displayTimer.set(DISPLAY_INTERVAL - millis() % DISPLAY_INTERVAL - 1);
  63 + Serial.begin(57600);
  64 + Serial.print("\n[JeenodeRangeRx]");
  65 + rf12_initialize('R', RF12_915MHZ);
71 66 }
72 67
73 68 void loop () {
74 69 if (rf12_recvDone() && rf12_crc == 0 && rf12_len == 1) {
75 70 lastSeq = rf12_data[0];
76   - lcd3dig(1, 1, lastSeq, '0');
77 71 gotPacket();
  72 + activityLed(1);
  73 + delay(5);
  74 + activityLed(0);
  75 + Serial.print("R ");
  76 + Serial.print(lastSeq);
  77 + Serial.print("\n");
78 78 }
79 79
80   - if (displayTimer.poll(DISPLAY_INTERVAL)) {
  80 + if (statTimer.poll(DISPLAY_INTERVAL)) {
81 81 // number of packets received in the last 5 seconds, as percentage
82   - lcd3dig(0, 0, recvCount(50) * 2);
  82 + //lcd3dig(0, 0, recvCount(50) * 2);
83 83 // number of packets received in the last second, as percentage
84   - lcd3dig(9, 0, recvCount(10) * 10);
  84 + //lcd3dig(9, 0, recvCount(10) * 10);
85 85 // show number of packets received in the last 10 display intervals
86 86 updateHistory();
87   - lcd.setCursor(6, 1);
88   - lcd.print(history);
  87 + //lcd.print(history);
89 88 }
90 89 }

0 comments on commit 09621b2

Please sign in to comment.
Something went wrong with that request. Please try again.