Basically i glued Peter Drescher and Simon Ford libs in a GraphicsDisplay class, then derived TFT or LCD class (which inherits Protocols class), then the most derived ones (Inits), which are per-display and are the only part needed to be adapted to diff hw.
Fork of UniGraphic by
Diff: TouchADS7843/readme.txt
- Revision:
- 22:62f3bed03503
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TouchADS7843/readme.txt Wed May 06 16:52:07 2015 +0000 @@ -0,0 +1,40 @@ +#include "mbed.h" +#include "ILI9341.h" +#include "Touch.h" + +ILI9341 TFT(SPI_16, 12000000, D11, D12, D13, D10, D9, D8, "TFT"); // Spi 16bit, 12MHz, mosi, miso, sclk, cs, reset, dc + +TouchScreenADS7843 TP(D11, D12, D13, D14, D15, &TFT); // ADS7843 -> mosi, miso, sclk, cs, irq, SPI_TFT + +int main() +{ + TFT.claim(stdout); + Matrix matrix; + Coordinate ScreenSample[3]; + TP.TouchPanel_Calibrate(); + TP.GetCalibration(&matrix, &ScreenSample[0]); + TP.SetCalibration(&matrix, &ScreenSample[0]); + for(;;) { + + if (!TP._tp_irq) { + if (TP.Read_Ads7843()) { + TP.getDisplayPoint() ; + TP.TP_DrawPoint(TP.display.x,TP.display.y, Blue); + TFT.locate(25,0); + printf("%03d",TP.display.x); + TFT.locate(95,0); + printf("%03d",TP.display.y); + // Touchscreen area is larger than LCD area. + // We use the bottom area outside the LCD area to clear the screen (y value > 320). + if (TP.display.y > 320) { + TFT.cls(); + TFT.locate(0,0); + printf(" X:"); + TFT.locate(70,0); + printf(" Y:"); + } + } + } + + } +} \ No newline at end of file