Dreamforce Heroku Sample mbed application for the FRDM-K64F. This application uses SocketIO to connect and communicate with Heroku.

Dependencies:   BufferedSerial C12832 EthernetInterface HTTPClient-SSL LM75B MMA7660 SocketIO-k64f WebSocketClient-ThermostatDemo mbed-rtos mbed picojson

Fork of df-2013-minihack-thermostat-complete by MBED_DEMOS

Committer:
ansond
Date:
Thu Oct 09 16:14:18 2014 +0000
Revision:
6:74c1e9c8c90e
Parent:
1:3faa003ad6e6
updates of the 2013 DF heroku app ported to K64F+appshield

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 0:26c48388f725 1 /* Thermostat-BaseUtils.h */
ansond 0:26c48388f725 2 /* Copyright (C) 2013 mbed.org, MIT License
ansond 0:26c48388f725 3 *
ansond 0:26c48388f725 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
ansond 0:26c48388f725 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
ansond 0:26c48388f725 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
ansond 0:26c48388f725 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
ansond 0:26c48388f725 8 * furnished to do so, subject to the following conditions:
ansond 0:26c48388f725 9 *
ansond 0:26c48388f725 10 * The above copyright notice and this permission notice shall be included in all copies or
ansond 0:26c48388f725 11 * substantial portions of the Software.
ansond 0:26c48388f725 12 *
ansond 0:26c48388f725 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
ansond 0:26c48388f725 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
ansond 0:26c48388f725 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
ansond 0:26c48388f725 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ansond 0:26c48388f725 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ansond 0:26c48388f725 18 */
ansond 0:26c48388f725 19
ansond 0:26c48388f725 20 #ifndef THERMOSTAT_BASEUTILS_H_
ansond 0:26c48388f725 21 #define THERMOSTAT_BASEUTILS_H_
ansond 0:26c48388f725 22
ansond 0:26c48388f725 23 // AppBoard LCD Support
ansond 6:74c1e9c8c90e 24 #include "C12832.h"
ansond 6:74c1e9c8c90e 25 C12832 lcd(D11, D13, D12, D7, D10);
ansond 0:26c48388f725 26
ansond 0:26c48388f725 27 // Serial Console Support (main.cpp)
ansond 6:74c1e9c8c90e 28 #include "BufferedSerial.h"
ansond 6:74c1e9c8c90e 29 extern BufferedSerial pc;
ansond 0:26c48388f725 30
ansond 0:26c48388f725 31 // log messages to appropriate outputs
ansond 0:26c48388f725 32 void Thermostat::logMessage(bool do_lcd) {
ansond 0:26c48388f725 33 // print to LCD panel
ansond 0:26c48388f725 34 if (do_lcd) {
ansond 0:26c48388f725 35 lcd.cls();
ansond 0:26c48388f725 36 lcd.locate(0,0);
ansond 0:26c48388f725 37 lcd.printf(this->m_display_message);
ansond 0:26c48388f725 38 }
ansond 0:26c48388f725 39 else {
ansond 0:26c48388f725 40 // print to serial console
ansond 0:26c48388f725 41 pc.printf(this->m_display_message);
ansond 0:26c48388f725 42 pc.printf("\r\n");
ansond 0:26c48388f725 43 }
ansond 0:26c48388f725 44
ansond 0:26c48388f725 45 // wait a bit so that the message can be read
ansond 0:26c48388f725 46 wait(0.5);
ansond 0:26c48388f725 47 }
ansond 0:26c48388f725 48
ansond 0:26c48388f725 49 // display output
ansond 0:26c48388f725 50 void Thermostat::display(const char *format, ...) {
ansond 0:26c48388f725 51 memset(this->m_display_message,'\0',MAX_MESSAGE_LENGTH+1);
ansond 0:26c48388f725 52 va_list args;
ansond 0:26c48388f725 53 va_start(args, format);
ansond 0:26c48388f725 54 vsprintf(this->m_display_message, format, args);
ansond 0:26c48388f725 55 va_end(args);
ansond 0:26c48388f725 56 this->logMessage(false);
ansond 0:26c48388f725 57 }
ansond 0:26c48388f725 58
ansond 0:26c48388f725 59 // display output
ansond 0:26c48388f725 60 void Thermostat::display_lcd(const char *format, ...) {
ansond 0:26c48388f725 61 memset(this->m_display_message,'\0',MAX_MESSAGE_LENGTH+1);
ansond 0:26c48388f725 62 va_list args;
ansond 0:26c48388f725 63 va_start(args, format);
ansond 0:26c48388f725 64 vsprintf(this->m_display_message, format, args);
ansond 0:26c48388f725 65 va_end(args);
ansond 0:26c48388f725 66 this->logMessage(true);
ansond 0:26c48388f725 67 }
ansond 0:26c48388f725 68
ansond 1:3faa003ad6e6 69 // display text message output
ansond 1:3faa003ad6e6 70 void Thermostat::displayTextMessage(const char *format, ...) {
ansond 1:3faa003ad6e6 71 memset(this->m_display_message,'\0',MAX_MESSAGE_LENGTH+1);
ansond 1:3faa003ad6e6 72 va_list args;
ansond 1:3faa003ad6e6 73 va_start(args, format);
ansond 1:3faa003ad6e6 74 vsprintf(this->m_display_message, format, args);
ansond 1:3faa003ad6e6 75 va_end(args);
ansond 1:3faa003ad6e6 76 this->logMessage(true);
ansond 1:3faa003ad6e6 77 wait_ms(3000); // add wait state so that we can see the message!
ansond 1:3faa003ad6e6 78 }
ansond 1:3faa003ad6e6 79
ansond 0:26c48388f725 80 #endif // THERMOSTAT_BASEUTILS_H_