#include <Adafruit_GFX.h>
#include <FastLED.h>
#include <FastLED_NeoMatrix.h>
#define SCROLL_OFFSET 8
String scrollText = "1234567890. HELLO. WORLD! THIS IS SCROLLING TEXT ANIMATION TEST";
CRGB Leds[256];
FastLED_NeoMatrix* matrix = new FastLED_NeoMatrix(Leds, 32, 8, NEO_MATRIX_TOP + NEO_MATRIX_RIGHT + NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE);
#include "MyFont.h"
void setup() {
FastLED.addLeds<WS2812B, 2, GRB>(Leds, 256);
matrix->begin();
matrix->clear();
matrix->setFont(&myfonts);
matrix->setTextColor(matrix->Color(0, 255, 255));
matrix->setBrightness(255);
matrix->setCursor(1, 1);
matrix->clear();
}
void loop() {
drawScrollingText();
//matrix->print("VWXYZ!.");
matrix->show();
delay(200); // Adjust the scrolling speed
matrix->clear();
}
void drawScrollingText() {
static int offset = 40;
int16_t textWidth = scrollText.length() * 5;
int16_t x = offset;
// Only print the text when it reaches the 9th pixel
if (x - SCROLL_OFFSET > 8) {
matrix->setTextWrap(false);
matrix->setCursor(x - SCROLL_OFFSET, 1); // Adjust the starting point
matrix->print(scrollText);
}
offset--;
if (offset <= -textWidth + 40) {
offset = 40;
}
}