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