Dreamforce 2013 MiniHack Thermostat Challenge - remotes
Dependencies: C12832_lcd EthernetInterface-ansond-patched HTTPClient-thermostat-remotes LM75B MMA7660 SocketIO WebSocketClient-ThermostatDemo mbed-rtos mbed picojson
Fork of df-2013-minihack-thermostat-complete by
Revision 6:33f71cf9a04f, committed 2013-11-11
- Comitter:
- ansond
- Date:
- Mon Nov 11 22:46:25 2013 +0000
- Parent:
- 5:9866322ed225
- Commit message:
- updates
Changed in this revision
diff -r 9866322ed225 -r 33f71cf9a04f Thermostat-Location.h --- a/Thermostat-Location.h Mon Nov 11 20:29:32 2013 +0000 +++ b/Thermostat-Location.h Mon Nov 11 22:46:25 2013 +0000 @@ -30,7 +30,7 @@ this->m_longitude = longitudes[location_index]; this->display("Location: Latitude:%2.4f Longitude:%2.4f",this->m_latitude,this->m_longitude); - this->display_lcd("Location Coordinates\r\nLatitude: %2.4f\r\nLongitude: %2.4f",this->m_latitude,this->m_longitude); + this->display_lcd("Location Coordinates\r\nLatitude: %2.4f\r\nLongitude: %2.4f\r\nLocation: %s",this->m_latitude,this->m_longitude,lcd_locations[location_index]); } #endif // THERMOSTAT_LOCATION_H_ \ No newline at end of file
diff -r 9866322ed225 -r 33f71cf9a04f Thermostat.cpp --- a/Thermostat.cpp Mon Nov 11 20:29:32 2013 +0000 +++ b/Thermostat.cpp Mon Nov 11 22:46:25 2013 +0000 @@ -45,24 +45,27 @@ // DreamForce 2013 Tunables START // set our location -int location_index = 2; +int location_index = 0; // Remoted Thermostats -// Thermostat 1: Austin TX 30.2500 –97.7500 -// Thermostat 2: Phoenix AZ 33.4500 -112.0667 -// Thermostat 3: Dallas TX 32.7758 -96.7967 -// Thermostat 4: Miami FL 25.7877 -80.2241 -// Thermostat 5: Chicago IL 41.8819 –87.6278 -// Thermostat 6: Memphis TN 35.1174 -89.9711 -// Thermostat 7: Seattle WA 47.6097 –122.3331 -// Thermostat 8: New York NY 40.6700 –73.9400 -// Thermostat 9: Raleigh NC 35.8189 –78.6447 -// Thermostat 10: Moscone 37.7842 –122.4016 +// Thermostat 0: Austin TX 30.2500 –97.7500 +// Thermostat 1: Phoenix AZ 33.4500 -112.0667 +// Thermostat 2: Dallas TX 32.7758 -96.7967 +// Thermostat 3: Miami FL 25.7877 -80.2241 +// Thermostat 4: Chicago IL 41.8819 –87.6278 +// Thermostat 5: Memphis TN 35.1174 -89.9711 +// Thermostat 6: Seattle WA 47.6097 –122.3331 +// Thermostat 7: New York NY 40.6700 –73.9400 +// Thermostat 8: Raleigh NC 35.8189 –78.6447 +// Thermostat 9: Moscone 37.7842 –122.4016 float latitudes[10] = { 30.2500, 33.4500, 32.7758, 25.7877, 41.8819, 35.1174, 47.6097, 40.6700, 35.8189, 37.7842}; float longitudes[10] = { -97.7500, -112.0667, -96.7967, -80.2241, -87.6278, -89.9711, -122.3331, -73.9400, -78.6447, -122.4016}; char *locations[10] = { "DF Thermostat-Austin TX", "DF Thermostat-Phoenix AZ", "DF Thermostat-Dallas TX", "DF Thermostat-Miami FL", "DF Thermostat-Chicago IL", "DF Thermostat-Memphis TN", "DF Thermostat-Seattle WA", "DF Thermostat-New York NY", "DF Thermostat-Raleigh NC", "DF Thermostat-Moscone Center"}; +char *lcd_locations[10]= { "Austin TX", "Phoenix AZ", "Dallas TX", "Miami FL", + "Chicago IL", "Memphis TN", "Seattle WA", + "New York NY", "Raleigh NC", "Moscone Center"}; // DreamForce 2013 Tunables END @@ -267,8 +270,8 @@ // Log if (sent > 0) { - this->display("Send success. Ready..."); - this->display_lcd("Send status: OK.\r\nSleeping..."); + this->display("Send success. Ready...Location: %s",lcd_locations[location_index]); + this->display_lcd("Send status: OK.\r\nSleeping...\r\nLocation: %s",lcd_locations[location_index]); } else { this->display("Send Failed: sent=%d",sent); @@ -447,8 +450,8 @@ // Run the Demo void Thermostat::runDemo() { // Announce - this->display("Thermostat Hands-On Demo v1.0"); - this->display_lcd("Thermostat Hands-On\r\nDemo v1.0"); + this->display("Thermostat Remote v1.0"); + this->display_lcd("Thermostat Remote\r\nDemo v1.0"); // init the RGB LED this->display("Initializing LEDs..."); @@ -469,5 +472,5 @@ } // exit the application if we get here - exit(1); + NVIC_SystemReset(); } \ No newline at end of file
diff -r 9866322ed225 -r 33f71cf9a04f ThermostatSocketIO.cpp --- a/ThermostatSocketIO.cpp Mon Nov 11 20:29:32 2013 +0000 +++ b/ThermostatSocketIO.cpp Mon Nov 11 22:46:25 2013 +0000 @@ -6,6 +6,9 @@ // message counter int counter = 1; +extern char *lcd_locations[10]; +extern int location_index; + // constructor ThermostatSocketIO::ThermostatSocketIO(char *devname) : SocketIO(DEFAULT_URL) { this->device_name = devname; @@ -75,13 +78,13 @@ // create the message name if (counter == 1) { // create the JSON to just register the device - sprintf(buffer,"[\"%s\",{\"battery\": %d, \"city\": \"Austin\", \"country\": \"US\", \"device_id\": \"%s\", \"lat\": %4.6f, \"long\": %4.6f, \"status\": \"%s\", \"temp\": %4.1f, \"switch\": %d}]", - device_name, (int)bat, this->device_name, latitude, longitude, t_status, temp, errorState); + sprintf(buffer,"[\"%s\",{\"battery\": %d, \"city\": \"%s\", \"country\": \"US\", \"device_id\": \"%s\", \"lat\": %4.6f, \"long\": %4.6f, \"status\": \"%s\", \"temp\": %4.1f, \"switch\": %d}]", + device_name, (int)bat, lcd_locations[location_index], this->device_name, latitude, longitude, t_status, temp, errorState); } else { // create the JSON - sprintf(buffer,"[{\"battery\": %d, \"city\": \"Austin\", \"country\": \"US\", \"device_id\": \"%s\", \"lat\": %4.6f, \"long\": %4.6f, \"status\": \"%s\", \"temp\": %4.1f, \"switch\": %d}]", - (int)bat, this->device_name, latitude, longitude, t_status, temp, errorState); + sprintf(buffer,"[{\"battery\": %d, \"city\": \"%s\", \"country\": \"US\", \"device_id\": \"%s\", \"lat\": %4.6f, \"long\": %4.6f, \"status\": \"%s\", \"temp\": %4.1f, \"switch\": %d}]", + (int)bat, lcd_locations[location_index], this->device_name, latitude, longitude, t_status, temp, errorState); } // return the JSON