Serial class med valgfri baudrate
Dependents: Fancy-Terminal-Menu Fancy-Terminal
SerialTerminal.h@2:64e7d86dbac1, 2015-10-16 (annotated)
- Committer:
- madmonkeyman82
- Date:
- Fri Oct 16 16:31:49 2015 +0000
- Revision:
- 2:64e7d86dbac1
- Parent:
- 0:f7f6e3220ea0
fixup;
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 | 2:64e7d86dbac1 | 6 | /** Control and display on an ANSI/VT100 Terminal (puTTy or similar...) |
madmonkeyman82 | 0:f7f6e3220ea0 | 7 | * |
madmonkeyman82 | 0:f7f6e3220ea0 | 8 | * This allows you to control an ANSI serial terminal |
madmonkeyman82 | 2:64e7d86dbac1 | 9 | * Set TX pin and RX . also spesify bauderate if needed different than default 9600 |
madmonkeyman82 | 0:f7f6e3220ea0 | 10 | */ |
madmonkeyman82 | 0:f7f6e3220ea0 | 11 | class SerialTerminal : public Serial { |
madmonkeyman82 | 0:f7f6e3220ea0 | 12 | public: |
madmonkeyman82 | 0:f7f6e3220ea0 | 13 | /** Create the Terminal interface |
madmonkeyman82 | 0:f7f6e3220ea0 | 14 | * |
madmonkeyman82 | 0:f7f6e3220ea0 | 15 | * @param tx Serial transmit |
madmonkeyman82 | 0:f7f6e3220ea0 | 16 | * @param rx Serial recieve |
madmonkeyman82 | 2:64e7d86dbac1 | 17 | * @param baud Serial baudreate speed (default 9600) |
madmonkeyman82 | 0:f7f6e3220ea0 | 18 | */ |
madmonkeyman82 | 2:64e7d86dbac1 | 19 | SerialTerminal(PinName tx, PinName rx, int baudrate=9600); |
madmonkeyman82 | 0:f7f6e3220ea0 | 20 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 21 | #if DOXYGEN_ONLY |
madmonkeyman82 | 0:f7f6e3220ea0 | 22 | /** Write a character to the terminal |
madmonkeyman82 | 0:f7f6e3220ea0 | 23 | * |
madmonkeyman82 | 0:f7f6e3220ea0 | 24 | * @param c The character to write to the display |
madmonkeyman82 | 0:f7f6e3220ea0 | 25 | */ |
madmonkeyman82 | 0:f7f6e3220ea0 | 26 | int putc(int c); |
madmonkeyman82 | 0:f7f6e3220ea0 | 27 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 28 | /** Write a formated string to the terminal |
madmonkeyman82 | 0:f7f6e3220ea0 | 29 | * |
madmonkeyman82 | 0:f7f6e3220ea0 | 30 | * @param format A printf-style format string, followed by the |
madmonkeyman82 | 0:f7f6e3220ea0 | 31 | * variables to use in formating the string. |
madmonkeyman82 | 0:f7f6e3220ea0 | 32 | */ |
madmonkeyman82 | 0:f7f6e3220ea0 | 33 | int printf(const char* format, ...); |
madmonkeyman82 | 0:f7f6e3220ea0 | 34 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 35 | // also baud etc |
madmonkeyman82 | 0:f7f6e3220ea0 | 36 | #endif |
madmonkeyman82 | 0:f7f6e3220ea0 | 37 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 38 | /** Locate to a screen column and row |
madmonkeyman82 | 0:f7f6e3220ea0 | 39 | * |
madmonkeyman82 | 0:f7f6e3220ea0 | 40 | * @param column The horizontal position from the left, indexed from 0 |
madmonkeyman82 | 0:f7f6e3220ea0 | 41 | * @param row The vertical position from the top, indexed from 0 |
madmonkeyman82 | 0:f7f6e3220ea0 | 42 | */ |
madmonkeyman82 | 0:f7f6e3220ea0 | 43 | void locate(int column, int row); |
madmonkeyman82 | 0:f7f6e3220ea0 | 44 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 45 | /** Clear the screen and locate to 0,0 */ |
madmonkeyman82 | 0:f7f6e3220ea0 | 46 | void cls(); |
madmonkeyman82 | 0:f7f6e3220ea0 | 47 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 48 | /** Set the foreground colour */ |
madmonkeyman82 | 0:f7f6e3220ea0 | 49 | void foreground(int colour); |
madmonkeyman82 | 0:f7f6e3220ea0 | 50 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 51 | /** Set the background colour */ |
madmonkeyman82 | 0:f7f6e3220ea0 | 52 | void background(int colour); |
madmonkeyman82 | 0:f7f6e3220ea0 | 53 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 54 | /** Hide Cursor from terminal*/ |
madmonkeyman82 | 0:f7f6e3220ea0 | 55 | void hideCursor(); |
madmonkeyman82 | 0:f7f6e3220ea0 | 56 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 57 | /** Hide Cursor from terminal*/ |
madmonkeyman82 | 0:f7f6e3220ea0 | 58 | void showCursor(); |
madmonkeyman82 | 0:f7f6e3220ea0 | 59 | }; |
madmonkeyman82 | 0:f7f6e3220ea0 | 60 | |
madmonkeyman82 | 0:f7f6e3220ea0 | 61 | #endif |