Based on Terminal lib from Simon Ford, some adds
Fork of TerminalPlus by
Terminal.h@8:e3c6d6322506, 2015-09-23 (annotated)
- Committer:
- MaxScorda
- Date:
- Wed Sep 23 00:04:05 2015 +0000
- Revision:
- 8:e3c6d6322506
- Parent:
- 7:80096ab72764
- Child:
- 13:09eb30497e78
Correzioni minori
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MaxScorda | 7:80096ab72764 | 1 | /** mbed TerminalPlus Library, for ANSI/VT200 Terminals and ecape codes |
MaxScorda | 7:80096ab72764 | 2 | * Copyright (c) 2015, Max Scordamaglia , https//developer.mbed.org/users/MaxScorda/ |
MaxScorda | 7:80096ab72764 | 3 | * fork from Terminal Library |
simon | 2:85184c13476c | 4 | * Copyright (c) 2007-2010, sford, http://mbed.org |
simon | 1:96ae39e58792 | 5 | * |
simon | 1:96ae39e58792 | 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
simon | 1:96ae39e58792 | 7 | * of this software and associated documentation files (the "Software"), to deal |
simon | 1:96ae39e58792 | 8 | * in the Software without restriction, including without limitation the rights |
simon | 1:96ae39e58792 | 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
simon | 1:96ae39e58792 | 10 | * copies of the Software, and to permit persons to whom the Software is |
simon | 1:96ae39e58792 | 11 | * furnished to do so, subject to the following conditions: |
simon | 0:2bf27af3c759 | 12 | * |
simon | 1:96ae39e58792 | 13 | * The above copyright notice and this permission notice shall be included in |
simon | 1:96ae39e58792 | 14 | * all copies or substantial portions of the Software. |
simon | 1:96ae39e58792 | 15 | * |
simon | 1:96ae39e58792 | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
simon | 1:96ae39e58792 | 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
simon | 1:96ae39e58792 | 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
simon | 1:96ae39e58792 | 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
simon | 1:96ae39e58792 | 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
simon | 1:96ae39e58792 | 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
simon | 1:96ae39e58792 | 22 | * THE SOFTWARE. |
simon | 0:2bf27af3c759 | 23 | */ |
simon | 0:2bf27af3c759 | 24 | |
simon | 0:2bf27af3c759 | 25 | |
simon | 0:2bf27af3c759 | 26 | #ifndef MBED_TERMINAL_H |
simon | 0:2bf27af3c759 | 27 | #define MBED_TERMINAL_H |
MaxScorda | 6:f8c90e147000 | 28 | #include "mbed.h" |
MaxScorda | 6:f8c90e147000 | 29 | #include <string> |
simon | 0:2bf27af3c759 | 30 | |
simon | 2:85184c13476c | 31 | /** Control and display on an ANSI/VT100 Terminal |
simon | 2:85184c13476c | 32 | * |
simon | 2:85184c13476c | 33 | * This allows you to control an ANSI serial terminal |
MaxScorda | 5:d045e3561533 | 34 | */ |
MaxScorda | 5:d045e3561533 | 35 | class Terminal : public Serial |
MaxScorda | 5:d045e3561533 | 36 | { |
simon | 0:2bf27af3c759 | 37 | public: |
MaxScorda | 5:d045e3561533 | 38 | /** Create the Terminal interface |
MaxScorda | 5:d045e3561533 | 39 | * |
simon | 1:96ae39e58792 | 40 | * @param tx Serial transmit |
simon | 1:96ae39e58792 | 41 | * @param rx Serial recieve |
MaxScorda | 5:d045e3561533 | 42 | */ |
simon | 0:2bf27af3c759 | 43 | Terminal(PinName tx, PinName rx); |
simon | 0:2bf27af3c759 | 44 | |
simon | 1:96ae39e58792 | 45 | #if DOXYGEN_ONLY |
simon | 1:96ae39e58792 | 46 | /** Write a character to the terminal |
simon | 1:96ae39e58792 | 47 | * |
simon | 1:96ae39e58792 | 48 | * @param c The character to write to the display |
simon | 1:96ae39e58792 | 49 | */ |
simon | 1:96ae39e58792 | 50 | int putc(int c); |
simon | 0:2bf27af3c759 | 51 | |
simon | 1:96ae39e58792 | 52 | /** Write a formated string to the terminal |
simon | 1:96ae39e58792 | 53 | * |
simon | 1:96ae39e58792 | 54 | * @param format A printf-style format string, followed by the |
simon | 1:96ae39e58792 | 55 | * variables to use in formating the string. |
simon | 1:96ae39e58792 | 56 | */ |
simon | 1:96ae39e58792 | 57 | int printf(const char* format, ...); |
MaxScorda | 5:d045e3561533 | 58 | |
simon | 1:96ae39e58792 | 59 | // also baud etc |
simon | 1:96ae39e58792 | 60 | #endif |
simon | 1:96ae39e58792 | 61 | |
simon | 1:96ae39e58792 | 62 | /** Locate to a screen column and row |
simon | 1:96ae39e58792 | 63 | * |
simon | 1:96ae39e58792 | 64 | * @param column The horizontal position from the left, indexed from 0 |
simon | 1:96ae39e58792 | 65 | * @param row The vertical position from the top, indexed from 0 |
simon | 1:96ae39e58792 | 66 | */ |
simon | 1:96ae39e58792 | 67 | void locate(int column, int row); |
simon | 1:96ae39e58792 | 68 | |
simon | 1:96ae39e58792 | 69 | /** Clear the screen and locate to 0,0 */ |
simon | 0:2bf27af3c759 | 70 | void cls(); |
simon | 1:96ae39e58792 | 71 | |
MaxScorda | 5:d045e3561533 | 72 | /** Reset Screen */ |
MaxScorda | 5:d045e3561533 | 73 | void reset(); |
MaxScorda | 5:d045e3561533 | 74 | |
MaxScorda | 5:d045e3561533 | 75 | /** Erase line */ |
MaxScorda | 5:d045e3561533 | 76 | void eraseline(); |
MaxScorda | 5:d045e3561533 | 77 | |
MaxScorda | 7:80096ab72764 | 78 | // font attrib |
MaxScorda | 7:80096ab72764 | 79 | //** Reset attrib */ |
MaxScorda | 7:80096ab72764 | 80 | void resetattrib(); |
MaxScorda | 7:80096ab72764 | 81 | //** font bold */ |
MaxScorda | 7:80096ab72764 | 82 | void bold(); |
MaxScorda | 7:80096ab72764 | 83 | //** font underscore */ |
MaxScorda | 7:80096ab72764 | 84 | void underscore(); |
MaxScorda | 7:80096ab72764 | 85 | //** font blink */ |
MaxScorda | 7:80096ab72764 | 86 | void blink(); |
MaxScorda | 7:80096ab72764 | 87 | //** font reverse */ |
MaxScorda | 7:80096ab72764 | 88 | void reverse(); |
MaxScorda | 7:80096ab72764 | 89 | |
MaxScorda | 7:80096ab72764 | 90 | /** Set the foreground colour 0xffffff */ |
simon | 0:2bf27af3c759 | 91 | void foreground(int colour); |
MaxScorda | 7:80096ab72764 | 92 | /** Set the foreground standard (0-7) color */ |
MaxScorda | 7:80096ab72764 | 93 | void forgcol(int color); |
simon | 1:96ae39e58792 | 94 | |
MaxScorda | 7:80096ab72764 | 95 | /** Set the background colour 0xffffff */ |
simon | 0:2bf27af3c759 | 96 | void background(int colour); |
MaxScorda | 7:80096ab72764 | 97 | /** Set the background standard (0-7) color */ |
MaxScorda | 6:f8c90e147000 | 98 | void bckgcol(int color); |
MaxScorda | 5:d045e3561533 | 99 | |
MaxScorda | 7:80096ab72764 | 100 | /** printf formattato con dimensione e posizione */ |
MaxScorda | 8:e3c6d6322506 | 101 | void formatPrintf(char sstr[], int xx, int yy, int padb=0, bool boldf=0); |
MaxScorda | 5:d045e3561533 | 102 | |
MaxScorda | 7:80096ab72764 | 103 | /** Draw box */ |
MaxScorda | 4:ee2311717b80 | 104 | void frame(int x, int y, int w, int h, int boxtype=1); |
MaxScorda | 7:80096ab72764 | 105 | |
MaxScorda | 8:e3c6d6322506 | 106 | |
MaxScorda | 7:80096ab72764 | 107 | /** Banner Adv*/ |
MaxScorda | 7:80096ab72764 | 108 | void bannerAdv(); |
MaxScorda | 7:80096ab72764 | 109 | |
MaxScorda | 7:80096ab72764 | 110 | /** Default input pos */ |
MaxScorda | 5:d045e3561533 | 111 | void readypos(); |
MaxScorda | 7:80096ab72764 | 112 | |
MaxScorda | 7:80096ab72764 | 113 | private: |
MaxScorda | 6:f8c90e147000 | 114 | string padstr(string sttde, int maxlen, char fillchar); |
MaxScorda | 6:f8c90e147000 | 115 | string addEOS(string sttde); |
MaxScorda | 6:f8c90e147000 | 116 | char* string2char(string sttde); |
MaxScorda | 7:80096ab72764 | 117 | char* createStr(char car); |
simon | 0:2bf27af3c759 | 118 | }; |
simon | 0:2bf27af3c759 | 119 | |
simon | 0:2bf27af3c759 | 120 | #endif |