Rev 1145 Rev 1858
1 /*! \file vt100.c \brief VT100 terminal function library. */ 1 /*! \file vt100.c \brief VT100 terminal function library. */
2 //***************************************************************************** 2 //*****************************************************************************
3 // 3 //
4 // File Name : 'vt100.c' 4 // File Name : 'vt100.c'
5 // Title : VT100 terminal function library 5 // Title : VT100 terminal function library
6 // Author : Pascal Stang - Copyright (C) 2002 6 // Author : Pascal Stang - Copyright (C) 2002
7 // Created : 2002.08.27 7 // Created : 2002.08.27
8 // Revised : 2002.08.27 8 // Revised : 2002.08.27
9 // Version : 0.1 9 // Version : 0.1
10 // Target MCU : Atmel AVR Series 10 // Target MCU : Atmel AVR Series
11 // Editor Tabs : 4 11 // Editor Tabs : 4
12 // 12 //
13 // NOTE: This code is currently below version 1.0, and therefore is considered 13 // NOTE: This code is currently below version 1.0, and therefore is considered
14 // to be lacking in some functionality or documentation, or may not be fully 14 // to be lacking in some functionality or documentation, or may not be fully
15 // tested. Nonetheless, you can expect most functions to work. 15 // tested. Nonetheless, you can expect most functions to work.
16 // 16 //
17 // This code is distributed under the GNU Public License 17 // This code is distributed under the GNU Public License
18 // which can be found at http://www.gnu.org/licenses/gpl.txt 18 // which can be found at http://www.gnu.org/licenses/gpl.txt
19 // 19 //
20 //***************************************************************************** 20 //*****************************************************************************
21   21  
22 #include <avr/io.h> 22 #include <avr/io.h>
23 #include <avr/interrupt.h> 23 #include <avr/interrupt.h>
24 #include <avr/pgmspace.h> 24 #include <avr/pgmspace.h>
25   25  
26 #include "global.h" 26 #include "global.h"
27 #include "rprintf.h" 27 #include "rprintf.h"
28 #include "vt100.h" 28 #include "vt100.h"
29   29  
30 // Program ROM constants 30 // Program ROM constants
31   31  
32 // Global variables 32 // Global variables
33   33  
34 // Functions 34 // Functions
35 void vt100Init(void) 35 void vt100Init(void)
36 { 36 {
37 // initializes terminal to "power-on" settings 37 // initializes terminal to "power-on" settings
38 // ESC c 38 // ESC c
39 rprintfProgStrM("\x1B\x63"); 39 rprintfProgStrM("\x1B\x63");
40 } 40 }
41   41  
42 void vt100ClearScreen(void) 42 void vt100ClearScreen(void)
43 { 43 {
44 // ESC [ 2 J 44 // ESC [ 2 J
45 rprintfProgStrM("\x1B[2J"); 45 rprintfProgStrM("\x1B[2J");
46 } 46 }
47   47  
48 void vt100SetAttr(u08 attr) 48 void vt100SetAttr(u08 attr)
49 { 49 {
50 // ESC [ Ps m 50 // ESC [ Ps m
51 rprintf("\x1B[%dm",attr); 51 rprintf("\x1B[%dm",attr);
52 } 52 }
53   53  
54 void vt100SetCursorMode(u08 visible) 54 void vt100SetCursorMode(u08 visible)
55 { 55 {
56 if(visible) 56 if(visible)
57 // ESC [ ? 25 h 57 // ESC [ ? 25 h
58 rprintf("\x1B[?25h"); 58 rprintf("\x1B[?25h");
59 else 59 else
60 // ESC [ ? 25 l 60 // ESC [ ? 25 l
61 rprintf("\x1B[?25l"); 61 rprintf("\x1B[?25l");
62 } 62 }
63   63  
64 void vt100SetCursorPos(u08 line, u08 col) 64 void vt100SetCursorPos(u08 line, u08 col)
65 { 65 {
66 // ESC [ Pl ; Pc H 66 // ESC [ Pl ; Pc H
67 rprintf("\x1B[%d;%dH",line,col); 67 rprintf("\x1B[%d;%dH",line,col);
68 } 68 }
69   69