I'd like to understand how I can use my own 4x5 font data with a 5x8 neopixel array. I've done some work making the characters, padding them with zeros, inserting them into the 5x7 font data file, and displaying them on the LED array. I can do this without any problems. The problem is that I'd like to be able to construct a string and then display it without a large gap between characters, whithout having to move the cursor left one position after displaying each character.
I'm trying to upcycle an old clock radio into an LED clock using 2 of the 5x8 neopixel boards, and an Arduino Pro Mini. The shape of the old clock radio that I wish to use is such that the NeoPixels will have to be mounted 'sideways' with a total of 5 horizontal lines, each containing 16 LEDs (when the two neopixel boards are placed side by side).
I'm trying to create my own font table with numbers (and some other characters) that are 5 bits tall and 4 bits wide. Whenever I try to make my own font that isn't 5 bits wide (ie a different width from the font data is stored in glcdfont.c) I have the problem that the matrix does not display what I hope. Here are exerts from the two font data files. First the glcdfont.c file, and then my own:
Code: Select all
//exert from gcldfont.c lines 62 - 71
//bytes 240 - 289 of font
//characters 0 - 9
..... 0x3E, 0x51, 0x49, 0x45, 0x3E,
0x00, 0x42, 0x7F, 0x40, 0x00,
0x72, 0x49, 0x49, 0x49, 0x46,
0x21, 0x41, 0x49, 0x4D, 0x33,
0x18, 0x14, 0x12, 0x7F, 0x10,
0x27, 0x45, 0x45, 0x45, 0x39,
0x3C, 0x4A, 0x49, 0x49, 0x31,
0x41, 0x21, 0x11, 0x09, 0x07,
0x36, 0x49, 0x49, 0x49, 0x36,
0x46, 0x49, 0x49, 0x29, 0x1E, .....
Code: Select all
//exert from Aeroboyfont.c lines 62 - 71
//bytes 188 - 227 of font
//characters 0 - 9
..... 0x0E,0x11,0x11,0x0E, //0
0x00,0x12,0x1F,0x10, //1
0x12,0x09,0x15,0x12, //2
0x05,0x07,0x07,0x03, //3
0x0F,0x08,0x1C,0x08, //4
0x17,0x15,0x15,0x09, //5
0x0E,0x15,0x15,0x08, //6
0x01,0x19,0x05,0x02, //7
0x0A,0x15,0x15,0x0A, //8
0x02,0x15,0x15,0x0A, //9 .....
(When I run this sketch with the original font definition and include statement in Adafruit_GFX.cpp I see the to 5x5 area of the full 5x7 numeric characters being displayed in order from 0 to 9).
Code: Select all
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif
#define PIN 2
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(8, 5, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE,
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.begin();
matrix.setTextWrap(false);
matrix.setBrightness(10);
matrix.setTextColor(colors[0]);
matrix.fillScreen(0);
delay(2000);
}
void loop() {
for(int i=0; i<=9; i++) {
matrix.fillScreen(0);
matrix.setCursor(0, 0);
matrix.print(String(i));
matrix.show();
delay(1000);
}
}
I assume there is a mapping / calculation called by matrix.print that returns the correct bytes of font data given an ascii character code - and its this mapping that I need to modify in order to implement my smaller font... Is this correct? I have looked through the code but cannot find anything obvious. Can you point me in the right direction please?
Thanks in advance.