Paint for the FRDM-KL25Z

Dependencies:   mbed TFT_fonts SPI_TFT_ILI9341

touch.cpp

Committer:
ecowboy
Date:
2019-01-08
Revision:
2:fe018965e46c
Parent:
1:33506fcfdd95
Child:
3:1396bac4ae71

File content as of revision 2:fe018965e46c:

#include "touch.h"
#include "mbed.h"

TouchScreen::TouchScreen(PinName xp, PinName yp, PinName xm, PinName ym) {
    PinName _yp = yp;
    PinName _xm = xm;
    PinName _ym = ym;
    PinName _xp = xp;
}


int TouchScreen::readTouch(PinName n, PinName m, PinName a, PinName i){
    
    DigitalOut _n(n);
    _n = 1;
    DigitalOut _m(m);
    _m = 0;
    AnalogIn   _a(a);
    AnalogIn   _i(i);
    wait_us(10);
    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;
}