Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: touch2 default CANary_9341_test CANary_merge
Fork of Touch_tft by
TOUCH_TFTx2.h
- Committer:
- TickTock
- Date:
- 2013-02-17
- Revision:
- 6:a91b668b058a
- Parent:
- 5:a9890c586a64
- Child:
- 10:fd7ae99850a9
File content as of revision 6:a91b668b058a:
/* mbed library for touchscreen connected to 4 mbed pins
* derive from SPI_TFT lib
* Copyright (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.
*/
#ifndef MBED_TOUCH_H
#define MBED_TOUCH_H
#include "mbed.h"
#include "SPI_TFTx2.h"
struct point{
unsigned short x;
unsigned short y;
};
class TOUCH_TFTx2 : public SPI_TFTx2{
public:
/** create a TFT with touch object connected to the pins:
*
* @param pin xp resistiv touch x+
* @param pin xm resistiv touch x-
* @param pin yp resistiv touch y+
* @param pin ym resistiv touch y-
* @param mosi,miso,sclk SPI connection to TFT
* @param cs pin connected to CS of display
* @param reset pin connected to RESET of display
* based on my SPI_TFT lib
*/
TOUCH_TFTx2(PinName xp, PinName xm, PinName yp, PinName ym,PinName mosi, PinName miso, PinName sclk, PinName cs0, PinName cs1, PinName reset,const char* name ="TFT");
/** calibrate the touch display
*
* User is asked to touch on two points on the screen
*/
void calibrate(void);
/** read x and y analog samples
*
* @returns point(x,y)
*/
point get_touch(void);
/** calculate coord on screen
*
* @param a_point point(analog x, analog y)
* @returns point(pixel x, pixel y)
*
*/
point to_pixel(point a_point);
/** test if screen is touched
*
* @param point analog x,y
* @returns true is touched
*
*/
bool is_touched(void);
void wfi(void);
protected:
DigitalInOut _xp;
DigitalInOut _xm;
DigitalInOut _yp;
DigitalInOut _ym;
AnalogIn _ax;
AnalogIn _ay;
PinName xa;
PinName ya;
unsigned short x_a,y_a;
unsigned short x0_off,y0_off;
unsigned short x0_pp,y0_pp;
unsigned short x1_off,y1_off;
unsigned short x1_pp,y1_pp;
unsigned short x_mid;
};
#endif
