This is a fork of a functional ILI9341 display with a functional Seeed touch screen library.

Dependencies:   BMP180 UniGraphic mbed BNO055_fusionI_fixed HTU21D GPSISR Compass Fonts uGUI

Fork of TFT_test_NUCLEO-F411RE by Motoo Tanaka

/media/uploads/trevieze/win_20170427_21_31_20_pro.jpg

Had to move sensors to a remote board because of interference. Added spi burst mode to supported displays.

To do.... ugui buttons are slow. will need to add rtos to project. Finish other way points screen. Will have to rewrite portions of the touch screen class. Sense touch, delay, read values and then average, touch released, is the sequence. Add cadence input and logic to program for computer screen.

SeeedStudioTFTv2.cpp

Committer:
trevieze
Date:
2016-12-17
Revision:
2:c5085faf2aa5
Child:
14:b174ec6e3ca0

File content as of revision 2:c5085faf2aa5:

/* mbed library for resistive touch pads
 * uses 4 pins - 2 IO and 2 Analog

 * c 2011 Peter Drescher - DC2PD
 *
 * 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 "mbed.h"
#include "SeeedStudioTFTv2.h"

//Serial pc(USBTX,USBRX,19200);

TouchScreen::TouchScreen(PinName xp, PinName xm, PinName yp, PinName ym)
{
    //font = NULL;
    // touch screen pins
    _xp = xp;
    _yp = yp;
    _xm = xm;
    _ym = ym;
    // default touch calibration
    // orientation     //      0      1      2      3
    x_off = 108000;  //  17252  16605 108755 108000
    y_off =  22000;  //  22330 105819  97167  22000
    pp_tx =   -291;  //    378    289   -390   -291
    pp_ty =    356;  //    261   -355   -239    356
}

int TouchScreen::readTouch(PinName p, PinName m, PinName a, PinName i)
{
    DigitalOut _p(p);
    _p = 1;
    DigitalOut _m(m);
    _m = 0;
    AnalogIn   _a(a);
    AnalogIn   _i(i); // this pin has to be high Z (DigitalIn may also work)
    wait_us(10);
    return _a.read_u16();
}

void TouchScreen :: getTouch(point& p)
{
    int y2 = readTouch(_xp,_xm,_yp,_ym);
    int x2 = readTouch(_yp,_ym,_xp,_xm);
    int y1 = readTouch(_xp,_xm,_yp,_ym);
    int x1 = readTouch(_yp,_ym,_xp,_xm);
    int xd = x1 - x2;
    int yd = y1 - y2;
    xd = (xd > 0) ? xd : -xd;
    yd = (yd > 0) ? xd : -xd;
    p.x = x1 + x2;
    p.y = y1 + y2;
            
    int z1          =  _xm;
    int z2          =  _yp;
    float rtouch    =  0;

    rtouch  = z2;
    rtouch /= z1;
    rtouch -= 1;
    rtouch *= (2046-p.x)/2;
    rtouch *= RXPLATE;
    rtouch /= 1024;
    p.z = abs(rtouch);
 }