Use SD card from Aitendo TFT 2.2 display.

Dependencies:   SDFileSystem mbed ILI9340_Driver_Lib

Fork of Seeed_SDCard_Shield by Shields

Files at this revision

API Documentation at this revision

Comitter:
ImageWriter
Date:
Sun Apr 12 13:54:20 2015 +0000
Parent:
7:161ee1b5617b
Commit message:
Bug fix

Changed in this revision

ILI9340_Driver_Lib.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 161ee1b5617b -r a81a5af65446 ILI9340_Driver_Lib.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ILI9340_Driver_Lib.lib	Sun Apr 12 13:54:20 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dextorslabs/code/ILI9340_Driver_Lib/#216d35e347b8
diff -r 161ee1b5617b -r a81a5af65446 main.cpp
--- a/main.cpp	Sun Apr 12 13:16:05 2015 +0000
+++ b/main.cpp	Sun Apr 12 13:54:20 2015 +0000
@@ -4,27 +4,28 @@
 #include "SDFileSystem.h"
 #include "ILI9340_Driver.h"
 
-Serial pc(USBTX, USBRX);
-SDFileSystem sd(D11, D12, D13, D10, "sd"); // MOSI, MISO, SCK, CS
-FILE *fp;
+Serial pc(USBTX, USBRX);                    // Use Serial interface
+SDFileSystem sd(D11, D12, D13, D10, "sd");  // MOSI, MISO, SCK, CS
+FILE *fp;                                   // File pointer declear
 
 int main() {
 
     // create the display object
     // Nucleo-F411RE to M-TM022-SPI(Aitendo) connection.
-    // 2014.12.30 ImageWriter
+    // 2015.4.12 ImageWriter
     // ------------------------------------------------
-    // [Nucleo]     [M-TM022-SPI]
-    // (D2)     --- Reset;
-    // (D4)     --- CS;
-    // (D7)     --- D/C;
-    // (D13)    --- CLK;
-    // (D11)    --- MOSI;
-    // (D12)    --- MISO;
+    // [Nucleo]     [M-TM022-SPI_TFT]   [M-TM022-SPI-SD]                
+    // (D2)     --- Reset
+    // (D4)     --- CS
+    // (D7)     --- D/C
+    // (D13)    --- CLK  --------------- SD_SCK
+    // (D11)    --- MOSI --------------- SD_MOSI
+    // (D12)    --- MISO --------------- SD_MISO
+    // (D10)    ------------------------ SD_CS
     // (3V3)    --- VCC;
-    // (3V3)    -R- LED; (R=220 to 330 ohm)
+    // (3V3)    -R- LED; (330ohm)
     // (GND)    --- GND
-    // (A1)     --- LM35DZ (IC tempture sensor 10mV/deg C )
+    // (A1)     --- LM35DZ
     
     ILI9340_Display myTft = ILI9340_Display(D11, D12, D13, D4, D2, D7);
 
@@ -38,15 +39,15 @@
     myTft.FillScreen(ILI9340_WHITE);
 
     // set up variables
-    char roomTemptureString[] = "0000";
-    char roomTemptureString_old[] = "0000";
+    char roomTemptureString[] = "0000";     // Display charactor
+    char roomTemptureString_old[] = "0000"; // For Erace old charactor
     int  roomTempture;                      // Room Tempture * 100
     long realTempture;                      // For calucrate
-    int  xx = 1;
+    int  xx = 1;                            // Line graph x axis
     
     while(true) {
         realTempture = 0;
-        for(int i=0;i<1000;i++){
+        for(int i=0;i<1000;i++){            // For averaging.
             realTempture += myA1.read_u16()*33000/65535; // realTemp = 3300mv * 10 / 0xFFFF 
             }
         realTempture = realTempture/1000;    
@@ -72,7 +73,7 @@
         myTft.DrawAscii(roomTemptureString[3],90, 50,3,ILI9340_BLACK);
         myTft.DrawString("deg C"             ,110,50,3,ILI9340_BLACK);
 
-        // xx counter
+        // xx axis counter
         if(xx > 239){
             xx=1;
             }else{
@@ -94,16 +95,16 @@
         // cursor
         myTft.DrawLine(xx,319,xx,309,ILI9340_BLACK);
         
-        // logger
-        fp = fopen("/sd/mylogger.txt", "a+");
-        if (fp == NULL) {
+        // SD card logger
+        fp = fopen("/sd/mylogger.txt", "a");            // File open for "a"ppend
+        if (fp == NULL) {                               // Error!
             pc.printf("Unable to write the file\r\n");
         } else {
-            pc.printf("%d \r\n",roomTempture);
-            fprintf(fp, "%d \r\n",roomTempture);
+            pc.printf("%d \r\n",roomTempture);          // Append data to SD card.
+            fprintf(fp, "%d \r\n",roomTempture);        // Serial monitor.
         }
-        fclose(fp);
-        //pc.printf("File successfully written!\r\n");
+        fclose(fp);                                     // Cloce file.
+        pc.printf("File successfully written!\r\n");    // Serial monitor.
 
         
         wait(10);