I made a 16x32 pixel-LED matrix (5 feet x 2 feet) based on Adafruit's 16x32 smaller matrix board. Anticipating I would need more "oomph", I designed my I/O driver board with an Atmega328 AND a swappable Teensy3.2. (see photo 2938 below that shows the Atmega 328 with pin numbers at top left, bounded on both sides by a tall box header that accepts the Teensy). The matrix works on some Arduino sketches that aren't too "write" intensive, but for others, all my LEDs go bonkers. I'm sure it is the speed problem.
I removed the 328 and plugged in the Teensy with all wire connections of my (custom) PCB going to similar spots. After changing some of the Defines for pins (Clock, OE and LAT), and compiling, I get errors that many others obtained with other products. One of the errors is: error: cannot convert 'volatile uint8_t* {aka volatile unsigned char*}' to 'volatile PortType* {aka volatile long unsigned int*}' in assignment
latport = portOutputRegister(digitalPinToPort(lat)); There are numerous other errors with same message. I can include all the errors if required.
The program I'm running is an Adafruit example from their RGBMatrixPanel library. I use their small board as a "control" so I can see what I expect on the larger display.
Here is the code (works fine with UNO or naked Atmega328):
So, my question is how to make the Teensy work in place of the Atmega328. Attached are photos and schematic. I'm more a hardware guy than a software guy...don't know C++ or library manipulation that well.
I removed the 328 and plugged in the Teensy with all wire connections of my (custom) PCB going to similar spots. After changing some of the Defines for pins (Clock, OE and LAT), and compiling, I get errors that many others obtained with other products. One of the errors is: error: cannot convert 'volatile uint8_t* {aka volatile unsigned char*}' to 'volatile PortType* {aka volatile long unsigned int*}' in assignment
latport = portOutputRegister(digitalPinToPort(lat)); There are numerous other errors with same message. I can include all the errors if required.
The program I'm running is an Adafruit example from their RGBMatrixPanel library. I use their small board as a "control" so I can see what I expect on the larger display.
Here is the code (works fine with UNO or naked Atmega328):
Code:
Vers History: V1.0 Start
V1.1 Made note that setRotation is 0 for Adafruit, 2 for FE
Written by Limor Fried/Ladyada & Phil Burgess/PaintYourDragon
*/
#include <RGBmatrixPanel.h>
//#define CLK 8 // Atmega 328
//#define OE 9
//#define LAT 10
//#define A A0
//#define B A1
//#define C A2
#define CLK 15 // Teensy 3.2
#define OE 12
#define LAT 11
#define A A0
#define B A1
#define C A2
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);//won't work if true
// Similar to F(), but for PROGMEM string pointers rather than literals
#define F2(progmem_ptr) (const __FlashStringHelper *)progmem_ptr
const char str1[] PROGMEM = "Hello Indian Harbour";
int16_t textX = matrix.width(),
textMin = sizeof(str1) * -6,//-12 def, -6 makes text appear faster (less space) -12 needed for text size 2
hue = 0;
/*****************************************/
void setup() {
matrix.begin();
matrix.setTextWrap(false); //true= 16 rows 2 lines false: 8 rows,one line
matrix.setTextSize(2);//0 or 1=upper 8 rows, 2=uses both rows,large text, 3=overscans if =2, need str size of -12
matrix.setTextColor(matrix.Color333(7, 0, 3));
matrix.setRotation(2);//0 for Adafruit, 2 for FE display
}
/****************************************/
void loop() {
//byte i;
//Clear background
matrix.fillScreen(matrix.Color333(0, 0, 0)); // R,G,B 7 is max
// Draw big scrolly text on top. HSV: hue, saturation, brightness (0 is off)
//matrix.setTextColor(matrix.ColorHSV(1000, 155,250, true));//hue=500, bright green, 1000 bright blue
matrix.setCursor(textX, 0);//1=def row space above first line of text 4=middle
matrix.print(F2(str1));
delay(150);//scroll speed
// Move text left (w/wrap), increase hue
if ((--textX) < textMin) textX = matrix.width();//need for scroll hue does not increase
hue += 7;//prints red only if commmented out, def=7
// if (hue >= 1536) hue -= 1536;
// hue=500;//FE added 500 is bright green
#if !defined(__AVR__)
// On non-AVR boards, delay slightly so screen updates aren't too quick.
delay(20);
#endif
// Update display
matrix.swapBuffers(false);
}
So, my question is how to make the Teensy work in place of the Atmega328. Attached are photos and schematic. I'm more a hardware guy than a software guy...don't know C++ or library manipulation that well.