Neomatrix/neopixels on the core help debugging. Almost like not importing libraries

Hey guys,
I recently got a core and loving most of the features. Pre-ordered some Photons too :).

I’ve been trying to use the core to replicate some Arduino functionality I have to draw a 16 x 16 smily face on a NeoMatrix panel which is basically a 16 x 16 neopixel panel.

I found an awesome NeoMatrix library that somebody gratiously ported to the core but have been having immense issues either importing or using it.
The NeoMatrix port is here: https://github.com/delianides/SparkCore-NeoMatrix

I apologize for the code bomb below but don’t know how else to show it. I’m still a super newbie with the core and the WebIde (used to vim coding) and I guess my first problem is if the NeoMatrix port is even available to my script once i’ve imported it.

I’d like to use this to be able to make a RESTFUL upload of my 16x16 gif or animated gif and then spit out the RGB arrays and have them render on the core. Something I wouldn’t be able to do on an Arduino unless I dealt with Firmata stuff.

The code:

/*-------------------------------------------------------------------------
  Spark Core library to control WS2811/WS2812 based RGB
  LED devices such as Adafruit NeoPixel strips and matrices.
  Currently handles 800 KHz and 400kHz bitstream on Spark Core,
  WS2812, WS2812B and WS2811.

  Also supports Radio Shack Tri-Color Strip with TM1803 controller
  400kHz bitstream.

  PLEASE NOTE that the NeoPixels require 5V level inputs
  and the Spark Core only has 3.3V level outputs. Level shifting is
  necessary, but will require a fast device such as one of the following:

  [SN74HCT125N]
  http://www.digikey.com/product-detail/en/SN74HCT125N/296-8386-5-ND/376860

  [SN74HCT245N]
  http://www.digikey.com/product-detail/en/SN74HCT245N/296-1612-5-ND/277258

  [TXB0108PWR]
  http://www.digikey.com/product-search/en?pv7=2&k=TXB0108PWR

  If you have a Spark Shield Shield, the TXB0108PWR 3.3V to 5V level
  shifter is built in.

  Written by Phil Burgess / Paint Your Dragon for Adafruit Industries.
  Modified to work with Spark Core by Technobly.
  Modified for use with Matrices by delianides.
  Contributions by PJRC and other members of the open source community.

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing products
  from Adafruit!
  --------------------------------------------------------------------*/

#include "application.h"
#include "neomatrix/neomatrix.h"
#include <Metro.h>
// IMPORTANT: Set pixel PIN and TYPE
#define PIN D5
#define PIXEL_TYPE WS2812B

// MATRIX DECLARATION:
// Parameter 1 = width of EACH NEOPIXEL MATRIX (not total display)
// Parameter 2 = height of each matrix
// Parameter 3 = number of matrices arranged horizontally
// Parameter 4 = number of matrices arranged vertically
// Parameter 5 = pin number (most are valid)
// Parameter 6 = 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 FIRST MATRIX; pick two, e.g.
//     NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
//   NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs WITHIN EACH MATRIX are
//     arranged in horizontal rows or in vertical columns, respectively;
//     pick one or the other.
//   NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns WITHIN
//     EACH MATRIX proceed in the same order, or alternate lines reverse
//     direction; pick one.
//   NEO_TILE_TOP, NEO_TILE_BOTTOM, NEO_TILE_LEFT, NEO_TILE_RIGHT:
//     Position of the FIRST MATRIX (tile) in the OVERALL DISPLAY; pick
//     two, e.g. NEO_TILE_TOP + NEO_TILE_LEFT for the top-left corner.
//   NEO_TILE_ROWS, NEO_TILE_COLUMNS: the matrices in the OVERALL DISPLAY
//     are arranged in horizontal rows or in vertical columns, respectively;
//     pick one or the other.
//   NEO_TILE_PROGRESSIVE, NEO_TILE_ZIGZAG: the ROWS/COLUMS OF MATRICES
//     (tiles) in the OVERALL DISPLAY proceed in the same order for every
//     line, or alternate lines reverse direction; pick one.  When using
//     zig-zag order, the orientation of the matrices in alternate rows
//     will be rotated 180 degrees (this is normal -- simplifies wiring).
//   See example below for these values in action.
// Parameter 7 = pixel type flags, add together as needed:
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 pixels)
//   NEO_GRB     Pixels are wired for GRB bitstream (v2 pixels)
//   NEO_KHZ400  400 KHz bitstream (e.g. FLORA v1 pixels)
//   NEO_KHZ800  800 KHz bitstream (e.g. High Density LED strip)
//   For Spark Core developement it should probably also be WS2812B if you're
//   using adafruit neopixels.

// Example with three 10x8 matrices (created using NeoPixel flex strip --
// these grids are not a ready-made product).  In this application we'd
// like to arrange the three matrices side-by-side in a wide display.
// The first matrix (tile) will be at the left, and the first pixel within
// that matrix is at the top left.  The matrices use zig-zag line ordering.
// There's only one row here, so it doesn't matter if we declare it in row
// or column order.  The matrices use 800 KHz (v2) pixels that expect GRB
// color data.

Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(16,16,1,1, PIXEL_PIN,
  NEO_TILE_TOP   + NEO_TILE_LEFT   + NEO_TILE_ROWS   + NEO_TILE_PROGRESSIVE +
  NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
  PIXEL_TYPE);

const unsigned char smileRedFrame0[16*16] = {0,0,0,0,0,219,194,165,157,179,212,0,0,0,0,0,0,0,0,221,183,192,214,227,221,192,146,121,212,0,0,0,0,0,217,204,244,255,255,255,255,255,249,197,114,194,0,0,0,222,216,255,255,246,255,255,255,255,248,255,207,110,211,0,0,207,255,255,141,0,71,255,255,78,0,138,255,177,111,0,221,233,255,255,80,0,6,255,255,14,0,73,255,215,125,210,212,248,255,255,252,148,222,255,255,226,147,250,255,231,151,175,198,253,255,255,255,255,255,255,255,255,255,255,255,235,166,141,193,246,255,221,217,255,255,255,255,255,255,211,230,237,163,145,204,223,255,194,38,255,255,255,255,255,255,33,211,225,145,180,218,185,249,255,95,100,255,255,255,255,86,114,255,186,124,213,0,159,202,253,255,112,52,112,111,50,126,255,207,146,125,0,0,220,136,197,240,255,241,180,181,238,255,201,152,107,219,0,0,0,209,114,162,201,223,237,232,207,174,129,98,208,0,0,0,0,0,220,128,99,123,141,137,112,88,126,221,0,0,0,0,0,0,0,0,220,182,144,144,186,220,0,0,0,0,0};
const unsigned char smileGreenFrame0[16*16] = {0,0,0,0,0,220,191,159,152,177,213,0,0,0,0,0,0,0,0,222,168,170,190,203,198,173,130,112,213,0,0,0,0,0,215,180,221,253,255,255,251,242,226,178,101,194,0,0,0,222,191,242,255,248,255,255,255,255,239,245,188,97,212,0,0,187,235,255,143,0,71,255,255,78,0,130,244,161,100,0,221,207,254,255,80,0,6,255,255,12,0,74,255,194,110,210,205,224,255,255,251,148,222,255,255,225,146,251,255,208,136,171,185,230,255,255,255,255,255,255,255,255,255,255,255,212,151,134,181,222,255,221,217,255,255,255,255,255,255,212,219,215,149,139,200,198,255,196,37,255,255,255,255,255,255,35,192,205,130,176,219,165,223,255,97,100,255,255,255,255,89,103,244,169,109,214,0,147,182,232,255,113,54,115,113,51,113,245,188,132,115,0,0,221,122,178,217,255,224,165,164,216,237,184,138,94,220,0,0,0,210,101,146,182,202,216,212,188,158,118,86,209,0,0,0,0,0,222,124,88,110,128,124,100,78,120,223,0,0,0,0,0,0,0,0,222,182,143,142,186,222,0,0,0,0,0};
const unsigned char smileBlueFrame0[16*16] = {0,0,0,0,0,228,174,119,116,167,223,0,0,0,0,0,0,0,0,229,83,50,69,88,90,72,46,65,224,0,0,0,0,0,208,53,84,113,121,122,124,123,119,88,37,197,0,0,0,227,55,98,127,125,146,146,146,149,128,133,103,39,221,0,0,78,88,127,77,0,48,167,169,54,0,77,137,89,58,0,221,64,107,142,50,0,12,173,177,17,0,49,153,117,53,216,170,79,112,139,145,92,145,180,181,152,96,153,150,125,78,159,113,89,116,138,160,175,176,173,175,181,184,172,151,129,95,102,116,86,118,116,127,166,166,170,172,171,176,133,129,132,93,107,171,67,114,96,30,172,164,165,167,171,178,28,116,128,77,165,225,47,96,132,52,63,167,174,176,172,58,65,147,109,55,220,0,71,65,105,131,58,35,72,72,34,69,144,117,81,71,0,0,231,28,72,102,128,114,89,91,122,136,112,86,43,230,0,0,0,215,23,53,89,103,113,115,107,94,64,38,214,0,0,0,0,0,236,92,23,41,63,65,47,31,93,235,0,0,0,0,0,0,0,0,235,183,132,131,187,234,0,0,0,0,0};
Metro AnimateTimer = Metro(10);
byte FrameNumber = 0;

const uint16_t colors[] = {
  matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) };

void setup() {
  matrix.begin();
  //matrix.setTextWrap(false);
  matrix.setBrightness(30);
  //matrix.setTextColor(matrix.Color(80,255,0));
  matrix.fillScreen(0);
  matrix.show();
}



void loop() {
  if (AnimateTimer.check() == 1) {
    TimerEvent();
  }
}

uint16_t drawRGB24toRGB565(byte r, byte g, byte b) {
  return ((r / 8) << 11) | ((g / 4) << 5) | (b / 8);
}

void TimerEvent() {
  if (FrameNumber == 0) {
      for (byte y = 0; y < 16; y++) {
        for (byte x = 0; x < 16; x++) {
          byte loc = x + y*16;
          matrix.drawPixel(x, y, drawRGB24toRGB565((smileRedFrame0[loc]), (smileGreenFrame0[loc]), (smileBlueFrame0[loc])));
        }
      }
      FrameNumber = 0;
  }
  matrix

The error I get is below:

    In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from neomatrix/neomatrix.h:23,
from neomatrix/neomatrix.cpp:36:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
In file included from neomatrix/neomatrix.cpp:36:0:
neomatrix/neomatrix.h:24:42: fatal error: ../Adafruit_GFX/Adafruit_GFX.h: No such file or directory
#include "../Adafruit_GFX/Adafruit_GFX.h"
^
compilation terminated.
make: *** [neomatrix/neomatrix.o] Error 1

It’s almost like the library wasn’t imported or loaded properly and i’m at a loss for how to make the GFX and NEOMATRIX stuff available to my folder and how to just include them with the Web Ide mechanism.

@synteny, all the libraries you need are on the web IDE. All you need to do is build your app, select each library (neopixel, neomatrix and Adafruit_GFX) and you’re off to the races! The error you get shows that you either did not include the GFX library or the reference to the library is at issue.

If you are using Spark CLI or DEV, then download the repos from each library into a single (all in one) directory and compile the directory. :smile:

1 Like