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:
10:89cd9b6a251e
Parent:
9:add6ce18f1b7
Child:
12:a99989062fee
--- a/main.cpp	Wed Dec 03 17:59:07 2014 +0000
+++ b/main.cpp	Sat Dec 06 22:42:53 2014 +0000
@@ -15,6 +15,7 @@
 #include "RPCType.h"
 #include "alarmContainer.h"
 #include "wave_player.h"
+#include "HTTPClient.h"
 
 // Defines
 #define SERVER_PORT 80 //HTTPSERVER
@@ -39,6 +40,9 @@
 FILE *wave_file;
 string filepath = "/sd/mymusic/";
 
+string weatherCondition = "";
+string lowTemperature = "";
+string highTemperature = "";
 
 volatile bool t = true;
 volatile bool play = true;
@@ -49,7 +53,6 @@
 int num = 0;
 vector<string> filenames; //filenames are stored in a vector string
 
-
 // pin for ZeroCross tail input
 // An external 1K pullup required
 InterruptIn zerocross(p22);
@@ -75,7 +78,6 @@
 void snooze_hit_callback(void);
 void read_file_names(char *dir);
 void play_wake_up(void);
-
 void thread_server(void const *args);
 void thread_display(void const *args);
 void thread_alarm(void const *args);
@@ -83,15 +85,9 @@
 void dimmer();
 void turn_on();
 void getAndParseWeather();
-
-/** Weather **/
-#include "HTTPClient.h"
 char* getWeather();
 void getTime();
 void parseResults(char*);
-string weatherCondition = "";
-string lowTemperature = "";
-string highTemperature = "";
 
 int main() {
     snooze.mode(PullUp);
@@ -302,7 +298,6 @@
                     break; 
                 case 6:
                     ampm = chars_array;
-                    ampm = "PM";
                     break;
             }
             i++;
@@ -413,38 +408,37 @@
 }
 
 void play_wake_up(void){
-            while(t == true) {
-                printf("Started playing.");
-                if ((insert == true) && (play ==true)) {
-                        waver.play(wave_file, &play);
-                       if (feof(wave_file)) // when playback ends file will close and play will equal false
-                        {
-                        fclose(wave_file);
-                        printf("Wav ended.");
-                        } 
-                         
-                    }
-                if ((insert == false)&&(play == true)) {
-                    // generate a 500Hz tone using PWM hardware output
-                    for (int j=0; j<26; j=j+2) {
-                        alarm.period(1.0/500.0); // 500hz period
-                        alarm =vol; //50% duty cycle - max volume
-                        wait(.5);
-                        alarm.period(0.0/500.0);
-                        wait(.5);
-                        } // end of for
-                
-                    // two tone police siren effect -  two periods or two frequencies
-                    // increase volume - by changing the PWM duty cycle
-                    for (int i=0; i<26; i=i+2) {
-                        alarm = vol;
-                        alarm.period(1.0/969.0);
-                        wait(.5);
-                        alarm.period(1.0/800.0);
-                        wait(.5);
-                    } 
+    while(t == true) {
+        printf("Started playing.");
+        if ((insert == true) && (play ==true)) {
+                waver.play(wave_file, &play);
+               if (feof(wave_file)) // when playback ends file will close and play will equal false
+                {
+                fclose(wave_file);
+                printf("Wav ended.");
                 } 
-        
+                 
             }
-            alarm = 0.0;
+        if ((insert == false)&&(play == true)) {
+            // generate a 500Hz tone using PWM hardware output
+            for (int j=0; j<26; j=j+2) {
+                alarm.period(1.0/500.0); // 500hz period
+                alarm =vol; //50% duty cycle - max volume
+                wait(.5);
+                alarm.period(0.0/500.0);
+                wait(.5);
+                } // end of for
+        
+            // two tone police siren effect -  two periods or two frequencies
+            // increase volume - by changing the PWM duty cycle
+            for (int i=0; i<26; i=i+2) {
+                alarm = vol;
+                alarm.period(1.0/969.0);
+                wait(.5);
+                alarm.period(1.0/800.0);
+                wait(.5);
+            } 
+        } 
+    }
+    alarm = 0.0;
 }
\ No newline at end of file