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

Revision:
7:5cc7d70faa97
Parent:
6:d28b8be6e90a
--- a/main.cpp	Fri Sep 18 14:59:45 2015 +0000
+++ b/main.cpp	Mon Oct 12 08:58:55 2015 +0000
@@ -11,7 +11,7 @@
  ********************************************************************************************/
 
 /******************************************************************************
- * Includes
+ * Tested on NUCLEO-F401RE, LPCXpresso11U68, LPCXpresso824-MAX platform.
  *****************************************************************************/
 
 #include "mbed.h"
@@ -59,24 +59,24 @@
 /******************************************************************************
  * Local variables
  *****************************************************************************/
-
-//DmTftIli9325 tft;  /* DM_TFT28_103 and DM_TFT24_104 */
-DmTftIli9341 tft;  /* DM_TFT28_105 */
-//DmTftSsd2119 tft;   /* DM_TFT35_107 */
-//DmTftRa8875  tft;  /* DM_TFT43_108 and DM_TFT50_111 */  
+ 
+/*********  TFT DISPLAY INIT *********/
+//DmTftIli9325 tft(A4, A3, A5, A2);  /* DmTftIli9325(PinName wr, PinName cs, PinName dc, PinName rst) DM_TFT28_103 and DM_TFT24_104 */
+DmTftIli9341 tft(D10, D9, D11, D12, D13);  /* DmTftIli9341(PinName cs, PinName dc, PinName mosi, PinName miso, PinName clk)  DM_TFT28_105 and DM_TFT28_116*/
+//DmTftSsd2119 tft(D10, D9, D11, D12, D13);  /* DmTftSsd2119(PinName cs, PinName dc, PinName mosi, PinName miso, PinName clk) DM_TFT35_107 */
+//DmTftRa8875  tft(D10, D9, D11, D12, D13);  /* DmTftRa8875(PinName cs, PinName sel, PinName mosi, PinName miso, PinName clk) DM_TFT43_108 and DM_TFT50_111   For DmTftRa8875 driver, The panel resolution should be config in DmTftRa8875::init() function on the DmTftRa8875.cpp file. */
 
-//DmTouch touch(DmTouch::DM_TFT28_103, DmTouch::Software); /* For LPC4088 QuickStart Board */
+ /*********   TOUCH PANEL INIT  *********/
 //DmTouch touch(DmTouch::DM_TFT28_103);
-//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);
-//DmTouch touch(DmTouch::DM_TFT43_108);  // For DmTftRa8875 driver, The panel resolution should be config in DmTftRa8875::init() function on the DmTftRa8875.cpp file.
+DmTouch touch(DmTouch::DM_TFT28_105, D11, D12, D13);
+/* DM-TFT28-116  */
+//I2C i2c(D14, D15);  
+//DmTpFt6x06 touch(DmTpFt6x06::DM_TFT28_116, i2c); 
+//DmTouch touch(DmTouch::DM_TFT35_107, D11, D12, D13);
+//DmTouch touch(DmTouch::DM_TFT43_108, D11, D12, D13);  // For DmTftRa8875 driver, The panel resolution should be config in DmTftRa8875::init() function on the DmTftRa8875.cpp file.
 //DmTouch touch(DmTouch::DM_TFT50_111);
 
-// DM-TFT28-116;
-I2C i2c(D14, D15);  
-DmTpFt6x06 touch(DmTpFt6x06::DM_TFT28_116, i2c); 
 
 DigitalInOut csTouch(DM_PIN_CS_TOUCH, PIN_OUTPUT, PullUp, 1);
 DigitalInOut csDisplay(DM_PIN_CS_TFT, PIN_OUTPUT, PullUp, 1);
@@ -112,13 +112,14 @@
   
   tft.drawString(20, 20, "x:");
   tft.drawString(100, 20, "y:");
-  
+
   touch.init();
   while (1) {
-    touch.readTouchData(x, y, down);
+   touch.readTouchData(x, y, down);
     if (down) {
       tft.drawNumber(40, 20, x, 5, false);
       tft.drawNumber(120, 20, y, 5, false);
+      tft.drawPoint(x, y, 1);
     } else if (lastDown) {
       // no longer pressed, clean text
       tft.drawString(40, 20, "     ");
@@ -127,4 +128,5 @@
     wait(0.040);
     lastDown = down;
   }
+
 }