projets de S3 s4 2021

Dependencies:   mbed TFT_fonts SPI_TFT_ILI9341

Revision:
6:13d0de9e679c
Parent:
5:80791250acb2
--- a/touch.cpp	Thu Jan 10 04:31:29 2019 +0000
+++ b/touch.cpp	Sat Jan 12 03:48:27 2019 +0000
@@ -1,6 +1,20 @@
+/* KL25Z mbed library for ILI9341 touch devices
+ * SPI Interface
+
+ * Uses Peter Drescher ILI9341 Library
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
 #include "touch.h"
 #include "mbed.h"
-#include "stdio.h"
 
 
 TouchScreen::TouchScreen(PinName xp, PinName yp, PinName xm, PinName ym) {
@@ -13,29 +27,21 @@
     AnalogIn   _i(i);
     DigitalOut _n(n);
     DigitalOut _m(m);
-    int y1=1;
-    int y2=0;
+    int a1=1;
+    int a2=0;
     _n = 1;
     _m = 0;
     wait_us(50);
-    //while(y1 != y2){
-        y1 = _a.read_u16();
-        wait_us(50);
-        y2 = _a.read_u16();
-        wait_us(50);
-    //}
+    a1 = _a.read_u16();
+    wait_us(50);
+    a2 = _a.read_u16();
+    wait_us(50);
     _n=0;
-    return (y1+y2)/2;
+    return (a1+a2)/2;
 }
 
 
-
-/*bool TouchScreen::isTouching(void){
-    Point p = getPoint(p);
-    if(p.z > PRESSURE)return 1;
-    else return 0;
-}*/
-
+                
 int map(float value, float fromSource, float toSource, float fromTarget, float toTarget){
         return (value - fromSource) / (toSource - fromSource) * (toTarget - fromTarget) + fromTarget;
 }
\ No newline at end of file