#include <Adafruit_NeoMatrix.h>

#define LED_PIN 6 // Data pin
#define DISPLAY_WIDTH 32
#define DISPLAY_HEIGHT 8
#define BRIGHTNESS 255
byte delayMS = 20;

Adafruit_NeoMatrix display = Adafruit_NeoMatrix(
  DISPLAY_WIDTH, DISPLAY_HEIGHT, LED_PIN,
  NEO_MATRIX_TOP + // NEO_MATRIX_BOTTOM
  NEO_MATRIX_LEFT + // NEO_MATRIX_RIGHT
  NEO_MATRIX_ROWS + // NEO_MATRIX_COLUMNS
  NEO_MATRIX_PROGRESSIVE, // NEO_MATRIX_ZIGZAG,
  NEO_GRB + // NEO_RGB
  NEO_KHZ800 // NEO_KHZ400
);

int scroll = display.width();
char sometext[] = "Never gonna give you up.";
int scrollwidth = sizeof(sometext) * 6; // each character is 5 pixels plus one kern pixel

void setup() {
  Serial.begin(115200); 
  display.begin(); // Initialize the display object
  display.setTextWrap(false);
  display.setBrightness(255);
  display.setTextColor(display.Color(255, 255, 255)); // Set text color (white)
}

void loop() {
  scrollText();
}

void scrollText() {
  // Serial.println(scroll);
  display.fillScreen(0);    //Turn off all the LEDs
  display.setCursor(scroll, 0); // start displaying Neopixels at the right edge
  display.print(sometext); // store the Neopixel buffer

  if ( --scroll < -scrollwidth ) { // width of sizeof(text) scrolls from 32 to -150
    scroll = display.width(); // re-start at the right
  }
  display.show(); // display the Neopixel buffer
  delay(delayMS);
}