Last active
March 20, 2021 21:54
-
-
Save anecdata/5a9ce97e8938ed4ca91c19d035f1bd70 to your computer and use it in GitHub Desktop.
Arduino function to scroll a String on an Adafruit 8x16 LED Matrix FeatherWing
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
// 8x16 LED Matrix I2C FeatherWing | |
#define MATRIX_ADDR 0x70 // default; 0x71-0x77 with jumper changes | |
Adafruit_8x16minimatrix matrixDisplay = Adafruit_8x16minimatrix(); | |
setup() { | |
matrixDisplay.begin(MATRIX_ADDR); // void | |
} | |
void scrollMatrixString(String tString, int scrollDelay, int bright, int rot, int tSize, boolean tWrap, int tColor) { | |
int tLength = tString.length(); | |
matrixDisplay.setBrightness(bright); | |
matrixDisplay.setRotation(rot); | |
matrixDisplay.setTextSize(tSize); | |
matrixDisplay.setTextWrap(tWrap); | |
matrixDisplay.setTextColor(tColor); | |
// TextSize=1 characters are 6 pixels wide (matrix landsacpe) | |
// TextSize=2 characters are 12 pixels wide (matrix portrait) | |
for ( int x = matrixDisplay.width(); x > (-6 * tSize * tLength); x-- ) { | |
matrixDisplay.clear(); | |
matrixDisplay.setCursor(x, 0); | |
matrixDisplay.print(tString); | |
matrixDisplay.writeDisplay(); | |
delay(scrollDelay); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment