test export

Dependencies:   DmTftLibrary mbed

Fork of dm_calc by Display Module

Revision:
1:9a3ae682a75e
Parent:
0:3713b01e72fe
Child:
2:b17b19212e5a
--- a/main.cpp	Tue May 20 15:36:25 2014 +0000
+++ b/main.cpp	Fri Jul 04 10:33:40 2014 +0000
@@ -43,24 +43,26 @@
 
 #define NUM_BUTTONS  (sizeof(captions)/sizeof(captions[0]))
 
-#if 0 /* Displays without adapter */
-#define DM_PIN_SPI_MOSI   D11
-#define DM_PIN_SPI_MISO   D12
-#define DM_PIN_SPI_SCLK   D13
+#if 1
+  /* Displays without adapter */
+  #define DM_PIN_SPI_MOSI   D11
+  #define DM_PIN_SPI_MISO   D12
+  #define DM_PIN_SPI_SCLK   D13
+  #define DM_PIN_CS_TOUCH   D4
+  #define DM_PIN_CS_TFT     D10
+  #define DM_PIN_CS_SDCARD  D8
+  #define DM_PIN_CS_FLASH   D6
+#else
+  /* Displays with adapter */
+  #define DM_PIN_SPI_MOSI   A0
+  #define DM_PIN_SPI_MISO   D9
+  #define DM_PIN_SPI_SCLK   A1
+  #define DM_PIN_CS_TOUCH   D8
+  #define DM_PIN_CS_TFT     A3
+  #define DM_PIN_CS_SDCARD  D10
+#endif
 
-#define DM_PIN_CS_TOUCH   D4
-#define DM_PIN_CS_TFT     D10
-#define DM_PIN_CS_SDCARD  D8
-#define DM_PIN_CS_FLASH   D6
-#else /* Displays with adapter */
-#define DM_PIN_SPI_MOSI   A0
-#define DM_PIN_SPI_MISO   D9
-#define DM_PIN_SPI_SCLK   A1
-
-#define DM_PIN_CS_TOUCH   D8
-#define DM_PIN_CS_TFT     A3
-#define DM_PIN_CS_SDCARD  D10
-#endif
+//#define LANDSCAPE
 
 /******************************************************************************
  * Local variables
@@ -68,15 +70,15 @@
 
 //DmTftHX8353C tft;  /* DM_TFT18_101 */
 //DmTftS6D0164 tft;  /* DM_TFT22_102 */
-DmTftIli9325 tft;  /* DM_TFT28_103 and DM_TFT24_104 */
-//DmTftIli9341 tft;  /* DM_TFT28_105 */
+//DmTftIli9325 tft;  /* DM_TFT28_103 and DM_TFT24_104 */
+DmTftIli9341 tft;  /* DM_TFT28_105 */
 //DmTftSsd2119 tft;   /* DM_TFT35_107 */
 
-//DmTouch touch(DmTouch::DM_TFT28_103, false); /* For LPC4088 QuickStart Board */
+//DmTouch touch(DmTouch::DM_TFT28_103, DmTouch::Software); /* For LPC4088 QuickStart Board */
 //DmTouch touch(DmTouch::DM_TFT28_103);
-//DmTouch touch(DmTouch::DM_TFT24_104, false); /* For LPC4088 QuickStart Board */
-DmTouch touch(DmTouch::DM_TFT24_104);
-//DmTouch touch(DmTouch::DM_TFT28_105);
+//DmTouch touch(DmTouch::DM_TFT24_104, DmTouch::Software); /* For LPC4088 QuickStart Board */
+//DmTouch touch(DmTouch::DM_TFT24_104);
+DmTouch touch(DmTouch::DM_TFT28_105);
 //DmTouch touch(DmTouch::DM_TFT35_107);
 
 DigitalInOut csTouch(DM_PIN_CS_TOUCH, PIN_OUTPUT, PullUp, 1);
@@ -86,18 +88,36 @@
   DigitalInOut csFlash(DM_PIN_CS_FLASH, PIN_OUTPUT, PullUp, 1);
 #endif  
 
-/*
- *   7   8   9   +
- *   4   5   6   -
- *   3   2   1   *
- *   0   =  clr  /
- */
-const char* captions[] = {
-    "7","8","9","+",
-    "4","5","6","-",
-    "3","2","1","*",
-    "0","=","clr","/",
-};
+#ifdef LANDSCAPE
+  #define BUTTONS_PER_LINE   6
+  #define BUTTONS_NUM_LINES  3
+  /*
+   *   1   2   3   4   5   +
+   *   6   7   8   9   0   -
+   *   *   /   =   clr
+   */
+  const char* captions[] = {
+      "1","2","3","4","5","+",
+      "6","7","8","9","0","-",
+      "*","/","=","clr",
+  };  
+#else
+  #define BUTTONS_PER_LINE   4
+  #define BUTTONS_NUM_LINES  4
+  /*
+   *   1   2   3   +
+   *   4   5   6   -
+   *   7   8   9   *
+   *   0   =  clr  /
+   */
+  const char* captions[] = {
+      "1","2","3","+",
+      "4","5","6","-",
+      "7","8","9","*",
+      "0","=","clr","/",
+  };
+#endif
+  
 Button* buttons[NUM_BUTTONS];
 
 static char buff[25] = {0};
@@ -215,13 +235,13 @@
   uint16_t y = 0;
   uint16_t w = tft.width();
   uint16_t h = tft.height();
-  uint16_t size = (w - 5*MARGIN)/4;
-  uint16_t yoff = h - (size + MARGIN)*4;
+  uint16_t size = (w - (BUTTONS_PER_LINE + 1)*MARGIN)/BUTTONS_PER_LINE;
+  uint16_t yoff = h - (size + MARGIN)*BUTTONS_NUM_LINES;
   bool down = false;
 
   for (int i = 0; i < NUM_BUTTONS;i++) {
-    x = MARGIN + (size + MARGIN) * (i % 4);
-    y = yoff + (size + MARGIN) * (i / 4);
+    x = MARGIN + (size + MARGIN) * (i % BUTTONS_PER_LINE);
+    y = yoff + (size + MARGIN) * (i / BUTTONS_PER_LINE);
     buttons[i] = new Button(captions[i], x, y, size, size);
     buttons[i]->setAction(handleClick, captions[i][0]);
   }