26
31
static void text_chr (int x, int y, char c);
27
32
static int text_contrast (int contrast);
28
33
static void text_backlight (int on);
29
//static void text_init_vbar ();
30
//static void text_init_hbar ();
31
//static void text_init_num ();
34
/* static void text_init_vbar ();
35
* static void text_init_hbar ();
36
* static void text_init_num ();
32
38
static void text_vbar (int x, int len);
33
39
static void text_hbar (int x, int y, int len);
34
40
static void text_num (int x, int num);
35
//static void text_set_char (int n, char *dat);
36
//static void text_flush_box (int lft, int top, int rgt, int bot);
41
/* static void text_set_char (int n, char *dat);
42
* static void text_flush_box (int lft, int top, int rgt, int bot);
37
44
static void text_draw_frame (char *dat);
39
46
/* Ugly code extracted by David GLAUDE from lcdm001.c ;)*/
82
89
lcd_logical_driver *text;
84
//////////////////////////////////////////////////////////////////////////
85
////////////////////// For Text-Mode Output //////////////////////////////
86
//////////////////////////////////////////////////////////////////////////
88
#define LCD_DEFAULT_WIDTH 20
89
#define LCD_DEFAULT_HEIGHT 4
90
// The two value below are fake, we don't support custom char.
92
* For Text-Mode Output
96
#define TEXTDRV_DEF_SIZE "20x4"
98
/* The two value below are fake, we don't support custom char. */
91
99
#define LCD_DEFAULT_CELL_WIDTH 5
92
100
#define LCD_DEFAULT_CELL_HEIGHT 8
94
// TODO: When using the text driver, ^C fails to interrupt!
96
// DONE??? Are you sure, not in my Konsole. David GLAUDE
102
/* To verify: When using the text driver, ^C fails to interrupt! */
99
104
text_init (lcd_logical_driver * driver, char *args)
103
// Make sure the frame buffer is there...
111
/* TODO?: replace DriverName with driver->name when that field exists.*/
112
#define DriverName "text"
114
/*Get settings from config file*/
116
/*Get size settings*/
117
strncpy(buf, config_get_string ( DriverName , "Size" , 0 , TEXTDRV_DEF_SIZE), sizeof(buf));
118
buf[sizeof(buf)-1]=0;
119
if( sscanf(buf , "%dx%d", &wid, &hgt ) != 2
122
report (RPT_WARNING, "TEXT: Cannot read size: %s. Using default value %s.\n", buf, TEXTDRV_DEF_SIZE);
123
sscanf( TEXTDRV_DEF_SIZE , "%dx%d", &wid, &hgt );
128
/* Make sure the frame buffer is there... */
104
129
if (!text->framebuf)
105
130
text->framebuf = (unsigned char *)
106
131
malloc (text->wid * text->hgt);
107
132
memset (text->framebuf, ' ', text->wid * text->hgt);
110
// Set the functions the driver supports
135
/* Set the functions the driver supports */
112
text->wid = LCD_DEFAULT_WIDTH;
113
text->hgt = LCD_DEFAULT_HEIGHT;
114
137
text->cellwid = LCD_DEFAULT_CELL_WIDTH;
115
138
text->cellhgt = LCD_DEFAULT_CELL_HEIGHT;
118
141
text->string = text_string;
119
142
text->chr = text_chr;
120
143
text->vbar = text_vbar;
121
//text->init_vbar = NULL;
144
/* text->init_vbar = NULL; */
122
145
text->hbar = text_hbar;
123
//text->init_hbar = NULL;
146
/* text->init_hbar = NULL; */
124
147
text->num = text_num;
125
//text->init_num = NULL;
148
/* text->init_num = NULL; */
127
150
text->init = text_init;
128
151
text->close = text_close;
129
152
text->flush = text_flush;
130
//text->flush_box = NULL;
131
//text->contrast = NULL;
132
//text->backlight = NULL;
133
//text->set_char = NULL;
153
/* text->flush_box = NULL; */
154
/* text->contrast = NULL; */
155
/* text->backlight = NULL; */
156
/* text->set_char = NULL; */
157
/* text->icon = NULL; */
135
158
text->draw_frame = text_draw_frame;
137
//text->getkey = NULL;
160
/* text->getkey = NULL; */
139
return 200; // 200 is arbitrary. (must be 1 or more)
162
return 200; /* 200 is arbitrary. (must be 1 or more) */
148
171
text->framebuf = NULL;
151
/////////////////////////////////////////////////////////////////
152
// Clears the LCD screen
174
/* Clears the LCD screen */
157
178
memset (text->framebuf, ' ', text->wid * text->hgt);
160
//////////////////////////////////////////////////////////////////
161
// Flushes all output to the lcd...
181
/* Flushes all output to the lcd... */
166
185
text_draw_frame (text->framebuf);
169
/////////////////////////////////////////////////////////////////
170
// Prints a string on the lcd display, at position (x,y). The
171
// upper-left is (1,1), and the lower right should be (20,4).
188
/* Prints a string on the lcd display, at position (x,y). The
189
upper-left is (1,1), and the lower right should be (20,4). */
174
191
text_string (int x, int y, char string[])
178
x--; y--; // Convert 1-based coords to 0-based...
195
x--; y--; /* Convert 1-based coords to 0-based... */
197
/* Convert NULLs and 0xFF in string to valid printables... */
180
199
for (i = 0; string[i]; i++) {
201
/* case 0: -- can never happen?
205
case -1: /* This magicaly translate to 255 */
181
209
text->framebuf[(y * text->wid) + x + i] = string[i];
185
/////////////////////////////////////////////////////////////////
186
// Prints a character on the lcd display, at position (x,y). The
187
// upper-left is (1,1), and the lower right should be (20,4).
214
/* Prints a character on the lcd display, at position (x,y). The
215
upper-left is (1,1), and the lower right should be (20,4). */
190
217
text_chr (int x, int y, char c)
228
case -1: /* translates to 255 (ouch!) */
194
237
text->framebuf[(y * text->wid) + x] = c;
198
246
text_contrast (int contrast)
200
// printf("Contrast: %i\n", contrast);
205
252
text_backlight (int on)
210
printf("Backlight ON\n");
214
printf("Backlight OFF\n");
222
//// printf("Vertical bars.\n");
228
//// printf("Horizontal bars.\n");
234
//// printf("Big Numbers.\n");
237
/////////////////////////////////////////////////////////////////
238
// Writes a big number. (by Rene Wagner from lcdm001.c)
256
/* Writes a big number. (by Rene Wagner from lcdm001.c) */
240
257
static void text_num (int x, int num)
244
// printf("BigNum(%i, %i)\n", x, num);
245
261
for (y = 1; y < 5; y++)
246
262
for (dx = 0; dx < 3; dx++)
247
263
text_chr (x + dx, y, num_icon[num][y-1][dx]);
251
//text_set_char (int n, char *dat)
253
//// printf("Set Character %i\n", n);
256
/////////////////////////////////////////////////////////////////
257
// Draws a vertical bar; erases entire column onscreen.
266
/* Draws a vertical bar; erases entire column onscreen. */
260
268
text_vbar (int x, int len)