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
Thermostat-BaseUtils.h
00001 /* Thermostat-BaseUtils.h */ 00002 /* Copyright (C) 2013 mbed.org, MIT License 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00005 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00006 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00007 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00008 * furnished to do so, subject to the following conditions: 00009 * 00010 * The above copyright notice and this permission notice shall be included in all copies or 00011 * substantial portions of the Software. 00012 * 00013 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00014 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00015 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00016 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00017 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00018 */ 00019 00020 #ifndef THERMOSTAT_BASEUTILS_H_ 00021 #define THERMOSTAT_BASEUTILS_H_ 00022 00023 // AppBoard LCD Support 00024 #include "C12832.h" 00025 C12832 lcd(D11, D13, D12, D7, D10); 00026 00027 // Serial Console Support (main.cpp) 00028 #include "BufferedSerial.h" 00029 extern BufferedSerial pc; 00030 00031 // log messages to appropriate outputs 00032 void Thermostat::logMessage(bool do_lcd) { 00033 // print to LCD panel 00034 if (do_lcd) { 00035 lcd.cls(); 00036 lcd.locate(0,0); 00037 lcd.printf(this->m_display_message); 00038 } 00039 else { 00040 // print to serial console 00041 pc.printf(this->m_display_message); 00042 pc.printf("\r\n"); 00043 } 00044 00045 // wait a bit so that the message can be read 00046 wait(0.5); 00047 } 00048 00049 // display output 00050 void Thermostat::display(const char *format, ...) { 00051 memset(this->m_display_message,'\0',MAX_MESSAGE_LENGTH+1); 00052 va_list args; 00053 va_start(args, format); 00054 vsprintf(this->m_display_message, format, args); 00055 va_end(args); 00056 this->logMessage(false); 00057 } 00058 00059 // display output 00060 void Thermostat::display_lcd(const char *format, ...) { 00061 memset(this->m_display_message,'\0',MAX_MESSAGE_LENGTH+1); 00062 va_list args; 00063 va_start(args, format); 00064 vsprintf(this->m_display_message, format, args); 00065 va_end(args); 00066 this->logMessage(true); 00067 } 00068 00069 // display text message output 00070 void Thermostat::displayTextMessage(const char *format, ...) { 00071 memset(this->m_display_message,'\0',MAX_MESSAGE_LENGTH+1); 00072 va_list args; 00073 va_start(args, format); 00074 vsprintf(this->m_display_message, format, args); 00075 va_end(args); 00076 this->logMessage(true); 00077 wait_ms(3000); // add wait state so that we can see the message! 00078 } 00079 00080 #endif // THERMOSTAT_BASEUTILS_H_
Generated on Wed Jul 13 2022 00:00:04 by 1.7.2