a

Dependencies:   HTTPClient SeeedStudioTFTv2 TFT_fonts WIZnet_Library mbed

Fork of Seeed_TFT_Touch_Shield by Shields

Files at this revision

API Documentation at this revision

Comitter:
bangbh
Date:
Sat Aug 15 05:12:06 2015 +0000
Parent:
4:e98910e480b4
Commit message:
a

Changed in this revision

HTTPClient.lib Show annotated file Show diff for this revision Revisions of this file
SeeedStudioTFTv2.lib Show annotated file Show diff for this revision Revisions of this file
WIZnet_Library.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 e98910e480b4 -r 9fc620b1378a HTTPClient.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient.lib	Sat Aug 15 05:12:06 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/donatien/code/HTTPClient/#277279a1891e
diff -r e98910e480b4 -r 9fc620b1378a SeeedStudioTFTv2.lib
--- a/SeeedStudioTFTv2.lib	Fri Feb 13 09:39:48 2015 +0000
+++ b/SeeedStudioTFTv2.lib	Sat Aug 15 05:12:06 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/components/code/SeeedStudioTFTv2/#362765fdf287
+https://developer.mbed.org/users/bangbh/code/SeeedStudioTFTv2/#2b2929d22714
diff -r e98910e480b4 -r 9fc620b1378a WIZnet_Library.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIZnet_Library.lib	Sat Aug 15 05:12:06 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/WIZnet/code/WIZnet_Library/#ca8405b9564d
diff -r e98910e480b4 -r 9fc620b1378a main.cpp
--- a/main.cpp	Fri Feb 13 09:39:48 2015 +0000
+++ b/main.cpp	Sat Aug 15 05:12:06 2015 +0000
@@ -19,14 +19,37 @@
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
-
+/*include library*/
+//mbed library
 #include "mbed.h"
+
+//HW W5500 library
+#include "WIZnetInterface.h"
+
+//HW Touch lcd library
 #include "SeeedStudioTFTv2.h"
+
+//HW&SW SDFilsystem library
+#include "SDFileSystem.h"
+SDFileSystem sd(D11,D12,D13,D4, "sd");
+
+//SW Font library
 #include "Arial12x12.h"
 #include "Arial24x23.h"
 #include "Arial28x28.h"
 #include "font_big.h"
 
+//SW HTTPClient library
+#include "HTTPClient.h"
+
+/*Port define and initialize*/
+
+//Define W5500 port and initialization
+SPI spi(D11,D12,D13);
+WIZnetInterface ethernet(&spi,D10,D0);
+
+
+//Define TFT LCD port and initialization
 #define PIN_XP          A3
 #define PIN_XM          A1
 #define PIN_YP          A2
@@ -38,63 +61,107 @@
 #define PIN_DC_TFT      D6
 #define PIN_BL_TFT      D7
 #define PIN_CS_SD       D4
+SeeedStudioTFTv2 TFT(PIN_XP, PIN_XM, PIN_YP, PIN_YM, PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TFT, PIN_DC_TFT, PIN_BL_TFT, PIN_CS_SD);
 
-SeeedStudioTFTv2 TFT(PIN_XP, PIN_XM, PIN_YP, PIN_YM, PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TFT, PIN_DC_TFT, PIN_BL_TFT, PIN_CS_SD);
+//UART to USB initialization for debug message
+Serial pc(USBTX, USBRX);
+
+//Ethernet information pre definition
+const char * IP_Addr    = "222.98.173.249";
+const char * IP_Subnet  = "255.255.255.192";
+const char * IP_Gateway = "222.98.173.254";
+unsigned char MAC_Addr[6] = {0x00,0x08,0xDC,0x12,0x34,0x56};
 
 int main()
 {
+    //Set baudrate of "U2U"
+    pc.baud(115200);
+
     //Configure the display driver
     TFT.background(Black);
     TFT.foreground(White);
     TFT.cls();
-
-    //Print a welcome message
+  
+    //Application Start message
     TFT.set_font((unsigned char*) Arial12x12);
     TFT.locate(0,0);
-    TFT.printf("Hello Mbed");
-
-    //Wait for 5 seconds
-    wait(5.0);
-
-    //Draw some graphics
-    TFT.cls();
-    TFT.set_font((unsigned char*) Arial24x23);
-    TFT.locate(100,100);
-    TFT.printf("Graphic");
-
-    TFT.line(0,0,100,0,Green);
-    TFT.line(0,0,0,200,Green);
-    TFT.line(0,0,100,200,Green);
-
-    TFT.rect(100,50,150,100,Red);
-    TFT.fillrect(180,25,220,70,Blue);
-
-    TFT.circle(80,150,33,White);
-    TFT.fillcircle(160,190,20,Yellow);
+    TFT.printf(" Application Start.\n");
+    //Ethernet configuration
+    mbed_mac_address((char *)MAC_Addr);
+    int ret = ethernet.init(MAC_Addr,IP_Addr,IP_Subnet,IP_Gateway);
+    if (!ret) {
+        TFT.printf(" Ethernet Initialized\n MAC: %s\n", ethernet.getMACAddress());
+        ret = ethernet.connect();
+        if (!ret) {
+            TFT.printf(" IP: %s\r\n MASK: %s\r\n GW: %s\r\n",
+                      ethernet.getIPAddress(), ethernet.getNetworkMask(), ethernet.getGateway());
+        } else {
+            TFT.printf(" Error ethernet.connect() - ret = %d\r\n", ret);
+            exit(0);
+        }
+    } else {
+        TFT.printf(" Error ethernet.init() - ret = %d\r\n", ret);
+        exit(0);
+    }
+    wait(0.5);
 
-    double s;
-    for (int i = 0; i < 320; i++) {
-        s = 20 * sin((long double)i / 10);
-        TFT.pixel(i, 100 + (int)s, Red);
-    }
-
-    //Wait for 5 seconds
-    wait(5.0);
-
-    //Multiple fonts
-    TFT.foreground(White);
-    TFT.background(Blue);
+    //HTTPClient http;
+//    
+//    char str[8192];
+//    char get_msg[256]= "";
+//
+//    sprintf(get_msg,"http://www.kma.go.kr/wid/queryDFS.jsp?gridx=59&gridy=127");
+//    
+//    ret = http.get(get_msg, str, sizeof(str),0);
+//    
+//    if(ret == HTTP_OK)
+//    {
+//        TFT.printf(" HTTP_OK\r\n");
+//    }
+//    else
+//    {
+//        TFT.printf("error code: %d\r\n",ret);
+//    }
+//    char *startAddr;
+//    startAddr = strstr(str,"<tm>");
+//    if(startAddr == 0)
+//    {
+//        TFT.printf("There is no data.\r\n");
+//    }
+//    else
+//    {
+//        strncpy(get_msg,startAddr+4,12);
+//        *(get_msg+12) = 0;
+//        TFT.printf("%s",get_msg);
+//    }
     TFT.cls();
-    TFT.set_font((unsigned char*) Arial24x23);
-    TFT.locate(0,0);
-    TFT.printf("Different Fonts:");
-    TFT.set_font((unsigned char*) Neu42x35);
-    TFT.locate(0,30);
-    TFT.printf("Hello Mbed 1");
-    TFT.set_font((unsigned char*) Arial24x23);
-    TFT.locate(20,80);
-    TFT.printf("Hello Mbed 2");
-    TFT.set_font((unsigned char*) Arial12x12);
-    TFT.locate(35,120);
-    TFT.printf("Hello Mbed 3");
+    FILE *fp;
+    fp = fopen("/sd/Weather_Icons_02.bmp","r");
+    fseek(fp, 0, SEEK_SET);
+    TFT.BMP_16(100,100,fp);
+    printf("1234567890");
+    while(1)
+    {
+    }
+    //point p;
+//    
+//    while(1)
+//    {
+//      TFT.getPixel(p);
+//      TFT.locate(0,100);
+//      TFT.printf("X: %6d, Y: %6d",p.x,p.y);
+//    }
+      //  TFT.printf("msg : %s\r\n",get_msg);
+//        if(!ret)
+//        {
+//          TFT.printf("\r\nPage fetched successfully - read %d characters\r\n", strlen(str));
+//          TFT.printf("Result: %s\r\n", str);
+//        }
+//        else
+//        {
+//          TFT.printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
+//        }
+//        wait(20);
+//    }
+        
 }