/*
PAB49162 Wokwi projets
https://wokwi.com/makers/pab49162
Los3Urquidis’ Wokwi projects
https://wokwi.com/makers/los3urquidis
WLED multi-strip support
https://kno.wled.ge/features/multi-strip/
Multiple controller examples
https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples
Strip effects for NeoPixel and FastLED
https://www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/
RGB color code chart
https://www.rapidtables.com/web/color/RGB_Color.html
NeoMatrix setup guide
https://learn.adafruit.com/adafruit-neopixel-uberguide/neomatrix-library
Microphone INMP441 I2S Omnidirectional Module
https://techmaze.romman.store/product/99189039
ESP32-DevKitC Pin layout
https://docs.espressif.com/projects/esp-idf/en/v5.1/esp32/hw-reference/esp32/get-started-devkitc.html
FastLED pixel reference
https://github.com/FastLED/FastLED/wiki/Pixel-reference#colors
Pixel Art Converter
https://kno.wled.ge/features/pixel-art-converter/
*/
// -- Message Definition ------------------------------------------------------------
#define MESSAGE_A "Happy"
#define MESSAGE_A_SCROLL_ENABLED false
#define MESSAGE_A_NON_SCROLL_POSITION 6 // Pixels from left side starting with 0
#define MESSAGE_B "B-day"
#define MESSAGE_B_SCROLL_ENABLED false
#define MESSAGE_B_NON_SCROLL_POSITION 8 // Pixels from left side starting with 0
#define MESSAGE_C "Dora!"
#define MESSAGE_C_SCROLL_ENABLED false
#define MESSAGE_C_NON_SCROLL_POSITION 10 // Pixels from left side starting with 0
#define MESSAGE_D "From your friends at Mavericks Dancehall"
#define MESSAGE_D_SCROLL_ENABLED true
#define MESSAGE_D_NON_SCROLL_POSITION 6 // 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 26 //orange
#define PANEL_B_PIN 27 //blue
#define PANEL_C_PIN 14 //green
#define PANEL_D_PIN 12 //purple
Adafruit_NeoMatrix messagePanelA = Adafruit_NeoMatrix(44, 11, 1, 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, 1, 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, 1, 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, 1, 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 white = messagePanelA.Color(255, 255, 255);
const uint16_t red = messagePanelA.Color(255, 0, 0);
const uint16_t lime = messagePanelA.Color(0, 255, 0);
const uint16_t blue = messagePanelA.Color(0, 0, 255);
const uint16_t yellow = messagePanelA.Color(255, 255, 0);
const uint16_t aqua = messagePanelA.Color(0, 255, 255);
const uint16_t fuchsia = messagePanelA.Color(255, 0, 255);
const uint16_t silver = messagePanelA.Color(192, 192, 192);
const uint16_t gray = messagePanelA.Color(128, 128, 128);
const uint16_t maroon = messagePanelA.Color(128, 0, 0);
const uint16_t olive = messagePanelA.Color(128, 128, 0);
const uint16_t green = messagePanelA.Color(0, 128, 0);
const uint16_t purple = messagePanelA.Color(153, 51, 255);
const uint16_t teal = messagePanelA.Color(0, 128, 128);
const uint16_t navy = messagePanelA.Color(0, 0, 128);
const uint16_t smoke = messagePanelA.Color(245, 245, 245);
const uint16_t orange = messagePanelA.Color(255, 90, 0);
const uint16_t pink = messagePanelA.Color(255, 204, 229);
const uint16_t gainsboro = messagePanelA.Color(220, 220, 220);
const uint16_t DimGray = messagePanelA.Color(75, 75, 75);
const uint16_t chocolate = messagePanelA.Color(210, 105, 30);
const uint16_t SaddleBrown = messagePanelA.Color(139, 69, 19);
//
// Setup function
//
void setup() {
Serial.begin(115200);
Serial.println("setup function started.");
messagePanelA.begin();
messagePanelA.setTextWrap(false);
messagePanelA.setBrightness(64);
messagePanelA.setTextColor(maroon);
messagePanelB.begin();
messagePanelB.setTextWrap(false);
messagePanelB.setBrightness(64);
messagePanelB.setTextColor(DimGray);
messagePanelC.begin();
messagePanelC.setTextWrap(false);
messagePanelC.setBrightness(64);
messagePanelC.setTextColor(navy);
messagePanelD.begin();
messagePanelD.setTextWrap(false);
messagePanelD.setBrightness(64);
messagePanelD.setTextColor(SaddleBrown);
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.");
}