Shows how to use a display and the touch controller. Will display the X and Y coordinates of the current touch event.

Dependencies:   DmTftLibrary mbed

Files at this revision

API Documentation at this revision

Comitter:
displaymodule
Date:
Tue May 20 15:44:16 2014 +0000
Child:
1:63e25ac12708
Commit message:
First version

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
mbed-src.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DmTftLibrary.lib	Tue May 20 15:44:16 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/displaymodule/code/DmTftLibrary/#59be7fca4581
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue May 20 15:44:16 2014 +0000
@@ -0,0 +1,117 @@
+/**********************************************************************************************
+ Copyright (c) 2014 DisplayModule. All rights reserved.
+
+ Redistribution and use of this source code, part of this source code or any compiled binary
+ based on this source code is permitted as long as the above copyright notice and following
+ disclaimer is retained.
+
+ DISCLAIMER:
+ THIS SOFTWARE IS SUPPLIED "AS IS" WITHOUT ANY WARRANTIES AND SUPPORT. DISPLAYMODULE ASSUMES
+ NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE.
+ ********************************************************************************************/
+
+/******************************************************************************
+ * Includes
+ *****************************************************************************/
+
+#include "mbed.h"
+
+#include "DmTftHX8353C.h"
+#include "DmTftS6D0164.h"
+#include "DmTftIli9325.h"
+#include "DmTftIli9341.h"
+#include "DmTftSsd2119.h"
+#include "DmTouch.h"
+
+/******************************************************************************
+ * Typedefs and defines
+ *****************************************************************************/
+
+//#define log(...) printf(__VA_ARGS__)
+#define log(...)
+
+#if 0 /* 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
+
+/******************************************************************************
+ * Local variables
+ *****************************************************************************/
+
+//DmTftHX8353C tft;  /* DM_TFT18_101 */
+//DmTftS6D0164 tft;  /* DM_TFT22_102 */
+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 touch(DmTouch::DM_TFT24_104, false); /* For LPC4088 QuickStart Board */
+//DmTouch touch(DmTouch::DM_TFT28_105);
+//DmTouch touch(DmTouch::DM_TFT35_107);
+
+DigitalInOut csTouch(DM_PIN_CS_TOUCH, PIN_OUTPUT, PullUp, 1);
+DigitalInOut csDisplay(DM_PIN_CS_TFT, PIN_OUTPUT, PullUp, 1);
+DigitalInOut csSDCard(DM_PIN_CS_SDCARD, PIN_OUTPUT, PullUp, 1);
+#ifdef DM_PIN_CS_FLASH
+  DigitalInOut csFlash(DM_PIN_CS_FLASH, PIN_OUTPUT, PullUp, 1);
+#endif
+
+/******************************************************************************
+ * Global variables
+ *****************************************************************************/
+
+/******************************************************************************
+ * Local functions
+ *****************************************************************************/
+
+
+/******************************************************************************
+ * Main
+ *****************************************************************************/
+
+int main() {
+  log("init tft \r\n");
+  tft.init();
+
+  uint16_t x = 0;
+  uint16_t y = 0;
+  uint16_t w = tft.width();
+  uint16_t h = tft.height();
+  
+  bool down = false;
+  bool lastDown = false;
+  
+  tft.drawString(20, 20, "x:");
+  tft.drawString(100, 20, "y:");
+  
+  touch.init();
+  while (1) {
+    touch.readTouchData(x, y, down);
+    if (down) {
+      tft.drawNumber(40, 20, x, 5, false);
+      tft.drawNumber(120, 20, y, 5, false);
+    } else if (lastDown) {
+      // no longer pressed, clean text
+      tft.drawString(40, 20, "     ");
+      tft.drawString(120, 20, "     ");
+    }
+    wait(0.040);
+    lastDown = down;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-src.lib	Tue May 20 15:44:16 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/displaymodule/code/mbed-src/#3306e8fd8143