Support library for the ESP8266 Wireless Terminal. Can also be used for communicating with any VT100-compatible terminal.
Diff: espterm.hpp
- Revision:
- 3:1114012184bf
- Parent:
- 2:f9f27e2b64a7
- Child:
- 4:294e8f53ebcd
--- a/espterm.hpp Mon Mar 06 22:32:37 2017 +0000 +++ b/espterm.hpp Sun Mar 19 10:34:48 2017 +0000 @@ -2,27 +2,14 @@ #define ESPTERM_H #include "mbed.h" - -/** - * ANSI colors supported by the ESP Terminal +/* + * ESP8266 Wireless Terminal interfacing library + * --------------------------------------------- + * + * Tested with ESP firmware v0.5.4 + * + * This library provides simplified */ -typedef enum { - BLACK = 0, RED, GREEN, YELLOW, BLUE, PURPLE, CYAN, GRAY_LT, - GRAY, RED_LT, GREEN_LT, YELLOW_LT, BLUE_LT, PURPLE_LT, CYAN_LT, WHITE, - - // aliases - RED_DK=1, GREEN_DK=2, YELLOW_DK=3, BLUE_DK=4, PURPLE_DK=5, CYAN_DK=6, SILVER=7, -} ANSI_Color; - - -/** - * Argument for screen or line clear commands - */ -typedef enum { - CLEAR_TO_CURSOR = 0, - CLEAR_FROM_CURSOR = 1, - CLEAR_ALL = 2, -} ClearMode; /** @@ -35,11 +22,33 @@ Serial* ser; public: + /** + * ANSI colors supported by the ESP Terminal + */ + enum Color { + BLACK = 0, RED, GREEN, YELLOW, BLUE, PURPLE, CYAN, GRAY_LT, + GRAY, RED_LT, GREEN_LT, YELLOW_LT, BLUE_LT, PURPLE_LT, CYAN_LT, WHITE, + + // aliases + RED_DK=1, GREEN_DK=2, YELLOW_DK=3, BLUE_DK=4, PURPLE_DK=5, CYAN_DK=6, SILVER=7, + }; + + + /** + * Argument for screen or line clear commands + */ + enum ClearMode { + CLEAR_TO_CURSOR = 0, + CLEAR_FROM_CURSOR = 1, + CLEAR_ALL = 2, + }; + + /** * @brief Create a terminal instance from already initialized serial port * * Example: - * Serial ser(PA_2, PA_3, 115200); // for STM32F042 + * Serial ser(PA_2, PA_3, 115200); // eg. for STM32F042 * ESPTerm term(&ser); */ ESPTerm(Serial *s); @@ -66,6 +75,12 @@ /** + * @brief Print with no args + */ + int puts(const char *str); + + + /** * printf() over the Serial, followed by a newline (\\r\\n) * * Use for raw strings without formatting, or with custom escape sequences. @@ -78,14 +93,14 @@ * @brief Set foreground text color * @param c - color */ - void fg(ANSI_Color c); + void fg(Color c); /** * @brief Set background text color * @param c - color */ - void bg(ANSI_Color c); + void bg(Color c); /** @@ -93,7 +108,7 @@ * @param fg - foregorund color * @param bg - background color */ - void colors(ANSI_Color fg, ANSI_Color bg); + void colors(Color fg, Color bg); /** @@ -183,4 +198,8 @@ void set_screen_size(int rows, int cols); }; + +/** Convenience alias for using class enums etc */ +typedef ESPTerm VT; + #endif /* ESPTERM_H */