Hello !
I need bigger fonts.
How can I do that ? I don’t see any fontSize
method and the only fonts that I found were
font3x5,
font5x7,
font6x10,
font8x13,
gohufont11,
gohufont11b
Hello !
I need bigger fonts.
How can I do that ? I don’t see any fontSize
method and the only fonts that I found were
font3x5,
font5x7,
font6x10,
font8x13,
gohufont11,
gohufont11b
The existing library doesn’t support any fonts larger than 8 pixels wide which is why you don’t see anything larger. Someone added some code to support larger fonts, but I haven’t tried it myself, maybe you can: Try improved font code · Issue #47 · pixelmatix/SmartMatrix · GitHub
You can use any font you want with the GitHub - marcmerlin/SmartMatrix_GFX: SmartMatrix::GFX: Allow using Adafruit::GFX as well as FastLED_NeoMatrix code with SmartMatrix backend, layer.
(shown on a neomatrix, but works the same on smartmatrix with my glue library)
I couldn’t figure out how to make it work. I opened a few issues on your github.
I will try that.
I should add, a really cool feature of Adafruit::GFX’s font support is the amount of fonts that exist for it.
If you go there, you can literally generate a font.h for close to 50 fonts, in the size of your choosing, and even see what it looks like before it’s rendered. Totally awesome
http://oleddisplay.squix.ch/#/home
I know that ! But as I said, I couldn’t figure out how to make your SmartMatrix_GFX
work.
You made the basic demo work but then had issues writing triangles. Hopefully a simple problem with coordinates but unrelated to font usage
This is the config for SmartMatrix:
#include <Arduino.h>
#include <SmartMatrix3.h>
#define COLOR_DEPTH 24 // known working: 24, 48 - If the sketch uses type `rgb24` directly, COLOR_DEPTH must be 24
const uint8_t kMatrixWidth = 64; // known working: 32, 64, 96, 128
const uint8_t kMatrixHeight = 32; // known working: 16, 32, 48, 64
const uint8_t kRefreshDepth = 24; // known working: 24, 36, 48
const uint8_t kDmaBufferRows = 2; // known working: 2-4, use 2 to save memory, more to keep from dropping frames and automatically lowering refresh rate
const uint8_t kPanelType = SMARTMATRIX_HUB75_32ROW_64COL_MOD8SCAN_L540_2727; // use SMARTMATRIX_HUB75_16ROW_MOD8SCAN for common 16x32 panels
const uint8_t kMatrixOptions = (SMARTMATRIX_OPTIONS_NONE); // see http://docs.pixelmatix.com/SmartMatrix for options
const uint8_t kBackgroundLayerOptions = (SM_BACKGROUND_OPTIONS_NONE);
const uint8_t kScrollingLayerOptions = (SM_SCROLLING_OPTIONS_NONE);
const uint8_t kIndexedLayerOptions = (SM_INDEXED_OPTIONS_NONE);
SMARTMATRIX_ALLOCATE_BUFFERS(matrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions);
SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions);
SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);
SMARTMATRIX_ALLOCATE_INDEXED_LAYER(indexedLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kIndexedLayerOptions);
const int Brightness_15 = (15*255)/100; // dim: 15% brightness
const int Brightness_25 = (25*255)/100; // dim: 25% brightness
const int Brightness_50 = (50*255)/100;
const int Brightness_75 = (75*255)/100;
const int Brightness_100 = (100*255)/100; // full (100%) brightness
const int defaultScrollOffset = 6;
const rgb24 defaultBackgroundColor = {0x40, 0, 0};
#define WHITE rgb24(0xFF,0xFF,0xFF)
#define BLACK rgb24(0x00,0x00,0x00)
#define CYAN rgb24(0x00,0xFF,0xFF)
#define RED rgb24(0xFF,0x00,0x00)
#define GREEN rgb24(0x00,0xFF,0x00)
And this is how you “start it up”
matrix.addLayer(&backgroundLayer);
matrix.addLayer(&scrollingLayer);
matrix.begin();
matrix.setBrightness(Brightness_25);
backgroundLayer.enableColorCorrection(true);
backgroundLayer.fillScreen(BLACK);
backgroundLayer.swapBuffers();
And here is a simple drawTriangle
with the same coordinates that works:
backgroundLayer.drawTriangle(41,5,41,25,58,15,WHITE);
backgroundLayer.fillTriangle(41,5,41,25,58,15,WHITE);
backgroundLayer.swapBuffers();
Now, as you saw, I tried making your API work:
#include <Arduino.h>
#include <Adafruit_GFX.h>
#include <SmartMatrix_GFX.h>
#include <SmartMatrix3.h>
// ========================== CONFIG START ===================================================
/// SmartMatrix Defines
#define COLOR_DEPTH 24 // known working: 24, 48 - If the sketch uses type `rgb24` directly, COLOR_DEPTH must be 24
#define kMatrixWidth 64 // known working: 32, 64, 96, 128
#define kMatrixHeight 32 // known working: 16, 32, 48, 64
const uint8_t kRefreshDepth = 24; // known working: 24, 36, 48
const uint8_t kDmaBufferRows = 2; // known working: 2-4, use 2 to save memory, more to keep from dropping frames and automatically lowering refresh rate
const uint8_t kPanelType = SMARTMATRIX_HUB75_32ROW_64COL_MOD8SCAN_L540_2727; // use SMARTMATRIX_HUB75_16ROW_MOD8SCAN for common 16x32 panels
//const uint8_t kPanelType = SMARTMATRIX_HUB75_64ROW_MOD32SCAN;
const uint8_t kMatrixOptions = (SMARTMATRIX_OPTIONS_NONE); // see http://docs.pixelmatix.com/SmartMatrix for options
const uint8_t kBackgroundLayerOptions = (SM_BACKGROUND_OPTIONS_NONE);
SMARTMATRIX_ALLOCATE_BUFFERS(matrixLayer, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions);
SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions);
// const int defaultBrightness = (100*255)/100; // full (100%) brightness
const int defaultBrightness = (15*255)/100; // dim: 15% brightness
#define mw kMatrixWidth
#define mh kMatrixHeight
#define NUMMATRIX (kMatrixWidth*kMatrixHeight)
CRGB leds[kMatrixWidth*kMatrixHeight];
// Sadly this callback function must be copied around with this init code
void show_callback() {
for (uint16_t y=0; y<kMatrixHeight; y++) {
for (uint16_t x=0; x<kMatrixWidth; x++) {
CRGB led = leds[x + kMatrixWidth*y];
// rgb24 defined in MatrixComnon.h
backgroundLayer.drawPixel(x, y, { led.r, led.g, led.b } );
}
}
// This should be zero copy
// that said, copy or no copy is about the same speed in the end.
backgroundLayer.swapBuffers(false);
}
SmartMatrix_GFX *matrix = new SmartMatrix_GFX(leds, mw, mh, show_callback);
// ========================== CONFIG END ======================================================
And then, the start-up inside void loop() {}
matrixLayer.addLayer(&backgroundLayer);
matrixLayer.begin();
matrixLayer.setBrightness(defaultBrightness);
matrixLayer.setRefreshRate(240);
backgroundLayer.enableColorCorrection(true);
// Time for serial port to work?
delay(1000);
backgroundLayer.fillScreen( {0x80, 0x80, 0x80} );
backgroundLayer.swapBuffers();
But I could use it to draw a triangle.
I would love to make it work because it includes SmartMatrix’s backend and adds a lot of methods, functionality and style, but I haven’t figured it out yet.
Let’s not mix everything up, this is about fonts, not triangles. I already replied on Simple code lights up the whole display · Issue #2 · marcmerlin/SmartMatrix_GFX · GitHub .
Basically don’t assume both libs use the same API for triangles.
I don’t know about APIs, but it’s basically the same method:
//SmartMatrix
void SMLayerBackground<RGB, optionFlags>::drawTriangle(int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t x3, int16_t y3, const RGB& color) {
drawLine(x1, y1, x2, y2, color);
drawLine(x2, y2, x3, y3, color);
drawLine(x1, y1, x3, y3, color);
}
//SmartMatrix_GFX
void Adafruit_GFX::drawTriangle(int16_t x0, int16_t y0,
int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color) {
drawLine(x0, y0, x1, y1, color);
drawLine(x1, y1, x2, y2, color);
drawLine(x2, y2, x0, y0, color);
}
I
Of course ! I will carry this discussion over there. I would love some help to make it work !
Thank you !
And about the fonts: if SmartMatrix_GFX won’t work, I will later try Try improved font code · Issue #47 · pixelmatix/SmartMatrix · GitHub
Is it still the case that it’s impossible to have fonts wider than 8 pixels?
Check the pull requests on GitHub, I think someone submitted a fix
(I’m updating old threads mentioning fonts.) SmartMatrix Library 4.0 will have much better support for custom fonts and larger fonts. I’m posting more details here: