So I was quietly having a brew a few days back when I say @Janet’s excellent post about setting up a Raspberry Pi to monitor the #BCWildFire twitter feed and flash a LED every time it sends a tweet…
I immediately felt the need to build one…
But I wanted a big red rotating emergency light…
I didn’t have one…
Well actually I did (a gift from @TomKeddie) but I never got around to usign it and eventually donated it to the space and I think @xquared put it to use…
So I still didn’t have one…
But I do have a crap load of various types of WS2812 pixel leds…
And I membered that I had made up some of @Jarrett LED strips a while back and had not used them for anything yet…
So I put them to use… Figured 5 high was about right and just needed to mount them on something…
Covered it with some thin packing foam to use as a diffuser…
Then looked at programming it (always my downfall)… Originally I just wanted to simulate a red fire truck like beacon but then I thought perhaps I could display text on it. Spent some quality Goggle time and eventually found the Adafruit NeoPixel GFX library. Unfortunately it’s included fonts were all too larger for the 8 high x 8 wide matrix I had. Spent more time and eventually found a few fonts that would work and more importantly some code that showed my how to use different fonts. Also eventually discovered you had to set the cursor start position differently for new fonts compared to the stock font.
Anyways I ended up with this:
My plans going forward are to:
Figure out how to do bit map graphics to make a simulation of a rotating light. This will possibly include having the edges dim out but not sure if it is needed…
Have the Nano listen to a Pi that monitors various Twitter feeds (VFRS/VPD/Etc)
Have the Pi send some sort of command to the Nao that indicates a tweet and from what agency…
Have the Nano then start displaying and alternating beacon and mebbe the agency name…
So like displaying VFRS in red, VPD in blue, BCWildFire in something…
Of course I may never get any further than what I have here…
And I know my bench is a mess…
Here is the code I used which is one of the Adafruit NeoMatrix examples…
The TomThumb font is actually included in the library…
// Adafruit_NeoMatrix example for single NeoPixel Shield.
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#include <Fonts/TomThumb.h>
#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif
#define PIN 6
// MATRIX DECLARATION:
// Parameter 1 = width of NeoPixel matrix
// Parameter 2 = height of matrix
// Parameter 3 = pin number (most are valid)
// Parameter 4 = matrix layout flags, add together as needed:
// NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT:
// Position of the FIRST LED in the matrix; pick two, e.g.
// NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
// NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal
// rows or in vertical columns, respectively; pick one or the other.
// NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed
// in the same order, or alternate lines reverse direction; pick one.
// See example below for these values in action.
// Parameter 5 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
// Example for NeoPixel Shield. In this application we'd like to use it
// as a 5x8 tall matrix, with the USB port positioned at the top of the
// Arduino. When held that way, the first pixel is at the top right, and
// lines are arranged in columns, progressive order. The shield uses
// 800 KHz (v2) pixels that expect GRB color data.
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(8, 5, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_RIGHT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);
const uint16_t colors[] = {
matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) };
void setup() {
matrix.setFont(&TomThumb);
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(30);
matrix.setTextColor(colors[0]);
}
int x = matrix.width();
int pass = 0;
void loop() {
matrix.fillScreen(0);
matrix.setCursor(x, 5);
matrix.print(F("VHS"));
if(--x < -14) {
x = matrix.width();
if(++pass >= 3) pass = 0;
matrix.setTextColor(colors[pass]);
}
matrix.show();
delay(150);
}