Droni e Droidi / TerminalPlusV2

Fork of TerminalPlus by Max Scordamaglia

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     /** Erase square */
00079     void erasesquare(int x1, int y1, int x2, int y2);
00080 
00081     // font attrib
00082     //** Reset attrib */
00083     void resetattrib();
00084     //** font bold */
00085     void bold();
00086     //** font underscore */
00087     void underscore();
00088     //** font blink */
00089     void blink();
00090     //** font reverse */
00091     void reverse();
00092 
00093     /** Set the foreground colour 0xffffff */
00094     void foreground(int colour);
00095     /** Set the foreground standard (0-7) color */
00096     void forgcol(int color);
00097 
00098     /** Set the background colour 0xffffff */
00099     void background(int colour);
00100     /** Set the background standard (0-7) color */
00101     void bckgcol(int color);
00102 
00103     /** printf formattato con dimensione e posizione */
00104     void formatPrintf(char sstr[], int xx, int yy, int padb=0, bool boldf=0);
00105 
00106     /** Draw box */
00107     void frame(int x, int y, int w, int h, int boxtype=1);
00108 
00109     /** Default input pos */
00110     void readypos();
00111 
00112 private:
00113     string padstr(string sttde, int maxlen, char fillchar);
00114     string addEOS(string sttde);
00115     char* string2char(string sttde);
00116     char* createStr(char car);
00117 };
00118 
00119 #endif