micro paint to show the touchscreen and tft handling

Dependencies:   mbed Touch_tft TFT_fonts_old

Dependents:   touch_piirto

Files at this revision

API Documentation at this revision

Comitter:
dreschpe
Date:
Thu Jul 14 21:50:48 2011 +0000
Child:
1:d03155bfc252
Commit message:
1.0

Changed in this revision

SPI_TFT.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_tft.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPI_TFT.lib	Thu Jul 14 21:50:48 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dreschpe/code/SPI_TFT/#b2dd49f04d5d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TFT_fonts.lib	Thu Jul 14 21:50:48 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dreschpe/code/TFT_fonts/#d4d8df7e30d8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Touch_tft.lib	Thu Jul 14 21:50:48 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dreschpe/code/Touch_tft/#1745fdf054b5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jul 14 21:50:48 2011 +0000
@@ -0,0 +1,99 @@
+#include "mbed.h"
+#include "SPI_TFT.h"
+#include "Arial12x12.h"
+#include "Arial28x28.h"
+#include "touch_tft.h"
+
+
+// the TFT is connected to SPI pin 5-7
+// the touch is connected to 19,20,16,17
+
+touch_tft tt(p19,p20,p16,p17,p5, p6, p7, p8, p15,"TFT"); // x+,x-,y+,y-,mosi, miso, sclk, cs, reset
+
+int main() {
+
+    unsigned short color = White;
+    unsigned int brush = 2;
+    point p;
+
+    tt.claim(stdout);        // send stdout to the TFT display
+    tt.background(Black);    // set background to black
+    tt.foreground(White);    // set chars to white
+    tt.cls();                // clear the screen
+    tt.set_font((unsigned char*) Arial12x12);  // select the font
+    tt.set_orientation(1);
+
+    tt.calibrate();          // calibrate the touch
+    tt.locate(0,0);
+    printf(" x = ");
+    tt.locate(0,1);
+    printf(" y = ");
+    tt.line(0,25,319,25,White);
+    // the color chosing fields
+    tt.fillrect(80,0,98,24,White);
+    tt.fillrect(100,0,118,24,Green);
+    tt.fillrect(120,0,138,24,Red);
+    tt.fillrect(140,0,158,24,Blue);
+    tt.line(179,0,179,24,White);
+    // the brushes
+    tt.fillcircle(190,12,2,White);
+    tt.fillcircle(210,12,4,White);
+    tt.fillcircle(230,12,6,White);
+    tt.fillcircle(250,12,brush,color);
+    while (1) {
+
+        p = tt.get_touch();
+        if (tt.is_touched(p)) {  // touch
+            p = tt.to_pixel(p);          // convert to pixel pos
+            if (p.y < 26) {        // a button field
+                if (p.x > 80 && p.x < 100) {  // White
+                    color = White;
+                }
+                if (p.x > 100 && p.x < 120) {  // Green
+                    color = Green;
+                }
+                if (p.x > 120 && p.x < 140) {  // Red
+                    color = Red;
+                }
+                if (p.x > 140 && p.x < 160) {  // Blue
+                    color = Blue;
+                }
+                if (p.x > 160 && p.x < 180) {  // Black
+                    color = Black;
+                }
+                if (p.x > 180 && p.x < 200) {  // brush 2
+                    brush = 2;
+                }
+                if (p.x > 200 && p.x < 220) {  // brush 4
+                    brush = 4;
+                }
+                if (p.x > 220 && p.x < 240) {  // brush 6
+                    brush = 6;
+                }
+                if (color != Black) {
+                    tt.fillrect(240,0,260,24,Black);
+                } else {
+                    tt.fillrect(240,0,260,24,White);
+                }
+                tt.fillcircle(250,12,brush,color);
+                if (p.x > 300) {
+                    tt.fillrect(0,26,319,239,Black);
+                }
+                
+
+            } else {
+                
+                tt.locate(3,0);
+                printf("%3d",p.x);
+                tt.locate(3,1);
+                printf("%3d",p.y);
+            }
+        }
+
+    }
+
+}
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jul 14 21:50:48 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912