Serial class med valgfri baudrate
Dependents: Fancy-Terminal-Menu Fancy-Terminal
SerialTerminal.h@0:f7f6e3220ea0, 2015-10-16 (annotated)
- Committer:
- madmonkeyman82
- Date:
- Fri Oct 16 15:39:16 2015 +0000
- Revision:
- 0:f7f6e3220ea0
- Child:
- 2:64e7d86dbac1
Serial class with baud speed options
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
madmonkeyman82 | 0:f7f6e3220ea0 | 1 | #include "mbed.h" |
madmonkeyman82 | 0:f7f6e3220ea0 | 2 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 3 | #ifndef MBED_TERMINAL_H |
madmonkeyman82 | 0:f7f6e3220ea0 | 4 | #define MBED_TERMINAL_H |
madmonkeyman82 | 0:f7f6e3220ea0 | 5 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 6 | /** Control and display on an ANSI/VT100 Terminal |
madmonkeyman82 | 0:f7f6e3220ea0 | 7 | * |
madmonkeyman82 | 0:f7f6e3220ea0 | 8 | * This allows you to control an ANSI serial terminal |
madmonkeyman82 | 0:f7f6e3220ea0 | 9 | */ |
madmonkeyman82 | 0:f7f6e3220ea0 | 10 | class SerialTerminal : public Serial { |
madmonkeyman82 | 0:f7f6e3220ea0 | 11 | public: |
madmonkeyman82 | 0:f7f6e3220ea0 | 12 | /** Create the Terminal interface |
madmonkeyman82 | 0:f7f6e3220ea0 | 13 | * |
madmonkeyman82 | 0:f7f6e3220ea0 | 14 | * @param tx Serial transmit |
madmonkeyman82 | 0:f7f6e3220ea0 | 15 | * @param rx Serial recieve |
madmonkeyman82 | 0:f7f6e3220ea0 | 16 | * @param baud Serial baudreate speed |
madmonkeyman82 | 0:f7f6e3220ea0 | 17 | */ |
madmonkeyman82 | 0:f7f6e3220ea0 | 18 | SerialTerminal(PinName tx, PinName rx, int baudrate); |
madmonkeyman82 | 0:f7f6e3220ea0 | 19 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 20 | #if DOXYGEN_ONLY |
madmonkeyman82 | 0:f7f6e3220ea0 | 21 | /** Write a character to the terminal |
madmonkeyman82 | 0:f7f6e3220ea0 | 22 | * |
madmonkeyman82 | 0:f7f6e3220ea0 | 23 | * @param c The character to write to the display |
madmonkeyman82 | 0:f7f6e3220ea0 | 24 | */ |
madmonkeyman82 | 0:f7f6e3220ea0 | 25 | int putc(int c); |
madmonkeyman82 | 0:f7f6e3220ea0 | 26 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 27 | /** Write a formated string to the terminal |
madmonkeyman82 | 0:f7f6e3220ea0 | 28 | * |
madmonkeyman82 | 0:f7f6e3220ea0 | 29 | * @param format A printf-style format string, followed by the |
madmonkeyman82 | 0:f7f6e3220ea0 | 30 | * variables to use in formating the string. |
madmonkeyman82 | 0:f7f6e3220ea0 | 31 | */ |
madmonkeyman82 | 0:f7f6e3220ea0 | 32 | int printf(const char* format, ...); |
madmonkeyman82 | 0:f7f6e3220ea0 | 33 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 34 | // also baud etc |
madmonkeyman82 | 0:f7f6e3220ea0 | 35 | #endif |
madmonkeyman82 | 0:f7f6e3220ea0 | 36 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 37 | /** Locate to a screen column and row |
madmonkeyman82 | 0:f7f6e3220ea0 | 38 | * |
madmonkeyman82 | 0:f7f6e3220ea0 | 39 | * @param column The horizontal position from the left, indexed from 0 |
madmonkeyman82 | 0:f7f6e3220ea0 | 40 | * @param row The vertical position from the top, indexed from 0 |
madmonkeyman82 | 0:f7f6e3220ea0 | 41 | */ |
madmonkeyman82 | 0:f7f6e3220ea0 | 42 | void locate(int column, int row); |
madmonkeyman82 | 0:f7f6e3220ea0 | 43 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 44 | /** Clear the screen and locate to 0,0 */ |
madmonkeyman82 | 0:f7f6e3220ea0 | 45 | void cls(); |
madmonkeyman82 | 0:f7f6e3220ea0 | 46 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 47 | /** Set the foreground colour */ |
madmonkeyman82 | 0:f7f6e3220ea0 | 48 | void foreground(int colour); |
madmonkeyman82 | 0:f7f6e3220ea0 | 49 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 50 | /** Set the background colour */ |
madmonkeyman82 | 0:f7f6e3220ea0 | 51 | void background(int colour); |
madmonkeyman82 | 0:f7f6e3220ea0 | 52 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 53 | /** Hide Cursor from terminal*/ |
madmonkeyman82 | 0:f7f6e3220ea0 | 54 | void hideCursor(); |
madmonkeyman82 | 0:f7f6e3220ea0 | 55 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 56 | /** Hide Cursor from terminal*/ |
madmonkeyman82 | 0:f7f6e3220ea0 | 57 | void showCursor(); |
madmonkeyman82 | 0:f7f6e3220ea0 | 58 | }; |
madmonkeyman82 | 0:f7f6e3220ea0 | 59 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 60 | #endif |