//
// ESP32 64x8 64x8 Static & Scrolling Four Messages - this script uses 4 sets of
// two 32x8 panels to create a four 64x8 message boards.
//
// -- Message Definition ------------------------------------------------------------
#define MESSAGE_A "TITANIUM"
#define MESSAGE_A_SCROLL_ENABLED true
#define MESSAGE_A_NON_SCROLL_POSITION 21 // Pixels from left side starting with 0
#define MESSAGE_B "ELECTRICAL"
#define MESSAGE_B_SCROLL_ENABLED true
#define MESSAGE_B_NON_SCROLL_POSITION 15 // Pixels from left side starting with 0
#define MESSAGE_C "SOLUTIONS"
#define MESSAGE_C_SCROLL_ENABLED true
#define MESSAGE_C_NON_SCROLL_POSITION 18 // Pixels from left side starting with 0
#define MESSAGE_D "(512) 560-9551"
#define MESSAGE_D_SCROLL_ENABLED false
#define MESSAGE_D_NON_SCROLL_POSITION 2 // Pixels from left side starting with 0
#define SCROLL_DELAY 0
#define VERTICAL_CHAR_POSITION 2 // Pixels from top starting with 0
// -- End of Message Defintion ------------------------------------------------------
// Include libraries
#include <Adafruit_NeoPixel.h>
#include <Adafruit_NeoMatrix.h>
// Define the four message panels
#define PANEL_A_PIN 15
#define PANEL_B_PIN 2
#define PANEL_C_PIN 0
#define PANEL_D_PIN 4
Adafruit_NeoMatrix messagePanelA = Adafruit_NeoMatrix(44, 11, 2, 1, PANEL_A_PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE +
NEO_TILE_TOP + NEO_TILE_LEFT + NEO_TILE_ROWS + NEO_TILE_PROGRESSIVE,
NEO_GRB + NEO_KHZ800);
Adafruit_NeoMatrix messagePanelB = Adafruit_NeoMatrix(44, 11, 2, 1, PANEL_B_PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE +
NEO_TILE_TOP + NEO_TILE_LEFT + NEO_TILE_ROWS + NEO_TILE_PROGRESSIVE,
NEO_GRB + NEO_KHZ800);
Adafruit_NeoMatrix messagePanelC = Adafruit_NeoMatrix(44, 11, 2, 1, PANEL_C_PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE +
NEO_TILE_TOP + NEO_TILE_LEFT + NEO_TILE_ROWS + NEO_TILE_PROGRESSIVE,
NEO_GRB + NEO_KHZ800);
Adafruit_NeoMatrix messagePanelD = Adafruit_NeoMatrix(44, 11, 2, 1, PANEL_D_PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE +
NEO_TILE_TOP + NEO_TILE_LEFT + NEO_TILE_ROWS + NEO_TILE_PROGRESSIVE,
NEO_GRB + NEO_KHZ800);
// Other declarations
const char messageA[] = MESSAGE_A;
const char messageB[] = MESSAGE_B;
const char messageC[] = MESSAGE_C;
const char messageD[] = MESSAGE_D;
const int messageACharCount = (sizeof(messageA)/sizeof(messageA[0])) - 1;
const int messageBCharCount = (sizeof(messageB)/sizeof(messageB[0])) - 1;
const int messageCCharCount = (sizeof(messageC)/sizeof(messageC[0])) - 1;
const int messageDCharCount = (sizeof(messageD)/sizeof(messageD[0])) - 1;
const int displayWidth = messagePanelA.width(); // Assumes all four panels are the same width
const uint16_t black = messagePanelA.Color( 0, 0, 0);
const uint16_t red = messagePanelA.Color(255, 0, 0);
const uint16_t white = messagePanelA.Color(255, 255, 255);
const uint16_t blue = messagePanelA.Color(0, 0, 255);
const uint16_t orange = messagePanelA.Color(255, 90, 0);
//
// Setup function
//
void setup() {
Serial.begin(115200);
Serial.println("setup function started.");
messagePanelA.begin();
messagePanelA.setTextWrap(false);
messagePanelA.setBrightness(255);
messagePanelA.setTextColor(red);
messagePanelB.begin();
messagePanelB.setTextWrap(false);
messagePanelB.setBrightness(255);
messagePanelB.setTextColor(white);
messagePanelC.begin();
messagePanelC.setTextWrap(false);
messagePanelC.setBrightness(255);
messagePanelC.setTextColor(blue);
messagePanelD.begin();
messagePanelD.setTextWrap(false);
messagePanelD.setBrightness(255);
messagePanelD.setTextColor(orange);
Serial.println("setup function complete");
}
//
// Loop function
//
// Starting charPosition is the rightmost pixel on the display which is
// where the start of the first character is initially displayed.
int messagePanelACharPosition = messagePanelA.width();
int messagePanelBCharPosition = messagePanelA.width();
int messagePanelCCharPosition = messagePanelA.width();
int messagePanelDCharPosition = messagePanelA.width();
// restartPosition is the "virtual" position of the first character when
// the last character scrolls of the leftmost pixel of the display. This
// position assumes each character is 6 pixels wide.
int messageARestartPosition = -((messageACharCount) * 6);
int messageBRestartPosition = -((messageBCharCount) * 6);
int messageCRestartPosition = -((messageCCharCount) * 6);
int messageDRestartPosition = -((messageDCharCount) * 6);
long iterationCount = 0;
void loop() {
Serial.print("loop function started. iterationCount = ");
Serial.println(iterationCount++);
//
// Panel A processing
//
messagePanelA.fillScreen(black);
if (MESSAGE_A_SCROLL_ENABLED) {
messagePanelA.setCursor(messagePanelACharPosition, VERTICAL_CHAR_POSITION);
} else {
messagePanelA.setCursor(MESSAGE_A_NON_SCROLL_POSITION, VERTICAL_CHAR_POSITION);
}
messagePanelA.print(messageA);
// If last character has scrolled off of the display, change the text to
// the next color and reset the cursor position to the rightmost pixel
if (--messagePanelACharPosition <= messageARestartPosition) {
messagePanelACharPosition = messagePanelA.width();
}
//
// Panel B processing
//
messagePanelB.fillScreen(black);
if (MESSAGE_B_SCROLL_ENABLED) {
messagePanelB.setCursor(messagePanelBCharPosition, VERTICAL_CHAR_POSITION);
} else {
messagePanelB.setCursor(MESSAGE_B_NON_SCROLL_POSITION, VERTICAL_CHAR_POSITION);
}
messagePanelB.print(messageB);
// If last character has scrolled off of the display, change the text to
// the next color and reset the cursor position to the rightmost pixel
if (--messagePanelBCharPosition <= messageBRestartPosition) {
messagePanelBCharPosition = messagePanelB.width();
}
//
// Panel C processing
//
messagePanelC.fillScreen(black);
if (MESSAGE_C_SCROLL_ENABLED) {
messagePanelC.setCursor(messagePanelCCharPosition, VERTICAL_CHAR_POSITION);
} else {
messagePanelC.setCursor(MESSAGE_C_NON_SCROLL_POSITION, VERTICAL_CHAR_POSITION);
}
messagePanelC.print(messageC);
// If last character has scrolled off of the display, change the text to
// the next color and reset the cursor position to the rightmost pixel
if (--messagePanelCCharPosition <= messageCRestartPosition) {
messagePanelCCharPosition = messagePanelC.width();
}
//
// Panel D processing
//
messagePanelD.fillScreen(black);
if (MESSAGE_D_SCROLL_ENABLED) {
messagePanelD.setCursor(messagePanelDCharPosition, VERTICAL_CHAR_POSITION);
} else {
messagePanelD.setCursor(MESSAGE_D_NON_SCROLL_POSITION, VERTICAL_CHAR_POSITION);
}
messagePanelD.print(messageD);
// If last character has scrolled off of the display, change the text to
// the next color and reset the cursor position to the rightmost pixel
if (--messagePanelDCharPosition <= messageDRestartPosition) {
messagePanelDCharPosition = messagePanelD.width();
}
// Update all four panels
messagePanelA.show();
messagePanelB.show();
messagePanelC.show();
messagePanelD.show();
// Delay
delay(SCROLL_DELAY);
Serial.println("loop function completed.");
}
X Coordinate -->
Y Coordinate -->