Paint for the FRDM-KL25Z

Dependencies:   mbed TFT_fonts SPI_TFT_ILI9341

Committer:
ecowboy
Date:
Thu Jan 10 03:48:37 2019 +0000
Revision:
4:87b40e5986e7
Parent:
3:1396bac4ae71
Child:
5:80791250acb2
touch class enabled and working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ecowboy 0:42ec9a44bc24 1 #include "touch.h"
ecowboy 0:42ec9a44bc24 2 #include "mbed.h"
ecowboy 3:1396bac4ae71 3 #include "stdio.h"
ecowboy 0:42ec9a44bc24 4
ecowboy 3:1396bac4ae71 5
ecowboy 3:1396bac4ae71 6 TouchScreen::TouchScreen(PinName xp, PinName yp, PinName xm, PinName ym) {}
ecowboy 0:42ec9a44bc24 7
ecowboy 0:42ec9a44bc24 8
ecowboy 4:87b40e5986e7 9 int TouchScreen::readTouch(PinName a, PinName i, PinName n, PinName m){
ecowboy 4:87b40e5986e7 10 //int readTouch(PinName a, PinName i, PinName n, PinName m){
ecowboy 4:87b40e5986e7 11
ecowboy 4:87b40e5986e7 12 /*DigitalOut _n(PTB1);
ecowboy 0:42ec9a44bc24 13 _n = 1;
ecowboy 4:87b40e5986e7 14 DigitalOut _m(PTB0);
ecowboy 0:42ec9a44bc24 15 _m = 0;
ecowboy 3:1396bac4ae71 16 wait_ms(10);
ecowboy 4:87b40e5986e7 17 AnalogIn _a(PTB3);
ecowboy 3:1396bac4ae71 18 wait_ms(10);
ecowboy 4:87b40e5986e7 19 AnalogIn _i(PTB2);
ecowboy 0:42ec9a44bc24 20 wait_us(10);
ecowboy 3:1396bac4ae71 21 _n = 0;
ecowboy 4:87b40e5986e7 22 return (int)_a.read_u16();*/
ecowboy 4:87b40e5986e7 23
ecowboy 4:87b40e5986e7 24 AnalogIn _a(a);
ecowboy 4:87b40e5986e7 25 AnalogIn _i(i);
ecowboy 4:87b40e5986e7 26 DigitalOut _n(n);
ecowboy 4:87b40e5986e7 27 DigitalOut _m(m);
ecowboy 4:87b40e5986e7 28 //uint16_t y1=1;
ecowboy 4:87b40e5986e7 29 //uint16_t y2=0;
ecowboy 4:87b40e5986e7 30 int y1=1;
ecowboy 4:87b40e5986e7 31 int y2=0;
ecowboy 4:87b40e5986e7 32 _n = 1;
ecowboy 4:87b40e5986e7 33 _m = 0;
ecowboy 4:87b40e5986e7 34 wait_us(50);
ecowboy 4:87b40e5986e7 35 //while(y1 != y2){
ecowboy 4:87b40e5986e7 36 y1 = _a.read_u16();
ecowboy 4:87b40e5986e7 37 wait_us(50);
ecowboy 4:87b40e5986e7 38 y2 = _a.read_u16();
ecowboy 4:87b40e5986e7 39 wait_us(50);
ecowboy 4:87b40e5986e7 40 //}
ecowboy 4:87b40e5986e7 41 _n=0;
ecowboy 4:87b40e5986e7 42 return (y1+y2)/2;
ecowboy 0:42ec9a44bc24 43 }
ecowboy 0:42ec9a44bc24 44
ecowboy 0:42ec9a44bc24 45
ecowboy 0:42ec9a44bc24 46
ecowboy 0:42ec9a44bc24 47 /*bool TouchScreen::isTouching(void){
ecowboy 0:42ec9a44bc24 48 Point p = getPoint(p);
ecowboy 0:42ec9a44bc24 49 if(p.z > PRESSURE)return 1;
ecowboy 0:42ec9a44bc24 50 else return 0;
ecowboy 0:42ec9a44bc24 51 }*/
ecowboy 0:42ec9a44bc24 52
ecowboy 2:fe018965e46c 53 int map(float value, float fromSource, float toSource, float fromTarget, float toTarget){
ecowboy 0:42ec9a44bc24 54 return (value - fromSource) / (toSource - fromSource) * (toTarget - fromTarget) + fromTarget;
ecowboy 0:42ec9a44bc24 55 }