AaronLiddiment / LEDText

FastLED Flexible Text Message Class requires LEDMatrix Class
89 stars 32 forks source link

Unscaled font possible? #23

Closed DrRetro closed 2 years ago

DrRetro commented 2 years ago

Currently I am trying to work with your library on a LED WS2812b matrix with a LED height of 8 LEDs and 32 LEDs width. I noticed that the Robotron font is "scaled" which leads to unsightly fragments. As an alternative I converted the Commodore font (8x8) as a header file and inserted it into my project. This has at the bottom of every Byte also (almost) always an empty line of bits e.g. B8(00000000), which is however also scaled/truncated away from the library...? How can I solve this behavior? Thanks in advance for help!

AaronLiddiment commented 2 years ago

There is no scaling! The code size would increase massively to do scaled fonts. The Robotron font is lifted directly from the arcade game and doesn't to my mind have any unsightly fragments. It must be something to do with your code using it. I presume in the top of your Commodore font header you modified the 7's to 8's for width & height? I also presume you call the Init function with a window size large enough for the text to be displayed? Perhaps you need to post a portion of your code so I can see what might be wrong.

DrRetro commented 2 years ago

Hello Aaron,

Thank you very much for your quick reply. First of all to your questions: Q: I presume in the top of your Commodore font header you modified the 7's to 8's for width & height? A: Yes, I have. In the nopastelink you can find the CommodoreFontGER.h so you can see for yourself. Feel free to add it to your project. It was ouwendig enough to create the file from single images the characters with some python-magic. So I think it would be a pity to keep them for myself ;) https://nopaste.chaoz-irc.net/view/06bda814

Q: I also presume you call the Init function with a window size large enough for the text to be displayed? I thought of that too. It is two matrix panels 8x32 that are simply clamped together. Below you can find the main.cpp I used. It is also just a CnP from another page, so I can at least test the panel and the lib so far. Of course there could still be a bug, who knows? Anyway: Via the Imgur link you can find a video of my test setup and there you can see the challenge: The font is not displayed in a size of 7 (as you can see with the capital letters), but in a size of 8. Likewise you can see well at the L, I, D, P and ! the fragments I mean. Do you have any ideas about this? Many thanks in advance!

https://imgur.com/a/QnOcZbb

`#include

include

include

include

include

//#include

// Change the next 6 defines to match your matrix type and size

define LED_PIN 16

define COLOR_ORDER GRB

define CHIPSET WS2812B

define MATRIX_WIDTH 64

define MATRIX_HEIGHT 8

define MATRIX_TYPE VERTICAL_MATRIX // Wie sind die LEDs angeordnet

cLEDMatrix<MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE> leds;

cLEDText ScrollingMsg;

const unsigned char TxtDemo[] = { EFFECT_SCROLL_LEFT " DISCO POGO! DINGELINGELING!" }; void setup() { FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds[0], leds.Size()); FastLED.setBrightness(10); // WICHTIG - Hier wird die Helligkeit eingestellt. Am Anfang einen niedrigen Wert verwenden, und langsam hochtasten. FastLED.clear(true); delay(500); FastLED.showColor(CRGB::Red); delay(1000); FastLED.showColor(CRGB::Lime); delay(1000); FastLED.showColor(CRGB::Blue); delay(1000); FastLED.showColor(CRGB::White); delay(1000); FastLED.show();

ScrollingMsg.SetFont(CommodoreFontData); ScrollingMsg.Init(&leds, leds.Width(), ScrollingMsg.FontHeight() + 1, 0, 0); ScrollingMsg.SetText((unsigned char *)TxtDemo, sizeof(TxtDemo) - 1); ScrollingMsg.SetTextColrOptions(COLR_RGB | COLR_SINGLE, 0xff, 0x00, 0xff); }

void loop() { if (ScrollingMsg.UpdateText() == -1){ ScrollingMsg.SetText((unsigned char *)TxtDemo, sizeof(TxtDemo) - 1); delay(20); } else FastLED.show(); delay(20); }`

AaronLiddiment commented 2 years ago

Very strange! Have never seen anything like that. One thing is to change the: ScrollingMsg.Init(&leds, leds.Width(), ScrollingMsg.FontHeight() + 1, 0, 0); to ScrollingMsg.Init(&leds, leds.Width(), ScrollingMsg.FontHeight(), 0, 0); But don't think that would cause the problem, but there is no point in defining a text window bigger than the matrix. Are you certain the Matrix is just wired vertically? One test you could do is to cycle through all the LEDS with a delay just to confirm they are sequential and wired from bottom to top then back to bottom for the next vertical line: 3 7 11 2 6 10 1 5 9 0 4 8

void loop() { for (int x=0; x<MATRIX_WIDTH; x++) { for (int y=0; x<MATRIX_HEIGHT; y++) { leds(x, y) = CHSV(255, 255, 255); FastLED.show(); delay(500); leds(x, y) = CHSV(0, 0, 0); } } }

The above should go from bottom to top of each column starting at the left and going to the right if the matrix is wired and setup correctly.

DrRetro commented 2 years ago

Hey Aaron!

Thanks a lot for your help. With your loop test I was able to find the error relatively quickly: It is not only a Vertical Matrix, but also a ZIGZAG Vertical Matrix.... (It didn't say so anywhere... uff). And additionally I had to specify a minus height, so that this is now displayed correctly. (But only for the upper case letters, the lower case letters are rendered correctly, but seem to be in a wrong order). Anyway: Here you can see the result ;)

https://www.youtube.com/watch?v=_QVHphfuJzA

DrRetro commented 2 years ago

Funfact: I found my error with the lower keys - i forgot the `-Sign ;) Anyway, thanks and you can close this issue!

AaronLiddiment commented 2 years ago

Am really glad you got it sorted. You have highlighted the flexibility of my Matrix class.