Core Base Classes for the Light Endpoints
Dependents: mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more
Logger.h@192:54b758a8eaaa, 2014-09-26 (annotated)
- Committer:
- ansond
- Date:
- Fri Sep 26 05:16:07 2014 +0000
- Revision:
- 192:54b758a8eaaa
- Parent:
- ErrorHandler.h@179:35e88daf2d75
updates to new logger name
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 0:4c9bfcb3e759 | 1 | /* Copyright C2013 Doug Anson, MIT License |
ansond | 0:4c9bfcb3e759 | 2 | * |
ansond | 0:4c9bfcb3e759 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
ansond | 0:4c9bfcb3e759 | 4 | * and associated documentation files the "Software", to deal in the Software without restriction, |
ansond | 0:4c9bfcb3e759 | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
ansond | 0:4c9bfcb3e759 | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
ansond | 0:4c9bfcb3e759 | 7 | * furnished to do so, subject to the following conditions: |
ansond | 0:4c9bfcb3e759 | 8 | * |
ansond | 0:4c9bfcb3e759 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
ansond | 0:4c9bfcb3e759 | 10 | * substantial portions of the Software. |
ansond | 0:4c9bfcb3e759 | 11 | * |
ansond | 0:4c9bfcb3e759 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
ansond | 0:4c9bfcb3e759 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
ansond | 0:4c9bfcb3e759 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
ansond | 0:4c9bfcb3e759 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
ansond | 0:4c9bfcb3e759 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
ansond | 0:4c9bfcb3e759 | 17 | */ |
ansond | 0:4c9bfcb3e759 | 18 | |
ansond | 192:54b758a8eaaa | 19 | #ifndef _LOGGER_H_ |
ansond | 192:54b758a8eaaa | 20 | #define _LOGGER_H_ |
ansond | 0:4c9bfcb3e759 | 21 | |
ansond | 0:4c9bfcb3e759 | 22 | // Tunables |
ansond | 0:4c9bfcb3e759 | 23 | #include "Definitions.h" |
ansond | 0:4c9bfcb3e759 | 24 | |
ansond | 0:4c9bfcb3e759 | 25 | // Support for std args |
ansond | 0:4c9bfcb3e759 | 26 | #include <stdarg.h> |
ansond | 0:4c9bfcb3e759 | 27 | |
ansond | 0:4c9bfcb3e759 | 28 | // LCD Support |
ansond | 130:630d05daed77 | 29 | #ifdef _ENDPOINT_UBLOX_PLATFORM |
ansond | 130:630d05daed77 | 30 | #include "C12832.h" |
ansond | 130:630d05daed77 | 31 | #define LCDCLASS C12832 |
ansond | 130:630d05daed77 | 32 | #endif |
ansond | 130:630d05daed77 | 33 | |
ansond | 130:630d05daed77 | 34 | #ifdef _ENDPOINT_NXP_PLATFORM |
ansond | 130:630d05daed77 | 35 | #include "C12832_lcd.h" |
ansond | 130:630d05daed77 | 36 | #define LCDCLASS C12832_LCD |
ansond | 130:630d05daed77 | 37 | #endif |
ansond | 130:630d05daed77 | 38 | |
ansond | 130:630d05daed77 | 39 | #ifdef _ENDPOINT_FREEDOM_PLATFORM |
ansond | 130:630d05daed77 | 40 | #include "C12832_lcd.h" |
ansond | 130:630d05daed77 | 41 | #define LCDCLASS C12832_LCD |
ansond | 130:630d05daed77 | 42 | #endif |
ansond | 61:6012d61573ea | 43 | |
ansond | 166:8e63cd2c003a | 44 | #if defined(EH_USE_MUTEXES) || defined(NETWORK_MUTEX) || defined(ENABLE_THREADS) || defined(NSP_CELLULAR_NETWORK) |
ansond | 166:8e63cd2c003a | 45 | // RTOS support |
ansond | 166:8e63cd2c003a | 46 | #include "mbed.h" |
ansond | 166:8e63cd2c003a | 47 | #include "rtos.h" |
ansond | 160:24337c83dd1d | 48 | #endif |
ansond | 0:4c9bfcb3e759 | 49 | |
ansond | 192:54b758a8eaaa | 50 | class Logger { |
ansond | 0:4c9bfcb3e759 | 51 | private: |
ansond | 192:54b758a8eaaa | 52 | RawSerial *m_pc; |
ansond | 179:35e88daf2d75 | 53 | LCDCLASS *m_lcd; |
ansond | 179:35e88daf2d75 | 54 | char m_message[MAX_LOG_MESSAGE+1]; |
ansond | 160:24337c83dd1d | 55 | #ifdef EH_USE_MUTEXES |
ansond | 179:35e88daf2d75 | 56 | Mutex *m_mutex; |
ansond | 179:35e88daf2d75 | 57 | Mutex *m_close_mutex; |
ansond | 179:35e88daf2d75 | 58 | Mutex *m_led_mutex; |
ansond | 179:35e88daf2d75 | 59 | Mutex *m_rgb_mutex; |
ansond | 160:24337c83dd1d | 60 | #endif |
ansond | 179:35e88daf2d75 | 61 | void *m_endpoint; |
ansond | 179:35e88daf2d75 | 62 | bool m_status_lcd; |
ansond | 0:4c9bfcb3e759 | 63 | |
ansond | 0:4c9bfcb3e759 | 64 | public: |
ansond | 192:54b758a8eaaa | 65 | Logger(RawSerial *pc,LCDCLASS *lcd); |
ansond | 192:54b758a8eaaa | 66 | ~Logger(); |
ansond | 0:4c9bfcb3e759 | 67 | |
ansond | 114:bd38ad417d6a | 68 | void lcdStatusOnly(bool status_lcd); |
ansond | 114:bd38ad417d6a | 69 | |
ansond | 0:4c9bfcb3e759 | 70 | void log(const char *format, ...); |
ansond | 192:54b758a8eaaa | 71 | void logConsole(const char *format, ...); |
ansond | 74:b60149dd669e | 72 | void log_memory(const char *format, ...); |
ansond | 0:4c9bfcb3e759 | 73 | void checkForExit(); |
ansond | 0:4c9bfcb3e759 | 74 | |
ansond | 15:386dccd0000a | 75 | void pause(const char *format, ...); |
ansond | 15:386dccd0000a | 76 | |
ansond | 0:4c9bfcb3e759 | 77 | void turnLEDRed(); |
ansond | 0:4c9bfcb3e759 | 78 | void turnLEDGreen(); |
ansond | 0:4c9bfcb3e759 | 79 | void turnLEDBlue(); |
ansond | 114:bd38ad417d6a | 80 | void turnLEDPurple(); |
ansond | 0:4c9bfcb3e759 | 81 | void turnLEDBlack(); |
ansond | 0:4c9bfcb3e759 | 82 | void turnLEDYellow(); |
ansond | 114:bd38ad417d6a | 83 | void turnLEDOrange(); |
ansond | 0:4c9bfcb3e759 | 84 | |
ansond | 36:73e343ddca7f | 85 | void blinkTransportTxLED(); |
ansond | 36:73e343ddca7f | 86 | void blinkTransportRxLED(); |
ansond | 160:24337c83dd1d | 87 | |
ansond | 160:24337c83dd1d | 88 | #ifdef EH_USE_MUTEXES |
ansond | 70:055ebf51f6ad | 89 | void releaseMutexes(); |
ansond | 160:24337c83dd1d | 90 | #endif |
ansond | 160:24337c83dd1d | 91 | |
ansond | 84:4a993dd7c38b | 92 | void led2On(); |
ansond | 84:4a993dd7c38b | 93 | void led2Off(); |
ansond | 84:4a993dd7c38b | 94 | void led3On(); |
ansond | 84:4a993dd7c38b | 95 | void led3Off(); |
ansond | 112:1fb53d4729af | 96 | |
ansond | 112:1fb53d4729af | 97 | void setEndpoint(void *endpoint); |
ansond | 112:1fb53d4729af | 98 | void *getEndpoint(); |
ansond | 36:73e343ddca7f | 99 | |
ansond | 0:4c9bfcb3e759 | 100 | private: |
ansond | 0:4c9bfcb3e759 | 101 | void setRGBLED(float H, float S, float V); |
ansond | 0:4c9bfcb3e759 | 102 | void blinkLED(DigitalOut led); |
ansond | 0:4c9bfcb3e759 | 103 | void resetLEDs(); |
ansond | 84:4a993dd7c38b | 104 | void changeLED(DigitalOut led,bool onoff); |
ansond | 0:4c9bfcb3e759 | 105 | }; |
ansond | 0:4c9bfcb3e759 | 106 | |
ansond | 192:54b758a8eaaa | 107 | #endif // _LOGGER_H_ |