/*
PAB49162 Wokwi projets
https://wokwi.com/makers/pab49162
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
*/
//
// Two Panel NeoMatrix Hello World - This sketch will run on
// an EPS32 but not an Aruduino Uno when using 2 panels. I
// believe the 2 panels require more RAM memory than in on
// an Arduino UNO board.
//
// If you change the code to use just a single panel (see line 19
// thru 28), this sketch will run on an Uno.
//
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#define PINA 12
#define PINB 23
// NeoMatrix declarations for 1 panel and 2 panel implementations
// Single panel matrix - uncomment for 1 panel implementation
Adafruit_NeoMatrix matrixA = Adafruit_NeoMatrix(8, 8, PINA,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE,
NEO_GRB + NEO_KHZ800);
Adafruit_NeoMatrix matrixB = Adafruit_NeoMatrix(8, 8, PINB,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE,
NEO_GRB + NEO_KHZ800);
// Two panel matrix - uncomment for 2 panel implementation
/*
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(8, 8, 2, 1, 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 int displayWidthA = matrixA.width();
const int displayWidthB = matrixB.width();
const char myMessageA[] = "Hook 'em Horns!";
const int myMessageCharacterCountA = (sizeof(myMessageA)/sizeof(myMessageA[0])) - 1;
const char myMessageB[] = "Merry Christmas";
const int myMessageCharacterCountB = (sizeof(myMessageB)/sizeof(myMessageB[0])) - 1;
const uint16_t red = matrixB.Color(255, 0, 0);
const uint16_t green = matrixB.Color(0, 255, 0);
const uint16_t blue = matrixB.Color(0, 0, 255);
const uint16_t yellow = matrixB.Color(255, 255, 0);
const uint16_t orange = matrixB.Color(255, 90, 0);
const uint16_t white = matrixB.Color(255, 255, 255);
const uint16_t maroon = matrixB.Color(190, 10, 10);
const uint16_t black = matrixB.Color(0, 0, 0);
const uint16_t rotatingColorsA[] = {orange, white};
const int rotatingColorsCountA = (sizeof(rotatingColorsA)/sizeof(rotatingColorsA[0]));
const uint16_t rotatingColorsB[] = {maroon, white};
const int rotatingColorsCountB = (sizeof(rotatingColorsB)/sizeof(rotatingColorsB[0]));
//
// Setup function
//
void setup() {
Serial.begin(115200);
Serial.print("myMessage has ");
Serial.print(myMessageCharacterCountA);
Serial.print(" characters and ");
Serial.print(rotatingColorsCountA);
Serial.print(" rotating colors. Matrix panel is ");
Serial.print(displayWidthA);
Serial.println(" pixels in width.");
Serial.begin(115200);
Serial.print("myMessage has ");
Serial.print(myMessageCharacterCountB);
Serial.print(" characters and ");
Serial.print(rotatingColorsCountB);
Serial.print(" rotating colors. Matrix panel is ");
Serial.print(displayWidthB);
Serial.println(" pixels in width.");
matrixA.begin();
matrixA.setTextWrap(false);
matrixA.setBrightness(255);
matrixA.setTextColor(rotatingColorsA[0]);
matrixB.begin();
matrixB.setTextWrap(false);
matrixB.setBrightness(255);
matrixB.setTextColor(rotatingColorsB[0]);
}
//
// Loop function
//
int colorIteratorA = 0;
int colorIteratorB = 0;
// Starting charPosition is the rightmost pixel on the display which is
// where the start of the first character is initially displayed.
int charPositionA = displayWidthA;
int charPositionB = displayWidthB;
// 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 restartPositionA = -((myMessageCharacterCountA) * 6);
int restartPositionB = -((myMessageCharacterCountB) * 6);
void loop() {
matrixA.fillScreen(black);
matrixA.setCursor(charPositionA, 0);
matrixA.print(myMessageA);
// 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 (--charPositionA <= restartPositionA) {
if (++colorIteratorA >= rotatingColorsCountA) colorIteratorA = 0;
matrixA.setTextColor(rotatingColorsA[colorIteratorA]);
charPositionA = displayWidthA;
}
/* Kenneth - I think this is left-over code. Should it have been deleted?
if (--charPositionA <= restartPositionB) {
if (++colorIterator >= rotatingColorsCountA) colorIterator = 0;
matrixA.setTextColor(rotatingColorsA[colorIterator]);
charPositionB = displayWidthB;
} */
/* matrixA.show();
delay(100); */
matrixB.fillScreen(black);
matrixB.setCursor(charPositionB, 0);
matrixB.print(myMessageB);
// 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 (--charPositionB <= restartPositionB) {
if (++colorIteratorB >= rotatingColorsCountB) colorIteratorB = 0;
matrixB.setTextColor(rotatingColorsB[colorIteratorB]);
charPositionB = displayWidthB;
}
matrixA.show();
matrixB.show();
delay(100);
}