“perhaps the greatest 🦃 event in Thanksgiving Day history …”

November 15, 2017

“perhaps the greatest 🦃 event in Thanksgiving Day history …”

Is there anything that says “Thanksgiving” better than the classic WKRP in Cincinnati episode where they stage a turkey drop from a helicopter and it all goes terribly wrong? No? I didn't think so.

We at CED came up with the ultimate decoration for Thanksgiving, our own homage to WKRP: the 🦃-drop LED matrix —

We built this from:

You could also use an Arduino Uno to drive the the panel, but the backpack has the advantage of power and signal connectors that plug directly into the LED matrix. After you've built the backpack (following Nootropic Design's excellent build instructions), here's the code you'll need to get the animation running:

/*

   WKRP-inspired falling turkeys for Thanksgiving
   scruss - 2017-11 - for Chicago Electronic Distribution
                        & Elmwood Electronics

         ***************************
          NO TURKEYS WERE HARMED IN
           THE MAKING OF THIS DEMO
         ***************************

*/

#include <Adafruit_GFX.h>   // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#include "bitmaps.h"        // frame definitions, each 24x24
#define IMGSIZE 24

// Tasteful Thanksgiving Colour definitions
//  - format is RGB-565 16-bit rrrrrggggggbbbbb₂
#define BROWNISH 0x2061  //  #200c08
#define LEAVES   0x5920  //  #582400
#define GOLD     0x41a0  //  #403400
#define RED      0x4000  //  #400000
#define OLIVE    0x2160  //  #202c00
#define BLACK    0x0000  //  #000000

// array of visible colours, stepped through in loop
uint16_t colarray[] = { BROWNISH, LEAVES, GOLD, RED, OLIVE };
#define COLMOD 5 // array modulus for looping
int colsub = 0; // current colour array position

// configuration for 32x32 matrix with
// SINGLE HEADER input pinout
// talking to Nootropic Matrix Backpack v2
#define CLK 8
#define OE  9
#define LAT 10
#define A   A0
#define B   A1
#define C   A2
#define D   A3
// If your matrix has the DOUBLE HEADER input,
//  please use values from RGB matrix panel code examples
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);

int i = 0; // alternating frame counter

void setup() {
  matrix.begin();           // initialise LED matrix
  matrix.fillScreen(BLACK); // clear the screen
}

void loop() {
  /*
      Draw alternating frames, with left and right facing turkeys

      Start drawing turkey off top of matrix, and let it scroll
      down past the end of the matrix

      X-position of left and right facing turkeys varies to make
      them fit the matrix
  */
  for (int v = -24; v < 33; v++) {
    // erase turkey by drawing it in black one row up from vertical pos
    matrix.drawBitmap(1 + ((i % 2) ? 0 : 6), v - 1,
                      (const uint8_t *)pgm_read_word(&img[i]),
                      IMGSIZE, IMGSIZE, BLACK);
    // draw turkey at vertical pos
    matrix.drawBitmap(1 + ((i % 2) ? 0 : 6), v,
                      (const uint8_t *)pgm_read_word(&img[i]),
                      IMGSIZE, IMGSIZE, colarray[colsub]);
  }
  // change colour too at end of each turkey drop
  colsub++;
  colsub %= COLMOD;
  // alternate between left and  right facing turkeys
  i++;
  i %= 2;
}

You'll need to add a file tab to the sketch called bitmaps.h for the 🦃 animation frames. You can do this with the little down-arrow (⏷) tab at the end of the Arduino IDE menu bar, then select “New Tab”. Paste this code in the new tab:

/*
   bitmaps.h -
   WKRP_Turkeys bitmap definitions
   scruss 2017-11
   generated by
     image2cpp https://javl.github.io/image2cpp/

   a very select few might recognize these bitmaps as the
   ‘imageturkey’ from the old PostScript language tutorials
*/

// AVR-specific code for storing data in program flash memory
#include <avr/pgmspace.h>

static const uint8_t PROGMEM turkeys1 [] = {
  // 'imageturkey2' - left facing
  0x00, 0x3b, 0x00, 0x00, 0x27, 0x00, 0x00, 0x24, 0x80, 0x0e, 0x49, 0x40, 0x11, 0x49, 0x20, 0x14,
  0xb2, 0x20, 0x3c, 0xb6, 0x50, 0x75, 0xfe, 0x88, 0x17, 0xff, 0x8c, 0x17, 0x5f, 0x14, 0x1c, 0x07,
  0xe2, 0x38, 0x03, 0xc4, 0x70, 0x31, 0x82, 0xf8, 0xed, 0xfc, 0xb2, 0xbb, 0xc2, 0xbb, 0x6f, 0x84,
  0x31, 0xbf, 0xc2, 0x18, 0xea, 0x3c, 0x0e, 0x3e, 0x00, 0x07, 0xfc, 0x00, 0x03, 0xf8, 0x00, 0x1e,
  0x18, 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x00, 0x00
};

static const uint8_t PROGMEM turkeys2 [] = {
  // 'imageturkey2r' - right facing
  0x00, 0xdc, 0x00, 0x00, 0xe4, 0x00, 0x01, 0x24, 0x00, 0x02, 0x92, 0x70, 0x04, 0x92, 0x88, 0x04,
  0x4d, 0x28, 0x0a, 0x6d, 0x3c, 0x11, 0x7f, 0xae, 0x31, 0xff, 0xe8, 0x28, 0xfa, 0xe8, 0x47, 0xe0,
  0x38, 0x23, 0xc0, 0x1c, 0x41, 0x8c, 0x0e, 0x3f, 0xb7, 0x1f, 0x43, 0xdd, 0x4d, 0x21, 0xf6, 0xdd,
  0x43, 0xfd, 0x8c, 0x3c, 0x57, 0x18, 0x00, 0x7c, 0x70, 0x00, 0x3f, 0xe0, 0x00, 0x1f, 0xc0, 0x00,
  0x18, 0x78, 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x00
};

// image frame array for animation
const uint8_t* const img[] PROGMEM = {
  turkeys1, turkeys2
};

The code is also on github for easy downloading: WKRP_Turkeys

If you want to learn more about driving LED panels, have a look at our sister company's blog: Flying Toaster LED Panel - Elmwood Electronics.




Leave a comment

Comments will be approved before showing up.


Also in News

The Raspberry Pi Pico
The Raspberry Pi Pico

July 28, 2021

Raspberry Pi Pico’s are a great microcontroller that has a fair amount of range, despite the slightly more tricky set up process, once it’s ready to go there’s a lot you can do. 

Continue Reading

Raspberry Pi Troubleshooting

June 30, 2021

Continue Reading

An introduction to soldering
An introduction to soldering

June 08, 2021

Soldering is a good skill to learn and improve throughout your making and DIY-ing, there’s quite a few situations where it will be the best option for a more permanent build.

Continue Reading