SMS message display on LED Matrix board with printer option

Dependencies:   AdafruitThermalPrinter HT1632_LedMatrix VodafoneUSBModem mbed-rtos mbed

Revision:
7:b46d5d98434a
Parent:
6:323d7422ca8b
--- a/main.cpp	Mon Apr 08 20:55:20 2013 +0000
+++ b/main.cpp	Mon Jul 29 21:10:47 2013 +0000
@@ -47,8 +47,9 @@
 #include <ctype.h>
 
 #include "mbed.h"
+//#include "beep.h"
 #include "VodafoneUSBModem.h"
-//#include <LinkMonitor.h>
+//#include "LinkMonitor.h"
 
 #ifdef USE_LED
 #include "HT1632_LedMatrix.h"
@@ -57,13 +58,17 @@
 #include "AdafruitThermal.h"
 #endif
 
-#define DEBUG 1
+//#define DEBUG 1
 
 #ifdef USE_LED
 // Default scrolling message includes own number obtained using USSD request
 #define INFO_MSG "       Send a message to "
+//#define INFO_MSG "       Welcome to the IoT London Showcase. Send a message to "
+//#define INFO_MSG "       Welcome to the Reading Geek Night. Send a message to "
 #endif
 
+#define BRIGHTNESS 10
+
 // Vodafone USSD commands
 #define USSD_COMMAND_OWN_NUMBER "*#100#"
 #define USSD_COMMAND_BALANCE "*#134#"
@@ -87,8 +92,10 @@
 #define LED_MAX_DISPLAY_X 4
 #define LED_MAX_DISPLAY_Y 1
 
+
 // create object to control the LED Matrix
-HT1632_LedMatrix led = HT1632_LedMatrix();
+HT1632_LedMatrix led = HT1632_LedMatrix(p7, p5, p19, p17, p18, p20);    //, LED_MAX_DISPLAY_X,LED_MAX_DISPLAY_Y );
+//HT1632_LedMatrix led = HT1632_LedMatrix(p7, p5, p17, p18, p19, p20);    //, LED_MAX_DISPLAY_X,LED_MAX_DISPLAY_Y );
 #define DISPDELAY 90
 #endif
 
@@ -111,6 +118,9 @@
 void matrixDemo( void );
 #endif
 
+// Define object for buzzer to signal new message received
+//Beep buzzer(p21);
+
 // Define the onboard LEDs to use as status indicators
 DigitalOut led1(LED1);      // Activity
 DigitalOut led2(LED2);      // Activity, alternates with led2
@@ -149,6 +159,7 @@
 {
     strncpy( newMsgBuf, newMsgStart, MAX_MSG_LENGTH );
     resetMessage = true;
+ //   buzzer.beep(1000,0.5);
 }
 
 
@@ -267,6 +278,7 @@
     threadRestartCount++;
 
     // Getting the link state seems to speed up startup of the library
+    // Sometimes startup doesnt happen - need way to retry this
     modem.getLinkState( &pRssi,&pRegistrationState, &pBearer);
 #ifdef DEBUG
     debug_pc.printf("Link state Rssi: %d, Registration state %x Bearer %x\n",pRssi,pRegistrationState, pBearer);
@@ -402,6 +414,7 @@
         // TODO add minimum interval between message changes, e.g. 60s
         if( resetMessage && msgFinished ) {
             led.clear();
+            led.setBrightness(BRIGHTNESS);
             crtPos = 0;
             msgx = 1;
             msgFinished = false;
@@ -489,14 +502,19 @@
 
     led.init(LED_MAX_DISPLAY_X,LED_MAX_DISPLAY_Y);    // Use all displays as 128x8 display
     led.clear();
-    led.setBrightness(10);
+    led.setBrightness(BRIGHTNESS);
     //led.displayOff(); // Turn off display for now until receiver task has started
     bool twoLineDisplay = (LED_MAX_DISPLAY_X > 1);
     led.putString( 0, 0, "SMS to LED Display" );
 
-    Thread::wait(3000);   // Wait for display to initialise after power up
+//    Thread::wait(3000);   // Wait for display to initialise after power up
 #endif
 
+    // Startup beep
+ //   buzzer.beep(1000,0.5);
+    
+    Thread::wait(30000);     // Wait for bit longer to ensure dongle powers up
+
     // Set initial blank message
     resetMessageBuffers();
 
@@ -505,7 +523,7 @@
     Thread displayTask(displayScrollingLine, NULL, osPriorityNormal, 1024 * 4);
 #endif
 
-    // Show we are still working by alternitively flashing LED1 adn LED2, once a second
+    // Show we are still working by alternitively flashing LED1 and LED2, once a second
     led1 = 0;       // Working
     led2 = 1;       // Alternate with led1
     led3 = 0;       // Received and processing SMS