|
Authors: jcw
Now that there’s a Graphics Board, I thought I’d make a little display with the last few readings from a couple of room nodes around here. Ironically, it’s just a 8×21 character text display for now – no graphics in sight:

The information consists of:
- a packet sequence number (only 4-byte packets are treated as room nodes)
- the node ID
- the temperature in °C
- the relative humidity in %
- the measured light intensity (0..255)
New readings get added at th bottom, with older readings scrolling upwards.
Unfortunately, the ST7565 library doesn’t have a normal print() & println() API, so the first thing I did was to create a new wrapper class:

One quirk about this code is that since we’re using a RAM buffer, the ST7565 screen contents needs to be explicitly updated. I solved it by adding a poll() method which you need to call in the main loop. It’ll make sure that the display gets refreshed shortly after anything new has been “printed” (default is within 0.1 s).
Another thing this class does is to scroll the contents of the display one line up when the bottom is reached. It does this in a slightly lazy manner, i.e. the display is not scrolled immediately when a newline is sent to it but when the first character on the next line falls outside the display area – a subtle but important difference, because it lets you use println() calls and the display won’t constantly leave an empty line at the bottom.
Scroll support does require one change to the “ST7565.cpp” source code. This:
static byte gLCDbuf[1024];
Has to be changed as follows, to make the RAM buffer accessible from other source files:
byte gLCDbuf[1024];
(should be around line 42 in ST7565.cpp)
With that out of the way, here’s the glcdNode.pde sketch, which has been added to the RF12 library:

For debugging purposes, the same information shown on the display is also sent to the serial port:

Note that gldeNode is hard-coded to receive packets from net group 5 @ 868 MHz, as you can see in the call to rf12_initialize().
So now I have a battery-powered wireless gadget which lets me track what our house is trying to tell us!
Read more: |