added fxs to class

Dependents:   ard2pmod_demo MAXREFDES130_Demo OneWire_DS18B20_Demo MAXREFDES132_OneWire_Demo

Fork of Terminal by Simon Ford

Committer:
j3
Date:
Sat Mar 25 19:10:15 2017 +0000
Revision:
8:9ab22fc6e88b
Parent:
6:419eea2fe960
Updated get user input fxs to support systems that use CR+LF, CR, or just LF.;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon 1:96ae39e58792 1 /* mbed Terminal Library, for ANSI/VT200 Terminals and ecape codes
simon 2:85184c13476c 2 * Copyright (c) 2007-2010, sford, http://mbed.org
simon 1:96ae39e58792 3 *
simon 1:96ae39e58792 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
simon 1:96ae39e58792 5 * of this software and associated documentation files (the "Software"), to deal
simon 1:96ae39e58792 6 * in the Software without restriction, including without limitation the rights
simon 1:96ae39e58792 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
simon 1:96ae39e58792 8 * copies of the Software, and to permit persons to whom the Software is
simon 1:96ae39e58792 9 * furnished to do so, subject to the following conditions:
simon 0:2bf27af3c759 10 *
simon 1:96ae39e58792 11 * The above copyright notice and this permission notice shall be included in
simon 1:96ae39e58792 12 * all copies or substantial portions of the Software.
simon 1:96ae39e58792 13 *
simon 1:96ae39e58792 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
simon 1:96ae39e58792 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
simon 1:96ae39e58792 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
simon 1:96ae39e58792 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
simon 1:96ae39e58792 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
simon 1:96ae39e58792 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
simon 1:96ae39e58792 20 * THE SOFTWARE.
simon 0:2bf27af3c759 21 */
simon 0:2bf27af3c759 22
j3 6:419eea2fe960 23
j3 6:419eea2fe960 24 #include <string>
simon 0:2bf27af3c759 25 #include "mbed.h"
simon 0:2bf27af3c759 26
simon 0:2bf27af3c759 27 #ifndef MBED_TERMINAL_H
simon 0:2bf27af3c759 28 #define MBED_TERMINAL_H
simon 0:2bf27af3c759 29
simon 2:85184c13476c 30 /** Control and display on an ANSI/VT100 Terminal
simon 2:85184c13476c 31 *
simon 2:85184c13476c 32 * This allows you to control an ANSI serial terminal
simon 2:85184c13476c 33 */
simon 0:2bf27af3c759 34 class Terminal : public Serial {
simon 0:2bf27af3c759 35 public:
simon 1:96ae39e58792 36 /** Create the Terminal interface
simon 1:96ae39e58792 37 *
simon 1:96ae39e58792 38 * @param tx Serial transmit
simon 1:96ae39e58792 39 * @param rx Serial recieve
simon 1:96ae39e58792 40 */
simon 0:2bf27af3c759 41 Terminal(PinName tx, PinName rx);
simon 0:2bf27af3c759 42
simon 1:96ae39e58792 43 #if DOXYGEN_ONLY
simon 1:96ae39e58792 44 /** Write a character to the terminal
simon 1:96ae39e58792 45 *
simon 1:96ae39e58792 46 * @param c The character to write to the display
simon 1:96ae39e58792 47 */
simon 1:96ae39e58792 48 int putc(int c);
simon 0:2bf27af3c759 49
simon 1:96ae39e58792 50 /** Write a formated string to the terminal
simon 1:96ae39e58792 51 *
simon 1:96ae39e58792 52 * @param format A printf-style format string, followed by the
simon 1:96ae39e58792 53 * variables to use in formating the string.
simon 1:96ae39e58792 54 */
simon 1:96ae39e58792 55 int printf(const char* format, ...);
simon 1:96ae39e58792 56
simon 1:96ae39e58792 57 // also baud etc
simon 1:96ae39e58792 58 #endif
simon 1:96ae39e58792 59
simon 1:96ae39e58792 60 /** Locate to a screen column and row
simon 1:96ae39e58792 61 *
simon 1:96ae39e58792 62 * @param column The horizontal position from the left, indexed from 0
simon 1:96ae39e58792 63 * @param row The vertical position from the top, indexed from 0
simon 1:96ae39e58792 64 */
simon 1:96ae39e58792 65 void locate(int column, int row);
simon 1:96ae39e58792 66
simon 1:96ae39e58792 67 /** Clear the screen and locate to 0,0 */
simon 0:2bf27af3c759 68 void cls();
j3 4:4510b10fb5d9 69
j3 4:4510b10fb5d9 70 void home();
simon 1:96ae39e58792 71
simon 1:96ae39e58792 72 /** Set the foreground colour */
simon 0:2bf27af3c759 73 void foreground(int colour);
simon 1:96ae39e58792 74
simon 1:96ae39e58792 75 /** Set the background colour */
simon 0:2bf27af3c759 76 void background(int colour);
j3 3:7c269f52ad77 77
j3 5:5d3dc5f8f7b4 78 /** Get integer value from user
j3 5:5d3dc5f8f7b4 79 *
j3 5:5d3dc5f8f7b4 80 * @param msg - User prompt
j3 5:5d3dc5f8f7b4 81 * @param min_val - minimum value of input range
j3 5:5d3dc5f8f7b4 82 * @param max_val - maximum value of input range
j3 5:5d3dc5f8f7b4 83 */
j3 3:7c269f52ad77 84 int32_t get_int32(const char *msg, const int32_t min_val, const int32_t max_val);
j3 3:7c269f52ad77 85
j3 5:5d3dc5f8f7b4 86 /** Get char value from user
j3 5:5d3dc5f8f7b4 87 *
j3 5:5d3dc5f8f7b4 88 * @param msg - User prompt
j3 5:5d3dc5f8f7b4 89 * @param min_val - minimum value of input range
j3 5:5d3dc5f8f7b4 90 * @param max_val - maximum value of input range
j3 5:5d3dc5f8f7b4 91 */
j3 3:7c269f52ad77 92 char get_char(const char *msg, const char min_val, const char max_val);
j3 6:419eea2fe960 93
j3 6:419eea2fe960 94 /**Get Float from user
j3 6:419eea2fe960 95 *
j3 6:419eea2fe960 96 * @param msg - User prompt
j3 6:419eea2fe960 97 * @param min_val - minimum value of input range
j3 6:419eea2fe960 98 * @param max_val - maximum value of input range
j3 6:419eea2fe960 99 */
j3 6:419eea2fe960 100 float get_float(const char *msg, const float min_val, const float max_val);
simon 0:2bf27af3c759 101 };
simon 0:2bf27af3c759 102
simon 0:2bf27af3c759 103 #endif