Modified to work with two displays

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 mbed

Fork of touch by Peter Drescher

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: /media/uploads/TickTock/lcdsch.jpg /media/uploads/TickTock/_scaled_spi_tftx2.jpg

Files at this revision

API Documentation at this revision

Comitter:
TickTock
Date:
Sun Feb 03 15:22:53 2013 +0000
Parent:
2:9d80fd43a008
Child:
4:decb7d475a05
Commit message:
Modified to work with two displays

Changed in this revision

SPI_TFT.lib Show diff for this revision Revisions of this file
SPI_TFTx2.lib Show annotated file Show diff for this revision Revisions of this file
TFT_fonts.lib Show annotated file Show diff for this revision Revisions of this file
TOUCH_TFTx2.lib Show annotated file Show diff for this revision Revisions of this file
Touch_tft.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/SPI_TFT.lib	Sun Sep 04 21:49:22 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/dreschpe/code/SPI_TFT/#4781bb8eed45
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI_TFTx2.lib	Sun Feb 03 15:22:53 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dreschpe/code/SPI_TFT/#a71243b666f9
--- a/TFT_fonts.lib	Sun Sep 04 21:49:22 2011 +0000
+++ b/TFT_fonts.lib	Sun Feb 03 15:22:53 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/dreschpe/code/TFT_fonts/#31ce4466ecdf
+http://mbed.org/users/dreschpe/code/TFT_fonts/#419d21bfc20c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TOUCH_TFTx2.lib	Sun Feb 03 15:22:53 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dreschpe/code/Touch_tft/#3db7309b6146
--- a/Touch_tft.lib	Sun Sep 04 21:49:22 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/dreschpe/code/Touch_tft/#ef7972c29c0e
--- 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;
                 }