Message scroller
Dependencies: HT1632_LedMatrix mbed-rtos mbed
Revision 0:5438c56c3e4c, committed 2012-11-28
- Comitter:
- SomeRandomBloke
- Date:
- Wed Nov 28 16:46:58 2012 +0000
- Child:
- 1:fecc093f43d4
- Commit message:
- Example scrolling message
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HT1632_LedMatrix.lib Wed Nov 28 16:46:58 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/SomeRandomBloke/code/HT1632_LedMatrix/#af973a9c48b2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Nov 28 16:46:58 2012 +0000
@@ -0,0 +1,71 @@
+// Simple scrolling message display for mbed and HT1632C based LED matrix displays
+
+#include "mbed.h"
+#include <HT1632_LedMatrix.h>
+
+Serial pc(USBTX, USBRX); // tx, rx
+
+// Define the onboard LEDs to use as status indicators
+DigitalOut led1(LED1); // Activity
+DigitalOut led2(LED2); // Activity, alternates with led2
+
+// create object to control the LED Matrix
+HT1632_LedMatrix led = HT1632_LedMatrix();
+
+#define DISPDELAY 90
+
+// Define the message, add blanks to front so it doesnt lose first part immediately
+char* msg = " The quick brown fox jumped over the lazy dog!!!";
+int crtPos = 0;
+int msgx = 1; // position on message screen of current character, set to 1 to allow for first scroll
+
+/*
+* This works for multiple 8x32 matrix.
+*/
+void displayScrollingLine( void const* )
+{
+ int y,xmax,ymax;
+ led.getXYMax(&xmax,&ymax);
+ while(true) {
+ // shift the whole screen 6 times, one column at a time;
+ for (int x=0; x < 6; x++) {
+ led.scrollLeft(1,0);
+ msgx--;
+ // fit as much as we can on display
+ while (!led.putChar(msgx,0,msg[crtPos])) { // zero return if it all fitted on display
+ led.getXY(&msgx,&y);
+ crtPos++; // we got all of the character on!!
+ if (crtPos >= strlen(msg)) {
+ crtPos = 0;
+ }
+ }
+ led.putShadowRam();
+ Thread::wait(DISPDELAY);
+ }
+ }
+}
+
+
+int main()
+{
+ // Define how many displays we have, older 0832 allowed vertical stacking
+ // newer ones dont unless you want a gap between the displays.
+ // Num horizontal displays 1 to 4, num vertical displays 1 to 4. Max 4 displays can be used.
+ // Usable combinations are 1,1; 2,1; 3,1; 4,1; and 2,2; 1,2; 1,3; 1,4; with gaps!!
+ led.init(1,1);
+ pc.baud(9600);
+ printf("LED Matrix dislay test");
+ led.clear();
+ led.setBrightness(8);
+
+ Thread displayTask(displayScrollingLine, NULL, osPriorityNormal, 1024 * 4);
+
+ // Show we are still working by alternatively flashing LED1 and LED2, once a second
+ led1 = 0; // Working
+ led2 = 1; // Alternate with led1
+ while(1) {
+ led1=!led1;
+ led2=!led2;
+ Thread::wait(1000);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Nov 28 16:46:58 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/134def52cfa0 \ No newline at end of file