aitendo SX032QVGA008
Dependencies: SPI_TFT_ILI9341ext
SX032QVGA008.h@0:7db6d9893ccb, 2015-04-14 (annotated)
- Committer:
- king33jp
- Date:
- Tue Apr 14 05:49:32 2015 +0000
- Revision:
- 0:7db6d9893ccb
Open for my friend Yoshi
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
king33jp | 0:7db6d9893ccb | 1 | /* mbed library for aitendo SX032QVGA08 TFT module with resistive touch panel. |
king33jp | 0:7db6d9893ccb | 2 | * |
king33jp | 0:7db6d9893ccb | 3 | * Original library is "SpeedStudioTFT" by 2014 Copyright (c) Seeed Technology Inc. |
king33jp | 0:7db6d9893ccb | 4 | * I made by it to the reference. |
king33jp | 0:7db6d9893ccb | 5 | * |
king33jp | 0:7db6d9893ccb | 6 | * (1) Because there was some mistake in the source, I was corrected. |
king33jp | 0:7db6d9893ccb | 7 | * (2) Also, I changed to the source you have to assume FRDM |
king33jp | 0:7db6d9893ccb | 8 | * (3) I changed BackLight is PWM controlled. |
king33jp | 0:7db6d9893ccb | 9 | */ |
king33jp | 0:7db6d9893ccb | 10 | |
king33jp | 0:7db6d9893ccb | 11 | #ifndef SX032QVGA008_H |
king33jp | 0:7db6d9893ccb | 12 | #define SX032QVGA008_H |
king33jp | 0:7db6d9893ccb | 13 | |
king33jp | 0:7db6d9893ccb | 14 | #include "mbed.h" |
king33jp | 0:7db6d9893ccb | 15 | #include "SPI_TFT_ILI9341ext.h" |
king33jp | 0:7db6d9893ccb | 16 | #ifdef USE_SDCARD |
king33jp | 0:7db6d9893ccb | 17 | #include "SDFileSystem.h" // import the SDFileSystem library |
king33jp | 0:7db6d9893ccb | 18 | #endif |
king33jp | 0:7db6d9893ccb | 19 | |
king33jp | 0:7db6d9893ccb | 20 | struct point { |
king33jp | 0:7db6d9893ccb | 21 | int x; |
king33jp | 0:7db6d9893ccb | 22 | int y; |
king33jp | 0:7db6d9893ccb | 23 | }; |
king33jp | 0:7db6d9893ccb | 24 | |
king33jp | 0:7db6d9893ccb | 25 | class SX032QVGA008 : public |
king33jp | 0:7db6d9893ccb | 26 | #ifdef USE_SDCARD |
king33jp | 0:7db6d9893ccb | 27 | SDFileSystem, |
king33jp | 0:7db6d9893ccb | 28 | #endif |
king33jp | 0:7db6d9893ccb | 29 | SPI_TFT_ILI9341ext |
king33jp | 0:7db6d9893ccb | 30 | { |
king33jp | 0:7db6d9893ccb | 31 | public: |
king33jp | 0:7db6d9893ccb | 32 | /** create a TFT with touch object connected to the pins: |
king33jp | 0:7db6d9893ccb | 33 | * |
king33jp | 0:7db6d9893ccb | 34 | * @param pin xp resistiv touch x+ |
king33jp | 0:7db6d9893ccb | 35 | * @param pin xm resistiv touch x- |
king33jp | 0:7db6d9893ccb | 36 | * @param pin yp resistiv touch y+ |
king33jp | 0:7db6d9893ccb | 37 | * @param pin ym resistiv touch y- |
king33jp | 0:7db6d9893ccb | 38 | * @param mosi,miso,sclk SPI connection to TFT |
king33jp | 0:7db6d9893ccb | 39 | * @param cs pin connected to CS of display |
king33jp | 0:7db6d9893ccb | 40 | * @param rs pin connected to RS(DC) of display |
king33jp | 0:7db6d9893ccb | 41 | * @param reset pin connected to RESET of display |
king33jp | 0:7db6d9893ccb | 42 | * @param backlight pin connected to bkl of display |
king33jp | 0:7db6d9893ccb | 43 | * ( You must drive N-MOSFET.pin is connected to NMOS gate terminal.) |
king33jp | 0:7db6d9893ccb | 44 | * @param sdcard_cs pin connected to CS of sdcard |
king33jp | 0:7db6d9893ccb | 45 | * based on my SPI_TFT lib |
king33jp | 0:7db6d9893ccb | 46 | */ |
king33jp | 0:7db6d9893ccb | 47 | SX032QVGA008(PinName xp, PinName xm, PinName yp, PinName ym, |
king33jp | 0:7db6d9893ccb | 48 | PinName mosi, PinName miso, PinName sclk, |
king33jp | 0:7db6d9893ccb | 49 | PinName csTft, PinName dcTft, PinName resTft, PinName blTft, |
king33jp | 0:7db6d9893ccb | 50 | PinName csSd); |
king33jp | 0:7db6d9893ccb | 51 | |
king33jp | 0:7db6d9893ccb | 52 | /** Backlight PWM controll |
king33jp | 0:7db6d9893ccb | 53 | * |
king33jp | 0:7db6d9893ccb | 54 | * @param duty is PWM duty (0 - 1.0) |
king33jp | 0:7db6d9893ccb | 55 | * period is 0.01 fixed. |
king33jp | 0:7db6d9893ccb | 56 | */ |
king33jp | 0:7db6d9893ccb | 57 | void setBacklight(float duty); |
king33jp | 0:7db6d9893ccb | 58 | |
king33jp | 0:7db6d9893ccb | 59 | /** calibrate the touch display |
king33jp | 0:7db6d9893ccb | 60 | * |
king33jp | 0:7db6d9893ccb | 61 | * User is asked to touch on two points on the screen |
king33jp | 0:7db6d9893ccb | 62 | */ |
king33jp | 0:7db6d9893ccb | 63 | void calibrate(void); |
king33jp | 0:7db6d9893ccb | 64 | |
king33jp | 0:7db6d9893ccb | 65 | /** read x and y coord on screen |
king33jp | 0:7db6d9893ccb | 66 | * |
king33jp | 0:7db6d9893ccb | 67 | * @returns point(x,y) |
king33jp | 0:7db6d9893ccb | 68 | */ |
king33jp | 0:7db6d9893ccb | 69 | bool |
king33jp | 0:7db6d9893ccb | 70 | getPixel(point& p); |
king33jp | 0:7db6d9893ccb | 71 | |
king33jp | 0:7db6d9893ccb | 72 | /** calculate coord on screen |
king33jp | 0:7db6d9893ccb | 73 | * |
king33jp | 0:7db6d9893ccb | 74 | * @param a_point point(analog x, analog y) |
king33jp | 0:7db6d9893ccb | 75 | * @returns point(pixel x, pixel y) |
king33jp | 0:7db6d9893ccb | 76 | * |
king33jp | 0:7db6d9893ccb | 77 | */ |
king33jp | 0:7db6d9893ccb | 78 | point toPixel(point p); |
king33jp | 0:7db6d9893ccb | 79 | |
king33jp | 0:7db6d9893ccb | 80 | protected: |
king33jp | 0:7db6d9893ccb | 81 | PinName _xm; |
king33jp | 0:7db6d9893ccb | 82 | PinName _ym; |
king33jp | 0:7db6d9893ccb | 83 | PinName _xp; |
king33jp | 0:7db6d9893ccb | 84 | PinName _yp; |
king33jp | 0:7db6d9893ccb | 85 | PwmOut bl; |
king33jp | 0:7db6d9893ccb | 86 | |
king33jp | 0:7db6d9893ccb | 87 | typedef enum { YES, MAYBE, NO } TOUCH; |
king33jp | 0:7db6d9893ccb | 88 | TOUCH getTouch(point& p); |
king33jp | 0:7db6d9893ccb | 89 | int readTouch(PinName p, PinName m, PinName a, PinName i); |
king33jp | 0:7db6d9893ccb | 90 | |
king33jp | 0:7db6d9893ccb | 91 | int x_off,y_off; |
king33jp | 0:7db6d9893ccb | 92 | int pp_tx,pp_ty; |
king33jp | 0:7db6d9893ccb | 93 | }; |
king33jp | 0:7db6d9893ccb | 94 | |
king33jp | 0:7db6d9893ccb | 95 | #endif |