Skip to content

Instantly share code, notes, and snippets.

@anecdata
Last active March 20, 2021 21:54
Show Gist options
  • Save anecdata/5a9ce97e8938ed4ca91c19d035f1bd70 to your computer and use it in GitHub Desktop.
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
// 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