https://www.adafruit.com/product/2294
and I am controlling it using an ESP8266 board I got from a friend. So far, I haven't had any trouble making it display scrolling text, but I would like to use a different font than the default one that comes with the Adafruit libraries. I am using this code:
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#include <Fonts/pixelmix.h>
#define PIN 3
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
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(255, 255, 0),matrix.Color(0, 0, 255), matrix.Color(255, 0, 255), matrix.Color(0, 255, 255), matrix.Color(255, 255, 255)};
void setup() {
Serial.begin(115200);
delay(10);
Serial.println();
Serial.print("Starting Matrix...");
matrix.begin();
matrix.setFont(&pixelmix5pt7b);
matrix.setTextWrap(false);
matrix.setBrightness(10);
matrix.setTextColor(colors[0]);
}
int pass = 0;
String textToDisplay = "Thanks for your help!";
int pixelsInText = (textToDisplay.length() * 7) + 8;
void loop() {
if (++pass >= 7) pass = 0;
int x = matrix.width();
while(x+17 > (matrix.width() - pixelsInText)) {
matrix.fillScreen(0);
matrix.setCursor(--x, 7);
matrix.print(textToDisplay);
matrix.show();
delay(100);
}
}
I've also discovered the `fontconvert` tool that comes with the `Adafruit_GFX` library, and have compiled it and used it to generate .h files from TTF files. Through trial and error experiments, I found that I need to use the number 5 for the second parameter to `fontconvert`, like this:
./fontconvert pixelmix.ttf 5 > pixelmix.h
to get a font that is a good size for an 8 pixel high matrix. But when I added that font to the sketch, it only displayed the top row pixels from each character. So more trial and error lead me to change the original code:
matrix.setCursor(--x, 0);
to:
matrix.setCursor(--x, 7);
then the text was displayed. But I still don't quite like the font. I have tried some of the other ones in the `Fonts` directory, but it seems like they are intended for a 16 pixel high display.
I am wondering if anybody else has any experience with this, and can suggest a good font file to use? Should I stick with the number 5 for the second parameter to `fontconvert`, which I believe is the number of points of the font?
Also, since the font isn't monospaced anymore, this code:
int pixelsInText = (textToDisplay.length() * 7) + 8;
returns an incorrect value. It is too long. Is there any way to calculate the actual length of the string, in pixels, or get the value from the `Adafruit_NeoMatrix` ?
Or perhaps there's a better way of going about this?
Thanks.