Based on Terminal lib from Simon Ford, some adds

Fork of Terminal by Simon Ford

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Terminal.h Source File

Terminal.h

00001 /** mbed TerminalPlus Library, for ANSI/VT200 Terminals and ecape codes
00002  * Copyright (c) 2015, Max Scordamaglia , https//developer.mbed.org/users/MaxScorda/
00003  * fork from Terminal Library
00004  * Copyright (c) 2007-2010, sford, http://mbed.org
00005  *
00006  * Permission is hereby granted, free of charge, to any person obtaining a copy
00007  * of this software and associated documentation files (the "Software"), to deal
00008  * in the Software without restriction, including without limitation the rights
00009  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00010  * copies of the Software, and to permit persons to whom the Software is
00011  * furnished to do so, subject to the following conditions:
00012  *
00013  * The above copyright notice and this permission notice shall be included in
00014  * all copies or substantial portions of the Software.
00015  *
00016  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00019  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00020  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00021  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00022  * THE SOFTWARE.
00023  */
00024 
00025 
00026 #ifndef MBED_TERMINAL_H
00027 #define MBED_TERMINAL_H
00028 #include "mbed.h"
00029 #include <string>
00030 
00031 /** Control and display on an ANSI/VT100 Terminal
00032  *
00033  * This allows you to control an ANSI serial terminal
00034  */
00035 class Terminal : public Serial
00036 {
00037 public:
00038     /** Create the Terminal interface
00039      *
00040      * @param tx Serial transmit
00041      * @param rx Serial recieve
00042      */
00043     Terminal(PinName tx, PinName rx);
00044 
00045 #if DOXYGEN_ONLY
00046     /** Write a character to the terminal
00047      *
00048      * @param c The character to write to the display
00049      */
00050     int putc(int c);
00051 
00052     /** Write a formated string to the terminal
00053      *
00054      * @param format A printf-style format string, followed by the
00055      *               variables to use in formating the string.
00056      */
00057     int printf(const char* format, ...);
00058 
00059     // also baud etc
00060 #endif
00061 
00062     /** Locate to a screen column and row
00063      *
00064      * @param column  The horizontal position from the left, indexed from 0
00065      * @param row     The vertical position from the top, indexed from 0
00066      */
00067     void locate(int column, int row);
00068 
00069     /** Clear the screen and locate to 0,0 */
00070     void cls();
00071 
00072     /** Reset Screen */
00073     void reset();
00074 
00075     /** Erase line */
00076     void eraseline();
00077 
00078 // font attrib
00079     //** Reset attrib */
00080     void resetattrib();
00081     //** font bold */
00082     void bold();
00083     //** font underscore */
00084     void underscore();
00085     //** font blink */
00086     void blink();
00087     //** font reverse */
00088     void reverse();
00089 
00090     /** Set the foreground colour 0xffffff */
00091     void foreground(int colour);
00092     /** Set the foreground standard (0-7) color */
00093     void forgcol(int color);
00094 
00095     /** Set the background colour 0xffffff */
00096     void background(int colour);
00097     /** Set the background standard (0-7) color */
00098     void bckgcol(int color);
00099 
00100     /** printf formattato con dimensione e posizione */
00101     void formatPrintf(char sstr[], int xx, int yy, int padb=0, bool boldf=0);
00102 
00103     /** Draw box */
00104     void frame(int x, int y, int w, int h, int boxtype=1);
00105 
00106    
00107         /** Banner Adv*/
00108     void bannerAdv();
00109 
00110     /** Default input pos */
00111     void readypos();
00112 
00113 private:
00114     string padstr(string sttde, int maxlen, char fillchar);
00115     string addEOS(string sttde);
00116     char* string2char(string sttde);
00117     char* createStr(char car);
00118 };
00119 
00120 #endif