Skip to content

Instantly share code, notes, and snippets.

@bboyho
Last active June 27, 2019 17:57
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save bboyho/fb709b9062368ce7421a42fb681df50b to your computer and use it in GitHub Desktop.
Save bboyho/fb709b9062368ce7421a42fb681df50b to your computer and use it in GitHub Desktop.
SparkFun Product Showcase Demo for 32x64 RGB LED Panel => https://youtu.be/uWds5Q4xcN0
// modified: May 10, 2018
//
// testshapes demo for RGBmatrixPanel library.
// Demonstrates the drawing abilities of the RGBmatrixPanel library.
// For 32x64 RGB LED matrix.
// NOTE THIS CAN ONLY BE USED ON A MEGA! NOT ENOUGH RAM ON UNO!
#include <Adafruit_GFX.h> // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#define CLK 11
#define LAT 10
#define OE 9
#define A A0
#define B A1
#define C A2
#define D A3
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false, 64);
void setup() {
matrix.begin();
// draw a pixel in solid white
matrix.drawPixel(0, 0, matrix.Color333(7, 7, 7));
delay(500);
// fix the screen with green
matrix.fillRect(0, 0, matrix.width(), matrix.height(), matrix.Color333(0, 7, 0));
delay(500);
// draw a box in yellow
matrix.drawRect(0, 0, matrix.width(), matrix.height(), matrix.Color333(7, 7, 0));
delay(500);
// draw an 'X' in red
matrix.drawLine(0, 0, matrix.width() - 1, matrix.height() - 1, matrix.Color333(7, 0, 0));
matrix.drawLine(matrix.width() - 1, 0, 0, matrix.height() - 1, matrix.Color333(7, 0, 0));
delay(500);
// draw a blue circle
matrix.drawCircle(10, 10, 10, matrix.Color333(0, 0, 7));
delay(500);
// fill a violet circle
matrix.fillCircle(40, 21, 10, matrix.Color333(7, 0, 7));
delay(500);
// fill the screen with 'black'
matrix.fillScreen(matrix.Color333(0, 0, 0));
// draw some text!
matrix.setTextSize(1); // size 1 == 8 pixels high
matrix.setTextWrap(false); // Don't wrap at end of line - will do ourselves
matrix.setCursor(8, 0); // start at top left, with 8 pixel of spacing
uint8_t w = 0;
char *str = "SparkFun";
for (w = 0; w < 8; w++) {
matrix.setTextColor(Wheel(w));
matrix.print(str[w]);
}
matrix.setCursor(2, 8); // next line
matrix.print(' ');
matrix.print(' ');
matrix.setTextColor(matrix.Color333(7, 0, 7));
matrix.print('H');
matrix.setTextColor(matrix.Color333(6, 0, 6));
matrix.print('I');
matrix.setTextColor(matrix.Color333(4, 0, 0));
matrix.print(' ');
matrix.setTextColor(matrix.Color333(6, 0, 5));
matrix.print('M');
matrix.setTextColor(matrix.Color333(5, 0, 5));
matrix.print('O');
//matrix.setCursor(34, 24);
matrix.setTextColor(matrix.Color333(4, 0, 4));
matrix.print("M");
matrix.setTextColor(matrix.Color333(4, 4, 4));
matrix.print('!');
matrix.println();
matrix.setTextColor(matrix.Color333(7, 0, 0));
matrix.print('L');
matrix.setTextColor(matrix.Color333(7, 4, 0));
matrix.print('E');
matrix.setTextColor(matrix.Color333(7, 7, 0));
matrix.print('D');
matrix.setTextColor(matrix.Color333(4, 7, 0));
matrix.print(' ');
matrix.setTextColor(matrix.Color333(0, 7, 0));
matrix.print('M');
//matrix.setCursor(34, 24);
matrix.setTextColor(matrix.Color333(0, 7, 7));
matrix.print("A");
matrix.setTextColor(matrix.Color333(0, 4, 7));
matrix.print('T');
matrix.setTextColor(matrix.Color333(0, 0, 7));
matrix.print('R');
matrix.setTextColor(matrix.Color333(4, 0, 7));
matrix.print("I");
matrix.setTextColor(matrix.Color333(7, 0, 4));
matrix.println("X");
// print each letter with a rainbow color
matrix.setTextColor(matrix.Color333(7, 7, 7));
matrix.print('3');
matrix.setTextColor(matrix.Color333(7, 7, 7));
matrix.print('2');
matrix.setTextColor(matrix.Color333(7, 7, 7));
matrix.print('x');
matrix.setTextColor(matrix.Color333(7, 7, 7));
matrix.print('6');
matrix.setTextColor(matrix.Color333(7, 7, 7));
matrix.print('4');
matrix.setCursor(34, 24);
matrix.setTextColor(matrix.Color333(0, 7, 7));
matrix.print("*");
matrix.setTextColor(matrix.Color333(7, 0, 0));
matrix.print('R');
matrix.setTextColor(matrix.Color333(0, 7, 0));
matrix.print('G');
matrix.setTextColor(matrix.Color333(0, 0, 7));
matrix.print("B");
matrix.setTextColor(matrix.Color333(0, 7, 7));
matrix.println("*");
// whew!
}
void loop() {
// do nothing
}
// Input a value 0 to 24 to get a color value.
// The colours are a transition r - g - b - back to r.
uint16_t Wheel(byte WheelPos) {
if (WheelPos < 8) {
return matrix.Color333(7 - WheelPos, WheelPos, 0);
} else if (WheelPos < 16) {
WheelPos -= 8;
return matrix.Color333(0, 7 - WheelPos, WheelPos);
} else {
WheelPos -= 16;
return matrix.Color333(0, WheelPos, 7 - WheelPos);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment