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_LEDBackpack
main.cpp
00001 #include "mbed.h" 00002 #include "Adafruit_LEDBackpack.h" 00003 #include "Adafruit_GFX.h" 00004 00005 I2C i2c(D14, D15); 00006 00007 //mpl - something with stdio screwing things up. need to define serial port to use for debug 00008 Serial pc (USBTX,USBRX); 00009 00010 Adafruit_16x8matrix matrix = Adafruit_16x8matrix(&i2c); 00011 Adafruit_16x8matrix matrix2 = Adafruit_16x8matrix(&i2c); 00012 00013 void scrollText(char * buffer, uint8_t buf_len); 00014 00015 int main() { 00016 00017 matrix2.begin(0x71); 00018 matrix2.clear(); 00019 matrix2.writeDisplay(); 00020 00021 matrix.begin(0x70); 00022 matrix.clear(); 00023 matrix.writeDisplay(); 00024 00025 char buffer [50]; 00026 sprintf (buffer, "Hello\0"); 00027 scrollText(buffer,strlen(buffer)); 00028 00029 } 00030 00031 void scrollText(char * buffer, uint8_t buf_len) 00032 { 00033 00034 //pc.printf("buffer = %s, len = %d\r\n", buffer, buf_len); 00035 00036 /* code inspired by LOLShield library */ 00037 int xoff=31;/* set offset to the right end of the screen - must be signed*/ 00038 for(int i=0; i< (31 + buf_len*6 +10); i++){ /*scrolling loop*/ 00039 for(int j=0; j<buf_len; j++){ /*loop over all of the chars in the text*/ 00040 if(xoff > 15){ 00041 matrix2.drawChar(xoff + j*6 - 16, 0, buffer[j], 1, 0, 1); 00042 matrix2.writeDisplay(); 00043 }else 00044 { 00045 matrix.drawChar(xoff + j*6, 0, buffer[j], 1, 0, 1); 00046 matrix.writeDisplay(); 00047 matrix2.drawChar(xoff + j*6 - 16, 0, buffer[j], 1, 0, 1); 00048 matrix2.writeDisplay(); 00049 } 00050 } 00051 xoff--; /* decrement x offset*/ 00052 Thread::wait(70); 00053 matrix.clear(); 00054 matrix2.clear(); 00055 } 00056 }
Generated on Tue Jul 19 2022 04:55:36 by
1.7.2