AaronLiddiment / LEDText

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

Static text - no scroll #7

Closed benlooi closed 7 years ago

benlooi commented 7 years ago

Hi, This isn't really an issue, but just contributing to what I found out after many trial and errors.

To display static text, the wiki says to use SetText() and UpdateText() at the same time. Didn't work. So I figured, if you want the text to stay put (no scroll), it has to have the same parameters for every cycle in the loop. Which means, you have to Init() every cycle. That was the AHA moment, so this works: Example ` //define your stuff here void setup () { // setup stuff here } void loop() { ScrollingMsg.Init(&leds, leds.Width(), ScrollingMsg.FontHeight(), X_pos, Y_pos);

if (ScrollingMsg.UpdateText()== -1) { ScrollingMsg.SetText((unsigned char*)Message, sizeof(Message)-1); } else { FastLED.show();

}; }`

So what this does is every time the loop runs, the X and Y pos is set back to the same values instead of being changed by the scrolling functions. You can set the font and other stuff in the setup () part, just reset the Init() in the loop.

Ben

RecklessPotcover commented 2 years ago

Hi there,

I know it has been a long time, but just in case if someone's still using this library out there.

I have to point out above is not a proper practice and it will cause problems.

As for my case, I used benlooi's method. Then it cause a problem where the text will only be white but not the colour set by SetTextColrOptions().

I found a better practice to display static text as the author mentioned in Wiki, Section 6. Hints:

"To just keep rendering static text, use SetText() and UpdateText() at the same time."

So the idea is basically updating but not initialising the test at the initial position for every loop. And it won't cause any issue (at least the colour issue I've met).

Example:

void setup(){
  // Everything as shown in all the author's examples
}

void loop(){
  // Instead of using "if", just let them run in sequence
  ScrollingMsg.UpdateText();
  ScrollingMsg.SetText(displayText, sizeof(displayText) - 1);
  FastLED.show();
}