sd card and tft

Dependencies:   MMA8451Q SDFileSystem SPI_TFT_ILI9341 TFT_fonts mbed

Fork of TFT_test_frdm-kl25z by Motoo Tanaka

Files at this revision

API Documentation at this revision

Comitter:
dhivya12
Date:
Tue Nov 25 09:13:55 2014 +0000
Parent:
2:4b85d308f1ef
Commit message:
tft and sd card

Changed in this revision

SDFileSystem.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
diff -r 4b85d308f1ef -r 955860740bd0 SDFileSystem.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Tue Nov 25 09:13:55 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/SDFileSystem/#7b35d1709458
diff -r 4b85d308f1ef -r 955860740bd0 main.cpp
--- a/main.cpp	Fri Oct 31 01:43:18 2014 +0000
+++ b/main.cpp	Tue Nov 25 09:13:55 2014 +0000
@@ -29,6 +29,9 @@
 #include "Arial28x28.h"
 #include "font_big.h"
 
+#include "SDFileSystem.h"
+
+
 
 #define PIN_XP          PTB3
 #define PIN_XM          PTB1
@@ -51,6 +54,8 @@
 SPI_TFT_ILI9341 TFT(PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TFT, PIN_BL_TFT, PIN_DC_TFT) ;
 SPI_STMPE610 TSC(PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TSC) ;
 
+SDFileSystem sd(PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_SD,"sd");
+
 DigitalOut backlight(PTA12) ;
 DigitalIn pinD7(PTC9) ;
 
@@ -101,6 +106,42 @@
     backlight = 1 ;
 }
 
+
+
+void screen4(void) // Welcome Screen
+{
+  
+    backlight = 0 ;
+    TFT.background(White) ;
+    TFT.cls() ;
+    wait(0.1) ;
+    TFT.set_font((unsigned char*) Arial24x23);
+    TFT.foreground(Red) ;
+    TFT.locate(10, 40) ;
+     TFT.printf("Hello World");   
+ 
+    mkdir("/sd/mydir", 0777);
+    
+    FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
+    if(fp == NULL) {
+        error("Could not open file for write\n");
+    }
+    fprintf(fp, "Hello fun SD Card World!");
+    fclose(fp); 
+ 
+    
+    
+    
+    TFT.foreground(Blue);
+    TFT.locate(0, 80) ;
+    TFT.printf("Goodbye World");
+
+}
+
+
+
+
+
 void screen2(void) // Graphics
 {
     //Draw some graphics
@@ -231,7 +272,7 @@
         prev[1] = data[1] ;
         prev[2] = data[2] ;
         pt = t ;
-        wait(0.01) ;
+        wait(0.1) ;
     }
 }
 
@@ -253,54 +294,18 @@
     
 int main()
 {
-    uint16_t x, y, z ;
-    int prevPage = 0 ;
+  //  uint16_t x, y, z ;
+ //   int prevPage = 0 ;
     
     acc = new MMA8451Q(PTE25, PTE24, MMA8451_I2C_ADDRESS) ;
     
     initTFT() ;
     
-    screen1() ;
-        
-    printf("Program Started!\n\r") ;
+    while(1)
+    {
+     screen4(); 
+     wait(10);
+        }
+   
     
-    for(;;) {
-//        printf("TFT width = %d, height = %d\n\r", TFT.width(), TFT.height()) ;
-        switch(page) {
-        case 0:
-            if (prevPage != page) {
-                screen1() ;
-            }
-            break ;
-        case 1:
-            if (prevPage != page) {
-                screen2() ; 
-            }
-            break ;
-        case 2:
-            if (prevPage != page) {
-                TFT.background(Black) ;
-                TFT.foreground(White) ;
-                TFT.cls() ;
-            }
-            screen3() ; 
-            wait(2) ;
-            break ;
-        default:
-            page = 0 ; 
-            break ;
-        }
-        prevPage = page ;
-        printf("Screen Printed\n\r") ;
-
-        TSC.getRAWPoint(&x, &y, &z) ;
-        if ((x != 0)||(y != 0) || (z != 0)) {
-            if (x < 1000) { // left
-                decPage() ;
-            } else if (x > 3000) { // right
-                incPage() ;
-            }
-        }
-//        wait(1) ;
-    }
-}
+ }