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: GT20L16J1Y_font TinyJpgDec mbed
Diff: mGTP/mGTPlib.cpp
- Revision:
- 0:6fa19738f62e
diff -r 000000000000 -r 6fa19738f62e mGTP/mGTPlib.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mGTP/mGTPlib.cpp Mon Sep 08 16:07:05 2014 +0000
@@ -0,0 +1,46 @@
+// --------------------------------------------------------
+// mGTPlib.c (c) Copyright 2013-2014 Goji.
+// --------------------------------------------------------
+
+#include "mbed.h"
+#include "mainconf.h"
+
+#include "mGTP.h"
+
+extern TFT_INFO TFT_info;
+
+#define TPC_ABS(a,b) ((a>b)?(a-b):(b-a))
+
+int16_t TPC_getXYO(int16_t *dx, int16_t *dy)
+{
+ int16_t wx1, wx2, wy1, wy2;
+
+ if ((wx1 = get_pX()) < TFT_info.TPC_xNon) return(0);
+ if ((wy1 = get_pY()) < TFT_info.TPC_yNon) return(0);
+ wait_us(300);
+ if ((wx2 = get_pX()) < TFT_info.TPC_xNon) return(0);
+ if ((wy2 = get_pY()) < TFT_info.TPC_yNon) return(0);
+ if ((TPC_ABS(wx1, wx2) > 20) || (TPC_ABS(wy1, wy2) > 20)) return(1);
+
+ *dx = (wx1 + wx2) / 2;
+ *dy = (wy1 + wy2) / 2;
+
+ return(2);
+}
+
+int16_t TPC_getXY(int16_t *dx, int16_t *dy)
+{
+ int16_t rc;
+
+ if ((rc = TPC_getXYO(dx, dy)) != 2) return(rc);
+
+ *dx = (*dx > TFT_info.TPC_xMin) ? (*dx - TFT_info.TPC_xMin) : 0;
+ *dy = (*dy > TFT_info.TPC_yMin) ? (*dy - TFT_info.TPC_yMin) : 0;
+ if (*dx > TFT_info.TPC_xMax) *dx = TFT_info.TPC_xMax;
+ if (*dy > TFT_info.TPC_yMax) *dy = TFT_info.TPC_yMax;
+
+ *dx = ((((*dx * 1000) / TFT_info.TPC_xMax) * (TFT_info.xMAX - 1)) / 1000);
+ *dy = ((((*dy * 1000) / TFT_info.TPC_yMax) * (TFT_info.yMAX - 1)) / 1000);
+
+ return(2);
+}