Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Adafruit_32x8matrix
Fork of Adafruit_LEDBackpack_16x8_App by
Revision 1:dd1d1b64b9a5, committed 2016-12-21
- Comitter:
- maclobdell
- Date:
- Wed Dec 21 18:25:03 2016 +0000
- Parent:
- 0:2eec8a9428ea
- Child:
- 2:ffe5cf2557e3
- Commit message:
- initial commit
Changed in this revision
| Adafruit_LEDBackpack.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Adafruit_LEDBackpack.lib Thu Dec 15 17:43:32 2016 +0000 +++ b/Adafruit_LEDBackpack.lib Wed Dec 21 18:25:03 2016 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/maclobdell/code/Adafruit_LEDBackpack/#529bad55777e +https://developer.mbed.org/users/maclobdell/code/Adafruit_LEDBackpack/#b0ac557b5f0c
--- 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
+
+
+}
