Paint for the FRDM-KL25Z
Dependencies: mbed TFT_fonts SPI_TFT_ILI9341
touch.cpp
- Committer:
- ecowboy
- Date:
- 2019-01-10
- Revision:
- 4:87b40e5986e7
- Parent:
- 3:1396bac4ae71
- Child:
- 5:80791250acb2
File content as of revision 4:87b40e5986e7:
#include "touch.h" #include "mbed.h" #include "stdio.h" TouchScreen::TouchScreen(PinName xp, PinName yp, PinName xm, PinName ym) {} int TouchScreen::readTouch(PinName a, PinName i, PinName n, PinName m){ //int readTouch(PinName a, PinName i, PinName n, PinName m){ /*DigitalOut _n(PTB1); _n = 1; DigitalOut _m(PTB0); _m = 0; wait_ms(10); AnalogIn _a(PTB3); wait_ms(10); AnalogIn _i(PTB2); wait_us(10); _n = 0; return (int)_a.read_u16();*/ AnalogIn _a(a); AnalogIn _i(i); DigitalOut _n(n); DigitalOut _m(m); //uint16_t y1=1; //uint16_t y2=0; int y1=1; int y2=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); //} _n=0; return (y1+y2)/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; }