Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DmTftLibrary mbed
Fork of dm_touch by
Diff: main.cpp
- Revision:
- 0:144e2312d558
- Child:
- 1:63e25ac12708
diff -r 000000000000 -r 144e2312d558 main.cpp
--- /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;
+ }
+}
