Last active
August 9, 2024 00:49
-
-
Save buildcircuit/404b309368c523003b16493435997869 to your computer and use it in GitHub Desktop.
Display Test with Modified Adafruit Library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This code works with this display only: https://buildcircuits.com/products/led-display-matrix-module-320x160mm-32x16-pixels-3in1-smd-1-4-scan-rgb-p10-full-color | |
// library link: https://drive.google.com/file/d/1BqVCiwq8BrZRucozg-tdPiYgmmH_c87f/view | |
// Delete the original Adafruit library | |
#include <RGBmatrixPanel.h> | |
// Most of the signal pins are configurable, but the CLK pin has some | |
// special constraints. On 8-bit AVR boards it must be on PORTB... | |
// Pin 8 works on the Arduino Uno & compatibles (e.g. Adafruit Metro), | |
// Pin 11 works on the Arduino Mega. On 32-bit SAMD boards it must be | |
// on the same PORT as the RGB data pins (D2-D7)... | |
// Pin 8 works on the Adafruit Metro M0 or Arduino Zero, | |
// Pin A4 works on the Adafruit Metro M4 (if using the Adafruit RGB | |
// Matrix Shield, cut trace between CLK pads and run a wire to A4). | |
#define CLK 8 // USE THIS ON ARDUINO UNO, A | |
//#define CLK A4 // USE THIS ON METRO M4 (not M0) | |
//#define CLK 11 // USE THIS ON ARDUINO MEGA | |
#define OE 9 | |
#define LAT 10 | |
#define A A0 | |
#define B A1 | |
#define C A2 | |
// This works with modified Adafruit library | |
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false,1); | |
void setup() { | |
matrix.begin(); | |
// draw a pixel in white | |
matrix.drawPixel(0, 0, matrix.Color333(7, 7, 7)); | |
delay(500); | |
// fix the screen with green | |
matrix.fillRect(0, 0, 32, 16, matrix.Color333(0, 7, 0)); | |
delay(500); | |
// draw a box in yellow | |
matrix.drawRect(0, 0, 32, 16, matrix.Color333(7, 7, 0)); | |
delay(500); | |
// draw an 'X' in red | |
matrix.drawLine(0, 0, 31, 15, matrix.Color333(7, 0, 0)); | |
matrix.drawLine(31, 0, 0, 15, matrix.Color333(7, 0, 0)); | |
delay(500); | |
// draw a blue circle | |
matrix.drawCircle(7, 7, 7, matrix.Color333(0, 0, 7)); | |
delay(500); | |
// fill a violet circle | |
matrix.fillCircle(23, 7, 7, matrix.Color333(7, 0, 7)); | |
delay(500); | |
// fill the screen with black | |
matrix.fillScreen(matrix.Color333(0, 0, 0)); | |
// draw some text! | |
matrix.setCursor(1, 0); // start at top left, with one pixel of spacing | |
matrix.setTextSize(1); // size 1 == 8 pixels high | |
// print each letter with a rainbow color | |
matrix.setTextColor(matrix.Color333(7,0,0)); | |
matrix.print('1'); | |
matrix.setTextColor(matrix.Color333(7,4,0)); | |
matrix.print('6'); | |
matrix.setTextColor(matrix.Color333(7,7,0)); | |
matrix.print('x'); | |
matrix.setTextColor(matrix.Color333(4,7,0)); | |
matrix.print('3'); | |
matrix.setTextColor(matrix.Color333(0,7,0)); | |
matrix.print('2'); | |
matrix.setCursor(1, 9); // next line | |
matrix.setTextColor(matrix.Color333(0,7,7)); | |
matrix.print('*'); | |
matrix.setTextColor(matrix.Color333(0,4,7)); | |
matrix.print('R'); | |
matrix.setTextColor(matrix.Color333(0,0,7)); | |
matrix.print('G'); | |
matrix.setTextColor(matrix.Color333(4,0,7)); | |
matrix.print('B'); | |
matrix.setTextColor(matrix.Color333(7,0,4)); | |
matrix.print('*'); | |
// whew! | |
} | |
void loop() { | |
// Do nothing -- image doesn't change | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment