Basic calculator example to show the LPC4088 Experiment Base Board with a touch LCD from DisplayModule

Dependencies:   DmTftLibrary mbed

Fork of dm_calc by Display Module

Files at this revision

API Documentation at this revision

Comitter:
embeddedartists
Date:
Thu Sep 11 14:28:56 2014 +0000
Parent:
4:71588a1e3618
Child:
6:2063744e0512
Commit message:
Fixed hardfault issue and removed unnecessary prints.

Changed in this revision

DmTftLibrary.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/DmTftLibrary.lib	Wed Sep 10 12:48:14 2014 +0000
+++ b/DmTftLibrary.lib	Thu Sep 11 14:28:56 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/displaymodule/code/DmTftLibrary/#8b441dd1d470
+http://mbed.org/users/displaymodule/code/DmTftLibrary/#eb97ccfe7c3f
--- a/main.cpp	Wed Sep 10 12:48:14 2014 +0000
+++ b/main.cpp	Thu Sep 11 14:28:56 2014 +0000
@@ -43,6 +43,8 @@
 
 #define NUM_BUTTONS  (sizeof(captions)/sizeof(captions[0]))
 
+#define NUM_CHARS_IN_DISPLAY  20
+
 #if 0
   /* Displays without adapter (DM_TFT28_105 & DM_TFT35_107) */
   #define DM_PIN_CS_TOUCH   D4
@@ -111,7 +113,7 @@
   
 Button* buttons[NUM_BUTTONS];
 
-static char buff[25] = {0};
+static char buff[NUM_CHARS_IN_DISPLAY + 1] = {0};
 static bool redrawResult = true;
 static bool clearResult = true;
 
@@ -132,6 +134,13 @@
   static calc_mode_t mode = MODE_WANT_ARG1;
   static int strpos = 0;
   
+  if (strpos == NUM_CHARS_IN_DISPLAY) {
+    // only accept 'clr' and '=' to prevent overflow
+    if ((arg != 'c') && (arg != '=')) {
+      return;
+    }
+  }
+    
   switch (arg)
   {
     case '0':
@@ -256,18 +265,6 @@
   while(true) {
     touch.readTouchData(x, y, down);
     
-    /* The following printouts are for some unexplainable reason needed
-       on the LPC4088 QuickStart Board in combination with the MBED online compiler.
-       The printouts are not needed when using an external compiler, e.g. Keil uVision
-       or LPCXpresso IDE. */
-#if defined(__LPC407x_8x_177x_8x_H__)
-    if (down) {
-      printf("DOWN %4d, %4d\n", x, y);
-    } else {
-      printf("UP   %4d, %4d\n", x, y);
-    }
-#endif
-    
     for (int i = 0; i < NUM_BUTTONS; i++) {
       if (buttons[i]->handle(x, y, down)) {
         buttons[i]->draw(&tft);