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.
ESPTerm Class Reference
ESP8266 Wireless Terminal interface. More...
#include <espterm.hpp>
Public Member Functions | |
| ESPTerm (Serial *s) | |
| Create a terminal instance from already initialized serial port. | |
| ESPTerm (PinName txPin, PinName rxPin, int baud=115200) | |
| Create a terminal instance with given params. | |
| ESPTerm (void) | |
| Create a terminal instance with given params & 115200 baud. | |
| int | printf (const char *fmt,...) |
| printf() over the Serial | |
| int | print (const char *fmt,...) |
| Alias for printf() | |
| int | puts (const char *str) |
| Print with no args. | |
| void | putc (const char c) |
| Print a single char. | |
| int | println (const char *fmt,...) |
| printf() over the Serial, followed by a newline (\r\n) | |
| void | fg (Color c) |
| Set foreground text color. | |
| void | bg (Color c) |
| Set background text color. | |
| void | colors (Color fg, Color bg) |
| Set both text colors. | |
| void | reset_attribs (void) |
| Send \e[0m - reset all attributes. | |
| void | rst (void) |
| Reset all attributes (alias) | |
| void | go_to (int y, int x) |
| Move cursor to a given position. | |
| void | move (int dy, int dx) |
| Move cursor relatively to the current position. | |
| void | clear_screen (ClearMode mode) |
| Clear screen. | |
| void | clear_line (ClearMode mode) |
| Clear in line. | |
| void | screen_reset (void) |
| Clear the whole screen and move cursor to 1,1. | |
| void | scroll (int lines) |
| Scroll the screen up or down. | |
| void | show_cursor (bool yes) |
| Set cursor visibility. | |
| void | cursor_push (bool with_attribs=true) |
| Push the cursor (there's only one slot) | |
| void | cursor_pop (bool with_attribs=true) |
| Pop the cursor (if stored) | |
| void | wrap_enable (bool yes) |
| Enable or disable wrapping at EOL (and automatic scrolling) | |
| void | factory_reset (void) |
| Perform a factory reset of the ESP Terminal. | |
| void | set_screen_size (int rows, int cols) |
| Set screen size. | |
| void | clear_status (void) |
| Clear the Device OK flag. | |
| bool | query_status (void) |
| Query device status. | |
Data Fields | |
| void(* | on_mouse )(int row, int col, MouseEvent event) |
| Fired when user taps the screen at the given coords. | |
| void(* | on_button )(int index) |
| Fired when the user presses one of the blue buttons (index is 1 thru 5) | |
| void(* | on_key )(CtlKey key) |
| Fired on each key press (keyboard arrows etc) | |
| void(* | on_esp_reset )(void) |
| Fired on rx of the "ESP reset notification" byte. | |
| void(* | on_char_rx )(char c) |
| Fired on each received plain character. | |
| void(* | on_osc_rx )(const char *str) |
| Handle generic OSC command (may be used in the future) | |
Detailed Description
ESP8266 Wireless Terminal interface.
Can also be used for sending ANSI sequences to a regular serial terminal
Definition at line 142 of file espterm.hpp.
Constructor & Destructor Documentation
| ESPTerm | ( | Serial * | s ) |
Create a terminal instance from already initialized serial port.
Example: Serial ser(PA_2, PA_3, 115200); // eg. for STM32F042 ESPTerm term(&ser);
Definition at line 24 of file espterm.cpp.
| ESPTerm | ( | PinName | txPin, |
| PinName | rxPin, | ||
| int | baud = 115200 |
||
| ) |
Create a terminal instance with given params.
Definition at line 37 of file espterm.cpp.
| ESPTerm | ( | void | ) |
Create a terminal instance with given params & 115200 baud.
Create with Serial at (PA_2, PA_3, 115200)
Definition at line 30 of file espterm.cpp.
Member Function Documentation
| void bg | ( | Color | c ) |
| void clear_line | ( | ClearMode | mode ) |
Clear in line.
Replace part of the current line with spaces (ASCII 32) of the currently selected foregorund and background colors.
- Parameters:
-
mode - what to clear: part or all
Definition at line 154 of file espterm.cpp.
| void clear_screen | ( | ClearMode | mode ) |
Clear screen.
Replace part of the screen with spaces (ASCII 32) of the currently selected foregorund and background colors.
- Parameters:
-
mode - what to clear: part or all
Definition at line 148 of file espterm.cpp.
| void clear_status | ( | void | ) |
Clear the Device OK flag.
Definition at line 452 of file espterm.hpp.
| void colors | ( | Color | fg, |
| Color | bg | ||
| ) |
Set both text colors.
- Parameters:
-
fg - foregorund color bg - background color
Definition at line 302 of file espterm.hpp.
| void cursor_pop | ( | bool | with_attribs = true ) |
Pop the cursor (if stored)
- Parameters:
-
with_attribs - restore also the colors and attributes
Definition at line 199 of file espterm.cpp.
| void cursor_push | ( | bool | with_attribs = true ) |
Push the cursor (there's only one slot)
- Parameters:
-
with_attribs - store also the colors and attributes
Definition at line 188 of file espterm.cpp.
| void factory_reset | ( | void | ) |
Perform a factory reset of the ESP Terminal.
This clears any saved WiFi config, restores the default AP name and switches to AP mode. The module will reset itself.
Expect some ASCII output from the module (and a burst of garbage during the reset).
Definition at line 224 of file espterm.cpp.
| void fg | ( | Color | c ) |
| void go_to | ( | int | y, |
| int | x | ||
| ) |
Move cursor to a given position.
Screen coordinates are 1-based, starting left-top, growing down and right.
- Parameters:
-
y - row x - column
Definition at line 116 of file espterm.cpp.
| void move | ( | int | dy, |
| int | dx | ||
| ) |
Move cursor relatively to the current position.
- Parameters:
-
dy - vertical offset (positive = down) dx - horizontal offset (positive = right)
Definition at line 122 of file espterm.cpp.
| int print | ( | const char * | fmt, |
| ... | |||
| ) |
Alias for printf()
Definition at line 58 of file espterm.cpp.
| int printf | ( | const char * | fmt, |
| ... | |||
| ) |
printf() over the Serial
Use for raw strings without formatting, or with custom escape sequences.
Definition at line 46 of file espterm.cpp.
| int println | ( | const char * | fmt, |
| ... | |||
| ) |
printf() over the Serial, followed by a newline (\r\n)
Use for raw strings without formatting, or with custom escape sequences. Especially useful for log messages, automatically terminating the line.
Definition at line 69 of file espterm.cpp.
| void putc | ( | const char | c ) |
Print a single char.
Definition at line 265 of file espterm.hpp.
| int puts | ( | const char * | str ) |
Print with no args.
Definition at line 256 of file espterm.hpp.
| bool query_status | ( | void | ) |
Query device status.
To use the query function, call clear_status() first, and then poll query_status() with some delays in between.
- Returns:
- the status flag from a previous query; if true, does not send another query, and just returns.
Definition at line 236 of file espterm.cpp.
| void reset_attribs | ( | void | ) |
Send \e[0m - reset all attributes.
Definition at line 107 of file espterm.cpp.
| void rst | ( | void | ) |
Reset all attributes (alias)
Definition at line 318 of file espterm.hpp.
| void screen_reset | ( | void | ) |
Clear the whole screen and move cursor to 1,1.
Definition at line 160 of file espterm.cpp.
| void scroll | ( | int | lines ) |
Scroll the screen up or down.
Moves the screen content in the specified direction, replacing the vacated lines with spaces (32) of the current colors.
- Parameters:
-
lines - number of lines, positive = down, negative = up.
Definition at line 177 of file espterm.cpp.
| void set_screen_size | ( | int | rows, |
| int | cols | ||
| ) |
Set screen size.
The total number of characters (rows*cols) is limited by the Terminal firmware, at v0.5.2 that is 2000 characters (25x80)
- Parameters:
-
rows - number of rows (screen height) cols - number of columns (screen width)
Definition at line 230 of file espterm.cpp.
| void show_cursor | ( | bool | yes ) |
Set cursor visibility.
If hidden, there will be no blinking square on the screen, but the cursor still works (ie. go_to works).
Hiding the cursor is useful for ASCII-art GUIs (dialog boxes etc)
Definition at line 166 of file espterm.cpp.
| void wrap_enable | ( | bool | yes ) |
Enable or disable wrapping at EOL (and automatic scrolling)
- Parameters:
-
yes - enable wrap
Definition at line 210 of file espterm.cpp.
Field Documentation
| void(* on_button)(int index) |
Fired when the user presses one of the blue buttons (index is 1 thru 5)
Definition at line 189 of file espterm.hpp.
| void(* on_char_rx)(char c) |
Fired on each received plain character.
Definition at line 201 of file espterm.hpp.
| void(* on_esp_reset)(void) |
Fired on rx of the "ESP reset notification" byte.
Definition at line 197 of file espterm.hpp.
| void(* on_key)(CtlKey key) |
Fired on each key press (keyboard arrows etc)
Definition at line 193 of file espterm.hpp.
| void(* on_mouse)(int row, int col, MouseEvent event) |
Fired when user taps the screen at the given coords.
Definition at line 185 of file espterm.hpp.
| void(* on_osc_rx)(const char *str) |
Handle generic OSC command (may be used in the future)
Definition at line 205 of file espterm.hpp.
Generated on Fri Jul 15 2022 15:31:59 by
1.7.2