AaronLiddiment / LEDText

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

Unable to resize text to small matrix #22

Closed CobaltEcho closed 2 years ago

CobaltEcho commented 2 years ago

I have a small matrix that I'm trying to get basic text to scroll across, it's scrolling in the correct direction but the LED's are not correct. For Example, here I am trying to have the number "2" displayed.

What I am actually getting scrolling across my matrix is (with X = on/light): OOXXXXO OOOOOOO OOOOOOO OOOOOOO OOOXXOO

const uint8_t RobotronFontData[] = { 5, // Font Width 5, // Font Height

#include <FastLED.h>

#include <LEDMatrix.h>
#include <LEDText.h>
#include <FontRobotron.h>

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

#define LED_PIN        6
#define COLOR_ORDER    GRB
#define CHIPSET        WS2812B

#define MATRIX_WIDTH   7
#define MATRIX_HEIGHT  5
#define MATRIX_TYPE    HORIZONTAL_ZIGZAG_MATRIX

cLEDMatrix<MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE> leds;

cLEDText ScrollingMsg;
uint8_t Rate = 3;
const unsigned char TxtDemo[] = {EFFECT_SCROLL_LEFT "   2  "};

void setup()
{
  FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds[0], leds.Size());
  FastLED.setBrightness(64);
  FastLED.clear(true);
  delay(500);
  FastLED.show();

  ScrollingMsg.SetFont(RobotronFontData);
  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);
  ScrollingMsg.SetFrameRate(Rate);
}

void loop()
{
  if (ScrollingMsg.UpdateText() == -1)
    ScrollingMsg.SetText((unsigned char *)TxtDemo, sizeof(TxtDemo) - 1);
  else
    FastLED.show();
  delay(10);
}
AaronLiddiment commented 2 years ago

Hi, For a start the Robotron font is 7 pixels wide and 7 high so it won't fit on a 5x7 matrix and be fully visible. The other is why do you have this line: const uint8_t RobotronFontData[] = { 5, // Font Width 5, // Font Height You cannot simply just override the font width and height without changing the font data to match it. You current code will not be looking in the right place for the pixels that make up the character '2'. It will be using the overridden height of 5 bytes per character rather then 7 which is how the data has been defined. Regards Aaron