Code written by Paul Rabbat, Angel Daruna, Jarel Hawkins, and Cordel Williams

Dependencies:   4DGL-uLCD-SE EthernetInterface HTTPClient NTPClient PinDetect SDFileSystem mbed-rpc mbed-rtos mbed wave_player

Fork of ECE4180_FinalProject by Angel Daruna

Revision:
7:b0f2169bdf48
Parent:
6:24d42cae48ad
Child:
8:548f413118e9
--- a/main.cpp	Mon Dec 01 21:16:17 2014 +0000
+++ b/main.cpp	Tue Dec 02 14:18:16 2014 +0000
@@ -64,6 +64,9 @@
 void getTime();
 void parseResults();
 char buf[3000];
+string weatherCondition = "";
+string lowTemperature = "";
+string highTemperature = "";
 
 int main() {
     dim = -1.0;
@@ -110,7 +113,7 @@
     // main program only sets dimmer level (dim)
     // interrupt routines dim the light
 
-    //Thread t1(thread_server); //start thread_server
+    Thread t1(thread_server); //start thread_server
     Thread t2(thread_display);
     Thread t3(thread_alarm);
     
@@ -144,22 +147,36 @@
 void parseResults(){
     printf("Starting parser\n");
     SP_XmlDomParser parser;    
+    int i=0;
+    //printf("\n----------%s----------\n",buf);
+    char* chars_array = strtok(buf, "\"");
+    while(chars_array)
+    {
+        //printf("%d: %s\n", i, chars_array);
+        
+        if(i==63){
+            lowTemperature = chars_array;
+            printf("Low temp: %s F\n", lowTemperature);
+        }
+        else if(i==65){
+            highTemperature = chars_array;
+            printf("Low temp: %s F\n", highTemperature);
+        }
+        else if (i==67){
+            weatherCondition = chars_array;
+            printf("Weather: %s\n", weatherCondition);
+        }
+        
+        i++;
+        chars_array = strtok(NULL, "\"");
+    }
     
-    printf("\n----------%s----------\n",buf);
     
-    parser.append( buf, strlen(buf)); // stream current buffer data to the XML parser
+    /*parser.append( buf, strlen(buf)); // stream current buffer data to the XML parser
     printf("Parser appended\n");    
 
+    
     SP_XmlHandle rootHandle( parser.getDocument()->getRootElement() );
-
-    /*        
-    SP_XmlCDataNode * title = rootHandle.getChild( "channel" ).getChild("title").getChild(0).toCData();
-    printf("\r\n === Title:%s === \r\n",title->getText());
-    SP_XmlCDataNode * title1 = rootHandle.getChild( "channel" ).getChild("image").getChild("title").getChild(0).toCData();
-    printf("\r\n === Title:%s === \r\n",title1->getText());
-    SP_XmlCDataNode * title2 = rootHandle.getChild( "channel" ).getChild("item").getChild("title").getChild(0).toCData();
-    printf("\r\n === Title:%s === \r\n",title2->getText());
-    */
     
     SP_XmlElementNode * location = rootHandle.getChild( "channel" ).getChild( "yweather:location" ).toElement();
     if (location) {
@@ -180,7 +197,7 @@
         printf("\r\n ----- Date:%s(%s) ----- \r\n",forecast->getAttrValue("date"),forecast->getAttrValue("day"));        
         printf("Condition:%s \n",forecast->getAttrValue("text"));
         printf("Temp:Low%sF High%sF\n",forecast->getAttrValue("low"),forecast->getAttrValue("high"));
-    }      
+    }      */
     
     printf("Parser complete!\n");
 }
@@ -268,10 +285,12 @@
             chars_array = strtok(NULL, " :");
         }
         
-        uLCD.printf("    %s, %s %s\n    %02d:%02d:%02d %s", dayOfWeek, month, dayNum, hour, minute, sec, ampm);
+        uLCD.printf("    %s, %s %s\n    %02d:%02d:%02d %s\n", dayOfWeek, month, dayNum, hour, minute, sec, ampm);
+        uLCD.color(BLUE);
+        uLCD.printf("    Low: %s F\n    High: %s F\n    Weather:\n  %s\n", lowTemperature, highTemperature, weatherCondition);
         if(_alarm.alarmSet){
             uLCD.color(GREEN);
-            if(_alarm.minutes < 10){ uLCD.printf("\n\n    Alarm:\n    %d:0%d %s", _alarm.hours, _alarm.minutes, _alarm.amPm); }
+            if(_alarm.minutes < 10){ uLCD.printf("    Alarm:\n    %d:0%d %s", _alarm.hours, _alarm.minutes, _alarm.amPm); }
             else{ uLCD.printf("\n\n    Alarm:\n    %d:%d %s", _alarm.hours, _alarm.minutes, _alarm.amPm); }
         }