Support library for the ESP8266 Wireless Terminal. Can also be used for communicating with any VT100-compatible terminal.

Files at this revision

API Documentation at this revision

Comitter:
MightyPork
Date:
Tue Mar 21 21:27:10 2017 +0000
Parent:
6:7e7550084e5f
Commit message:
updated docs

Changed in this revision

espterm.hpp Show annotated file Show diff for this revision Revisions of this file
--- a/espterm.hpp	Sun Mar 19 19:51:21 2017 +0000
+++ b/espterm.hpp	Tue Mar 21 21:27:10 2017 +0000
@@ -3,6 +3,64 @@
 #include "mbed.h"
 
 /*
+// Example
+
+DigitalOut led(LED1);
+ESPTerm term(PA_9, PA_10); // UART not used by the Nucleo ACM
+
+void onchar(char c);
+void onmouse(int row, int col, MouseEvent evt);
+
+int main()
+{   
+    // Wait for ESP ready (send "Device Status Query" and wait for "Device OK")
+    term.clear_status();
+    while (term.query_status() == false) {
+        wait_ms(100);        
+        led = !led;    
+    }
+    
+    // Connect handlers
+    term.on_char_rx = onchar; 
+    term.on_mouse = onmouse;
+    
+    // others: (check the declarations)
+    // term.on_esp_reset - on esp reset, we should re-init the screen etc
+    // term.on_key - user pushed an arrow key
+    // term.on_button - user pushed a button under the screen
+    
+    term.set_screen_size(25, 60);
+
+    int i = 0;
+    while(1) {
+        wait_ms(1000);        
+        led = !led; // heartbeat       
+        term.println("> %d", i++);
+    }
+}
+
+// --- handlers ---
+
+// User typed a character that's not part of a control sequence
+void onchar(char c)
+{
+    // change it to indicate we did something
+    term.putc(c+1);   
+}
+
+// User clicked (events other than 0 are not implemented as of v0.5.5)
+void onmouse(int row, int col, MouseEvent event)
+{
+    term.fg(GREEN);
+    term.println("Mouse evt %d @ %d, %d", event, row, col);    
+    term.rst();
+}
+
+*/
+
+
+
+/*
  * ESP8266 Wireless Terminal interfacing library
  * ---------------------------------------------
  *
@@ -51,8 +109,6 @@
  *
  * DOWN (and UP) are fired when the button stays pressed for
  * more than a certain time interval (typ. 200 ms)
- *
- *  
  */
 enum MouseEvent {
     // Left button