Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: C12832_lcd EthernetInterface HTTPClient LM75B MMA7660 SocketIO WebSocketClient-ThermostatDemo mbed-rtos mbed picojson
Thermostat-BaseUtils.h@1:dfd24f608038, 2013-10-17 (annotated)
- Committer:
- ansond
- Date:
- Thu Oct 17 20:25:14 2013 +0000
- Revision:
- 1:dfd24f608038
- Parent:
- 0:6b56785dd2b6
updates
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ansond | 1:dfd24f608038 | 1 | /* Thermostat-BaseUtils.h */ |
| ansond | 0:6b56785dd2b6 | 2 | /* Copyright (C) 2013 mbed.org, MIT License |
| ansond | 0:6b56785dd2b6 | 3 | * |
| ansond | 0:6b56785dd2b6 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
| ansond | 0:6b56785dd2b6 | 5 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
| ansond | 0:6b56785dd2b6 | 6 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
| ansond | 0:6b56785dd2b6 | 7 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
| ansond | 0:6b56785dd2b6 | 8 | * furnished to do so, subject to the following conditions: |
| ansond | 0:6b56785dd2b6 | 9 | * |
| ansond | 0:6b56785dd2b6 | 10 | * The above copyright notice and this permission notice shall be included in all copies or |
| ansond | 0:6b56785dd2b6 | 11 | * substantial portions of the Software. |
| ansond | 0:6b56785dd2b6 | 12 | * |
| ansond | 0:6b56785dd2b6 | 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
| ansond | 0:6b56785dd2b6 | 14 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| ansond | 0:6b56785dd2b6 | 15 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| ansond | 0:6b56785dd2b6 | 16 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| ansond | 0:6b56785dd2b6 | 17 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| ansond | 0:6b56785dd2b6 | 18 | */ |
| ansond | 0:6b56785dd2b6 | 19 | |
| ansond | 1:dfd24f608038 | 20 | #ifndef THERMOSTAT_BASEUTILS_H_ |
| ansond | 1:dfd24f608038 | 21 | #define THERMOSTAT_BASEUTILS_H_ |
| ansond | 0:6b56785dd2b6 | 22 | |
| ansond | 0:6b56785dd2b6 | 23 | // AppBoard LCD Support |
| ansond | 0:6b56785dd2b6 | 24 | #include "C12832_lcd.h" |
| ansond | 0:6b56785dd2b6 | 25 | C12832_LCD lcd; |
| ansond | 0:6b56785dd2b6 | 26 | |
| ansond | 0:6b56785dd2b6 | 27 | // Serial Console Support (main.cpp) |
| ansond | 0:6b56785dd2b6 | 28 | extern Serial pc; |
| ansond | 0:6b56785dd2b6 | 29 | |
| ansond | 0:6b56785dd2b6 | 30 | // log messages to appropriate outputs |
| ansond | 0:6b56785dd2b6 | 31 | void Thermostat::logMessage(bool do_lcd) { |
| ansond | 0:6b56785dd2b6 | 32 | // print to LCD panel |
| ansond | 0:6b56785dd2b6 | 33 | if (do_lcd) { |
| ansond | 0:6b56785dd2b6 | 34 | lcd.cls(); |
| ansond | 0:6b56785dd2b6 | 35 | lcd.locate(0,0); |
| ansond | 0:6b56785dd2b6 | 36 | lcd.printf(this->m_display_message); |
| ansond | 0:6b56785dd2b6 | 37 | } |
| ansond | 0:6b56785dd2b6 | 38 | else { |
| ansond | 0:6b56785dd2b6 | 39 | // print to serial console |
| ansond | 0:6b56785dd2b6 | 40 | pc.printf(this->m_display_message); |
| ansond | 0:6b56785dd2b6 | 41 | pc.printf("\r\n"); |
| ansond | 0:6b56785dd2b6 | 42 | } |
| ansond | 0:6b56785dd2b6 | 43 | |
| ansond | 0:6b56785dd2b6 | 44 | // wait a bit so that the message can be read |
| ansond | 0:6b56785dd2b6 | 45 | wait(0.5); |
| ansond | 0:6b56785dd2b6 | 46 | } |
| ansond | 0:6b56785dd2b6 | 47 | |
| ansond | 0:6b56785dd2b6 | 48 | // display output |
| ansond | 0:6b56785dd2b6 | 49 | void Thermostat::display(const char *format, ...) { |
| ansond | 0:6b56785dd2b6 | 50 | memset(this->m_display_message,'\0',MAX_MESSAGE_LENGTH+1); |
| ansond | 0:6b56785dd2b6 | 51 | va_list args; |
| ansond | 0:6b56785dd2b6 | 52 | va_start(args, format); |
| ansond | 0:6b56785dd2b6 | 53 | vsprintf(this->m_display_message, format, args); |
| ansond | 0:6b56785dd2b6 | 54 | va_end(args); |
| ansond | 0:6b56785dd2b6 | 55 | this->logMessage(false); |
| ansond | 0:6b56785dd2b6 | 56 | } |
| ansond | 0:6b56785dd2b6 | 57 | |
| ansond | 0:6b56785dd2b6 | 58 | // display output |
| ansond | 0:6b56785dd2b6 | 59 | void Thermostat::display_lcd(const char *format, ...) { |
| ansond | 0:6b56785dd2b6 | 60 | memset(this->m_display_message,'\0',MAX_MESSAGE_LENGTH+1); |
| ansond | 0:6b56785dd2b6 | 61 | va_list args; |
| ansond | 0:6b56785dd2b6 | 62 | va_start(args, format); |
| ansond | 0:6b56785dd2b6 | 63 | vsprintf(this->m_display_message, format, args); |
| ansond | 0:6b56785dd2b6 | 64 | va_end(args); |
| ansond | 0:6b56785dd2b6 | 65 | this->logMessage(true); |
| ansond | 0:6b56785dd2b6 | 66 | } |
| ansond | 0:6b56785dd2b6 | 67 | |
| ansond | 1:dfd24f608038 | 68 | #endif // THERMOSTAT_BASEUTILS_H_ |