Modified to work with two displays
Dependencies: SPI_TFTx2 TFT_fonts TOUCH_TFTx2 mbed
Fork of touch by
Based on original code by Peter Dreshner at http://mbed.org/users/dreschpe/notebook/micro-paint/
Uses two LCD panels connected as per the following schematic:
Diff: main.cpp
- Revision:
- 3:0fcd8a846111
- Parent:
- 2:9d80fd43a008
- Child:
- 5:f5c67520d147
--- a/main.cpp Sun Sep 04 21:49:22 2011 +0000 +++ b/main.cpp Sun Feb 03 15:22:53 2013 +0000 @@ -1,29 +1,32 @@ #include "mbed.h" -#include "SPI_TFT.h" +#include "SPI_TFTx2.h" #include "Arial12x12.h" #include "Arial28x28.h" -#include "touch_tft.h" +#include "TOUCH_TFTx2.h" -// the TFT is connected to SPI pin 5-7 -// the touch is connected to 19,20,16,17 +// the TFT is connected to SPI pin p11,p12,p13,{p14,p15},p16 +// the touch is connected to 17,18,19,20 -touch_tft tt(p19,p20,p16,p17,p11, p12, p13, p14, p15,"TFT"); // x+,x-,y+,y-,mosi, miso, sclk, cs, reset +TOUCH_TFTx2 tt(p17, p18, p19, p20, p11, p12, p13, p14, p15, p16, "TFT"); // x+,x-,y+,y-,mosi, miso, sclk, cs0, cs1, reset int main() { unsigned short color = White; unsigned int brush = 2; + unsigned int dsel = 1; point p; - + tt.set_display(2); // select both displays tt.claim(stdout); // send stdout to the TFT display tt.background(Black); // set background to black tt.foreground(White); // set chars to white + tt.set_display(2); // select both displays tt.cls(); // clear the screen tt.set_font((unsigned char*) Arial12x12); // select the font tt.set_orientation(1); + tt.set_display(dsel); // select display - tt.calibrate(); // calibrate the touch + tt.calibrate(); // calibrate the touch tt.locate(0,0); printf(" x = "); tt.locate(0,12); @@ -47,6 +50,14 @@ p = tt.to_pixel(p); // convert to pixel pos if (p.y < 26) { // a button field + if (p.x > 0 && p.x < 40) { // Swap screens + if (dsel == 0) { + dsel = 1; + } else { + dsel = 0; + } + tt.set_display(dsel); + } if (p.x > 80 && p.x < 100) { // White color = White; }