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
Diff: main.cpp
- Revision:
- 5:f2820d1efc08
- Parent:
- 4:8641e4da6744
diff -r 8641e4da6744 -r f2820d1efc08 main.cpp
--- a/main.cpp Sat Apr 08 02:57:54 2017 +0000
+++ b/main.cpp Mon Apr 10 14:43:42 2017 +0000
@@ -18,6 +18,8 @@
Adafruit_16x8matrix matrix2 = Adafruit_16x8matrix(&i2c);
void scrollText(char * buffer, uint8_t buf_len, uint8_t speed);
+void showText(char * buffer, uint8_t buf_len, uint8_t duration);
+
void myidlethread(void);
int main() {
@@ -36,11 +38,18 @@
matrix.writeDisplay();
char buffer [50];
+
+ sprintf(buffer, "This\0");
+ showText(buffer,strlen(buffer), 1);
+ sprintf(buffer, "is\0");
+ showText(buffer,strlen(buffer), 1);
+ sprintf(buffer, "the\0");
+ showText(buffer,strlen(buffer), 1);
sprintf (buffer, "IoT Lab\0");
-
+
while(1)
{
- scrollText(buffer,strlen(buffer), 1000);
+ scrollText(buffer,strlen(buffer), 100);
Thread::attach_idle_hook (myidlethread);
@@ -67,18 +76,33 @@
for(int j=0; j<buf_len; j++){ /*loop over all of the chars in the text*/
if(xoff > 15){
matrix2.drawChar(xoff + j*6 - 16, 0, buffer[j], 1, 0, 1);
- matrix2.writeDisplay();
+
}else
{
matrix.drawChar(xoff + j*6, 0, buffer[j], 1, 0, 1);
- matrix.writeDisplay();
matrix2.drawChar(xoff + j*6 - 16, 0, buffer[j], 1, 0, 1);
- matrix2.writeDisplay();
}
}
xoff--; /* decrement x offset*/
- Thread::wait(1000/speed);
+ matrix.writeDisplay();
+ matrix2.writeDisplay();
+ Thread::wait(2000/speed);
matrix.clear();
matrix2.clear();
}
}
+
+
+void showText(char * buffer, uint8_t buf_len, uint8_t duration)
+{
+ for(int j=0; j<buf_len; j++){ /*loop over all of the chars in the text*/
+ matrix.drawChar(j*6, 0, buffer[j], 1, 0, 1);
+ matrix2.drawChar(j*6 - 16, 0, buffer[j], 1, 0, 1);
+ }
+ matrix.writeDisplay();
+ matrix2.writeDisplay();
+ Thread::wait(1000*duration);
+ matrix.clear();
+ matrix2.clear();
+
+}
\ No newline at end of file