VT52 is an enhancement of class Serial and offers some Methods for Printing in VT52 Terminal Style: clearScreen() - to clear the whole Terminal Screen clearLine() - to clear the current Line setCursor(lin, col) - to set cursor in column col of line lin
Test_VT52.cpp@0:6cb381075fe7, 2011-01-23 (annotated)
- Committer:
- Krugmann
- Date:
- Sun Jan 23 15:44:41 2011 +0000
- Revision:
- 0:6cb381075fe7
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Krugmann | 0:6cb381075fe7 | 1 | /******************************************************************** |
Krugmann | 0:6cb381075fe7 | 2 | * Project: Test_VT52 |
Krugmann | 0:6cb381075fe7 | 3 | * Program: Test_VT52.cpp |
Krugmann | 0:6cb381075fe7 | 4 | * Description: Print to PC-Terminal and PC-Log |
Krugmann | 0:6cb381075fe7 | 5 | * 2 Terminal Emulations (VT52) are needed at PC |
Krugmann | 0:6cb381075fe7 | 6 | * Serial Connection (p13, p14) is connected |
Krugmann | 0:6cb381075fe7 | 7 | * to RS232-USB Adapter |
Krugmann | 0:6cb381075fe7 | 8 | * |
Krugmann | 0:6cb381075fe7 | 9 | * Author: Rainer Krugmann |
Krugmann | 0:6cb381075fe7 | 10 | * Date: 2011.01.23 |
Krugmann | 0:6cb381075fe7 | 11 | ********************************************************************/ |
Krugmann | 0:6cb381075fe7 | 12 | |
Krugmann | 0:6cb381075fe7 | 13 | /* |
Krugmann | 0:6cb381075fe7 | 14 | |
Krugmann | 0:6cb381075fe7 | 15 | Copyright (c) 2011 Rainer Krugmann |
Krugmann | 0:6cb381075fe7 | 16 | (rainer (dot) krugmann [at] gmail [dot] com) |
Krugmann | 0:6cb381075fe7 | 17 | |
Krugmann | 0:6cb381075fe7 | 18 | Permission is hereby granted, free of charge, to any person obtaining a copy |
Krugmann | 0:6cb381075fe7 | 19 | of this software and associated documentation files (the "Software"), to deal |
Krugmann | 0:6cb381075fe7 | 20 | in the Software without restriction, including without limitation the rights |
Krugmann | 0:6cb381075fe7 | 21 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
Krugmann | 0:6cb381075fe7 | 22 | copies of the Software, and to permit persons to whom the Software is |
Krugmann | 0:6cb381075fe7 | 23 | furnished to do so, subject to the following conditions: |
Krugmann | 0:6cb381075fe7 | 24 | |
Krugmann | 0:6cb381075fe7 | 25 | The above copyright notice and this permission notice shall be included in |
Krugmann | 0:6cb381075fe7 | 26 | all copies or substantial portions of the Software. |
Krugmann | 0:6cb381075fe7 | 27 | |
Krugmann | 0:6cb381075fe7 | 28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Krugmann | 0:6cb381075fe7 | 29 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Krugmann | 0:6cb381075fe7 | 30 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
Krugmann | 0:6cb381075fe7 | 31 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
Krugmann | 0:6cb381075fe7 | 32 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
Krugmann | 0:6cb381075fe7 | 33 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
Krugmann | 0:6cb381075fe7 | 34 | THE SOFTWARE. |
Krugmann | 0:6cb381075fe7 | 35 | |
Krugmann | 0:6cb381075fe7 | 36 | */ |
Krugmann | 0:6cb381075fe7 | 37 | |
Krugmann | 0:6cb381075fe7 | 38 | #include "mbed.h" |
Krugmann | 0:6cb381075fe7 | 39 | #include "VT52.h" |
Krugmann | 0:6cb381075fe7 | 40 | |
Krugmann | 0:6cb381075fe7 | 41 | VT52 pc(USBTX, USBRX); // PC-Terminal |
Krugmann | 0:6cb381075fe7 | 42 | VT52 myLog(p13, p14); // PC-Terminal (Log) |
Krugmann | 0:6cb381075fe7 | 43 | |
Krugmann | 0:6cb381075fe7 | 44 | int main() { |
Krugmann | 0:6cb381075fe7 | 45 | |
Krugmann | 0:6cb381075fe7 | 46 | unsigned char c = 0; |
Krugmann | 0:6cb381075fe7 | 47 | |
Krugmann | 0:6cb381075fe7 | 48 | myLog.baud(9600); |
Krugmann | 0:6cb381075fe7 | 49 | myLog.clearScreen(); |
Krugmann | 0:6cb381075fe7 | 50 | myLog.printf("Hello World - Log\r\n"); |
Krugmann | 0:6cb381075fe7 | 51 | myLog.printf("=================\r\n\n"); |
Krugmann | 0:6cb381075fe7 | 52 | |
Krugmann | 0:6cb381075fe7 | 53 | pc.clearScreen(); |
Krugmann | 0:6cb381075fe7 | 54 | pc.printf("Hello World!\r\n"); |
Krugmann | 0:6cb381075fe7 | 55 | pc.printf("============\r\n\n"); |
Krugmann | 0:6cb381075fe7 | 56 | |
Krugmann | 0:6cb381075fe7 | 57 | pc.setCursor(12,3); |
Krugmann | 0:6cb381075fe7 | 58 | pc.printf("Press any Characters ('x' to Exit): "); |
Krugmann | 0:6cb381075fe7 | 59 | myLog.printf("Press any Characters ('x' to Exit)!\r\n"); |
Krugmann | 0:6cb381075fe7 | 60 | |
Krugmann | 0:6cb381075fe7 | 61 | while (c != 'x') |
Krugmann | 0:6cb381075fe7 | 62 | { |
Krugmann | 0:6cb381075fe7 | 63 | c = pc.getc(); |
Krugmann | 0:6cb381075fe7 | 64 | myLog.printf("You pressed: %c\r\n", c); |
Krugmann | 0:6cb381075fe7 | 65 | pc.putc(c); |
Krugmann | 0:6cb381075fe7 | 66 | } |
Krugmann | 0:6cb381075fe7 | 67 | pc.setCursor(12, 9); |
Krugmann | 0:6cb381075fe7 | 68 | pc.clearLine(); |
Krugmann | 0:6cb381075fe7 | 69 | myLog.printf("\nLine cleared after 'Press'\r\n"); |
Krugmann | 0:6cb381075fe7 | 70 | pc.setCursor(12, 9); |
Krugmann | 0:6cb381075fe7 | 71 | |
Krugmann | 0:6cb381075fe7 | 72 | pc.printf("nothing!"); |
Krugmann | 0:6cb381075fe7 | 73 | myLog.printf("Word 'nothing!' was printed\r\n"); |
Krugmann | 0:6cb381075fe7 | 74 | |
Krugmann | 0:6cb381075fe7 | 75 | pc.setCursor(23, 75); |
Krugmann | 0:6cb381075fe7 | 76 | pc.printf("End"); |
Krugmann | 0:6cb381075fe7 | 77 | myLog.printf("\nWord 'End' was printed screen bottom\r\n"); |
Krugmann | 0:6cb381075fe7 | 78 | myLog.printf("Cursor position is at screen end (line=23 and column = 79)\r\n"); |
Krugmann | 0:6cb381075fe7 | 79 | |
Krugmann | 0:6cb381075fe7 | 80 | myLog.printf("Program ends\r\n"); |
Krugmann | 0:6cb381075fe7 | 81 | while(1); |
Krugmann | 0:6cb381075fe7 | 82 | } |
Krugmann | 0:6cb381075fe7 | 83 | //******************************************************************* |