Draw a bitmap file in a sd card

Dependencies:   SPI_TFT_ILI9341

Dependents:   Seeed_TFT_Touch_ShieldA Digital_Photo_Frame_with_FTP_SD_WIZwiki-W7500

Fork of SeeedStudioTFTv2 by Components

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SeeedStudioTFTv2.h Source File

SeeedStudioTFTv2.h

00001 /* mbed library for touchscreen connected to 4 mbed pins
00002  * derive from SPI_TFT lib
00003  * Copyright (c) 2011 Peter Drescher - DC2PD
00004  *
00005  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00006  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00007  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00008  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00009  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00010  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00011  * THE SOFTWARE.
00012  */
00013 
00014 #ifndef MBED_TOUCH_H
00015 #define MBED_TOUCH_H
00016 
00017 #define USE_SDCARD
00018 
00019 #include "mbed.h"
00020 #include "SPI_TFT_ILI9341.h"
00021 #ifdef USE_SDCARD
00022 #include "SDFileSystem.h" // import the SDFileSystem library 
00023 #endif
00024 
00025 struct point {
00026     int x;
00027     int y;
00028 };
00029 
00030 class SeeedStudioTFTv2 : 
00031 #ifdef USE_SDCARD
00032     public  SDFileSystem,
00033 #endif
00034     public  SPI_TFT_ILI9341
00035 {
00036 public:
00037     /** create a TFT with touch object connected to the pins:
00038      *
00039      * @param pin xp resistiv touch x+
00040      * @param pin xm resistiv touch x-
00041      * @param pin yp resistiv touch y+
00042      * @param pin ym resistiv touch y-
00043      * @param mosi,miso,sclk SPI connection to TFT
00044      * @param cs pin connected to CS of display
00045      * @param reset pin connected to RESET of display
00046      * based on my SPI_TFT lib
00047      */
00048     SeeedStudioTFTv2(PinName xp, PinName xm, PinName yp, PinName ym,
00049                      PinName mosi, PinName miso, PinName sclk,
00050                      PinName csTft, PinName dcTft, PinName blTft,
00051                      PinName csSd);
00052 
00053     void setBacklight(bool enabled);
00054     
00055     /** calibrate the touch display
00056      *
00057      * User is asked to touch on two points on the screen
00058      */
00059     void calibrate(void);
00060 
00061     /** read x and y coord on screen
00062      *
00063      * @returns point(x,y)
00064      */
00065     bool
00066     getPixel(point& p);
00067 
00068     /** calculate coord on screen
00069     *
00070     * @param a_point point(analog x, analog y)
00071     * @returns point(pixel x, pixel y)
00072     *
00073     */
00074     point toPixel(point p);
00075 
00076 protected:
00077     PinName _xm;
00078     PinName _ym;
00079     PinName _xp;
00080     PinName _yp;
00081     DigitalOut bl;
00082 
00083     typedef enum { YES, MAYBE, NO } TOUCH;
00084     TOUCH getTouch(point& p);
00085     int readTouch(PinName p, PinName m, PinName a, PinName i);
00086 
00087     int x_off,y_off;
00088     int pp_tx,pp_ty;
00089 };
00090 
00091 #endif
00092