Example application for two 16x8 Adafruit LED Backpacks to make a 32 x 8 matrix.
Dependencies: Adafruit_32x8matrix
Fork of Adafruit_LEDBackpack_16x8_App by
This project uses two 16x8 1.2" LED Matrix + Backpacks stuck together to make a 32x8 double-length matrix.
Diff: main.cpp
- Revision:
- 1:dd1d1b64b9a5
- Parent:
- 0:2eec8a9428ea
- Child:
- 2:ffe5cf2557e3
--- a/main.cpp Thu Dec 15 17:43:32 2016 +0000 +++ b/main.cpp Wed Dec 21 18:25:03 2016 +0000 @@ -3,19 +3,94 @@ #include "Adafruit_GFX.h" I2C i2c(D14, D15); - + +//mpl - something with stdio screwing things up. need to define serial port to use for debug +Serial pc (USBTX,USBRX); + Adafruit_16x8matrix matrix = Adafruit_16x8matrix(&i2c); - +Adafruit_16x8matrix matrix2 = Adafruit_16x8matrix(&i2c); + +void scrollText(char * buffer, uint8_t buf_len); + int main() { - matrix.begin(0x70); - while(1) { - matrix.clear(); + +/* matrix[0].begin(0x70); + //while(1) +// { + matrix[0].clear(); for (int i = 0; i < 16; i++) { - for (int j = 0; j < 16; j++) { + for (int j = 0; j < 8; j++) { matrix.drawPixel(i, j, LED_ON); matrix.writeDisplay(); // write the changes we just made to the display - Thread::wait(100); + Thread::wait(10); + } + } + + matrix2.begin(0x71); + matrix2.clear(); + + for (int i = 0; i < 16; i++) { + for (int j = 0; j < 8; j++) { + matrix2.drawPixel(i, j, LED_ON); + matrix2.writeDisplay(); // write the changes we just made to the display + Thread::wait(10); } } + +*/ + matrix2.begin(0x71); + matrix2.clear(); + matrix2.writeDisplay(); +// matrix2.writeChar('A'); +// matrix2.writeDisplay(); +// Thread::wait(10); + + matrix.begin(0x70); + matrix.clear(); + matrix.writeDisplay(); +// matrix.writeChar('A'); +// matrix.writeChar('B'); +// matrix.writeChar('C'); +// matrix.writeDisplay(); + + char buffer [50]; + sprintf (buffer, "Hello\0"); + scrollText(buffer,strlen(buffer)); + +// } +} + +void scrollText(char * buffer, uint8_t buf_len) +{ + uint8_t x_pos; + uint8_t m; + char c; + + //pc.printf("buffer = %s, len = %d\r\n", buffer, buf_len); + + //Need to start at the end and draw backwards, each time scrolling one pixel to the right + // then, stop when get to first character. + //find example + + /* code inspired by LOLShield library */ + int xoff=31;/* set offset to the right end of the screen*/ + for(int i=0; i<buf_len*5 +52; i++){ /*scrolling loop*/ + for(int j=0; j<buf_len; j++){ /*loop over all of the chars in the text*/ + if(xoff + j*6 <32) + { + matrix.drawChar(xoff + j*6, 0, buffer[j], 1, 0, 1); + matrix.writeDisplay(); + }else + { + matrix2.drawChar(xoff + j*6-32, 0, buffer[j], 1, 0, 1); + matrix2.writeDisplay(); + } + } + xoff--; /* decrement x offset*/ + Thread::wait(70); + matrix.clear(); + matrix2.clear(); } -} \ No newline at end of file + + +}