Skip to content

Instantly share code, notes, and snippets.

@maxpromer
Created February 17, 2025 16:59
Show Gist options
  • Save maxpromer/c10d766468dff2b4a253630fb86a52ec to your computer and use it in GitHub Desktop.
Save maxpromer/c10d766468dff2b4a253630fb86a52ec to your computer and use it in GitHub Desktop.
P4 P5 RGB Dot Matrix 64x32 Test Code
#include <Arduino.h>
#include <Adafruit_GFX.h>
#include <Adafruit_Protomatter.h>
// Matrix Pin Configs
uint8_t rgbPins[] = { 42, 41, 40, 39, 38, 37 };
uint8_t addrPins[] = { 36, 35, 46, 48 };
uint8_t clockPin = 47;
uint8_t latchPin = 21;
uint8_t oePin = 2;
Adafruit_Protomatter matrix(
64, // Width of matrix (or matrix chain) in pixels
4, // Bit depth, 1-6
1, rgbPins, // # of matrix chains, array of 6 RGB pins for each
4, addrPins, // # of address pins (height is inferred), array of pins
clockPin, latchPin, oePin, // Other matrix control pins
false); // No double-buffering here (see "doublebuffer" example)
uint32_t Wheel(byte WheelPos);
void setup() {
Serial.begin(115200);
ProtomatterStatus status = matrix.begin();
Serial.print("Protomatter begin() status: ");
Serial.println((int)status);
if (status != PROTOMATTER_OK) {
// DO NOT CONTINUE if matrix setup encountered an error.
for (;;)
;
}
// fill the screen with 'black'
matrix.fillScreen(matrix.color565(0, 0, 0));
{
matrix.setCursor(28 / 2, 2);
const char* str = "P5 RGB";
for (uint8_t i = 0; i < strlen(str); i++) {
matrix.setTextColor(Wheel(i * 20));
matrix.print(str[i]);
}
matrix.println();
}
{
matrix.setCursor(8, 8 + 2 + 2);
const char* str = "64x32 Px";
for (uint8_t i = 0; i < strlen(str); i++) {
matrix.setTextColor(Wheel(200 + (i * 20)));
matrix.print(str[i]);
}
matrix.println();
}
{
matrix.setCursor(2, 8 + 8 + 2 + 2 + 2);
matrix.setTextColor(matrix.color565(0, 120, 255));
matrix.print("Ar");
matrix.setTextColor(matrix.color565(46, 134, 193));
matrix.print("tron");
matrix.setTextColor(matrix.color565(0, 255, 0));
matrix.print("Shop");
matrix.println();
}
matrix.show();
}
void loop() {
// do nothing
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if (WheelPos < 85) {
return matrix.color565(255 - WheelPos * 3, 0, WheelPos * 3);
}
if (WheelPos < 170) {
WheelPos -= 85;
return matrix.color565(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return matrix.color565(WheelPos * 3, 255 - WheelPos * 3, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment