Support library for the ESP8266 Wireless Terminal. Can also be used for communicating with any VT100-compatible terminal.
Diff: espterm.hpp
- Revision:
- 5:7379bd37f3e2
- Parent:
- 4:294e8f53ebcd
- Child:
- 6:7e7550084e5f
--- a/espterm.hpp Sun Mar 19 17:19:16 2017 +0000 +++ b/espterm.hpp Sun Mar 19 18:16:17 2017 +0000 @@ -14,6 +14,69 @@ // Max nr of CSI parameters #define CSI_N_MAX 3 #define OSC_BUF_LEN 16 + + +/** + * 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, +}; + + +enum CtlKey { + KEY_LEFT = 0, + KEY_RIGHT = 1, + KEY_UP = 2, + KEY_DOWN = 3, +}; + + +/** + * NOTE: not all may be implemented + * + * DOWN (and UP) are fired when the button stays pressed for + * more than a certain time interval (typ. 200 ms) + * + * + */ +enum MouseEvent { + // Left button + LEFT_CLICK = 0, + LEFT_DOWN = 1, + LEFT_UP = 2, + + // Right button + RIGHT_CLICK = 10, + RIGHT_DOWN = 11, // Probably not working + RIGHT_UP = 12, // ditto + + // Common + MOUSE_MOVE = 20, // When coords of the cell under mouse changed + + // Wheel events + WHEEL_CLICK = 30, + WHEEL_DOWN = 31, // This refers to the push button + WHEEL_UP = 32, + SCROLL_DOWN = 33, // Here's the scrolling events + SCROLL_UP = 34, +}; + + /** * ESP8266 Wireless Terminal interface @@ -60,43 +123,20 @@ void apars_handle_badseq(void); -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, - }; - - - enum CtlKey { - KEY_LEFT=0, KEY_RIGHT, KEY_UP, KEY_DOWN - }; - +public: /** Fired when user taps the screen at the given coords */ - void (*on_mouse_click)(int row, int col); + void (*on_mouse)(int row, int col, MouseEvent event); /** Fired when the user presses one of the blue buttons (index is 1 thru 5) */ void (*on_button)(int index); + /** Fired on each key press (keyboard arrows etc) */ + void (*on_key)(CtlKey key); + + /** Fired on rx of the "ESP reset notification" byte */ void (*on_esp_reset)(void); @@ -105,10 +145,6 @@ void (*on_char_rx)(char c); - /** Fired on each key press (keyboard arrows etc) */ - void (*on_key_press)(CtlKey key); - - /** Handle generic OSC command (may be used in the future) */ void (*on_osc_rx)(const char *str);