added size option to text driver

This commit is contained in:
reenoo
2004-03-21 15:21:25 +00:00
parent 428ae90c49
commit 7e9e57493c
3 changed files with 30 additions and 4 deletions
+2 -1
View File
@@ -516,7 +516,8 @@ Arguments="fill in here"
[text]
# Text driver
# No options
# Set the display size [20x4]
size=20x4
+27 -3
View File
@@ -4,6 +4,21 @@
* Displays LCD screens, one after another; suitable for hard-copy
* terminals.
*
* Copyright (C) 1998-2004 The LCDproc Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
*/
#ifdef HAVE_CONFIG_H
@@ -18,6 +33,7 @@
#include "lcd.h"
#include "text.h"
#include "report.h"
//#include "drv_base.h"
@@ -40,6 +56,8 @@ MODULE_EXPORT char *symbol_prefix = "text_";
MODULE_EXPORT int
text_init (Driver *drvthis, char *args)
{
char buf[256];
// Set display sizes
if( drvthis->request_display_width() > 0
&& drvthis->request_display_height() > 0 ) {
@@ -48,9 +66,15 @@ text_init (Driver *drvthis, char *args)
height = drvthis->request_display_height();
}
else {
// Use default size
width = LCD_DEFAULT_WIDTH;
height = LCD_DEFAULT_HEIGHT;
/* Use our own size from config file */
strncpy(buf, drvthis->config_get_string ( drvthis->name , "size" , 0 , TEXTDRV_DEFAULT_SIZE), sizeof(buf));
buf[sizeof(buf)-1]=0;
if( sscanf(buf , "%dx%d", &width, &height ) != 2
|| (width <= 0)
|| (height <= 0)) {
report (RPT_WARNING, "TEXT: Cannot read size: %s. Using default value: %s\n", buf, TEXTDRV_DEFAULT_SIZE);
sscanf( TEXTDRV_DEFAULT_SIZE, "%dx%d", &width, &height );
}
}
// Allocate the framebuffer
+1
View File
@@ -14,5 +14,6 @@ MODULE_EXPORT void text_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void text_set_contrast (Driver *drvthis, int promille);
MODULE_EXPORT void text_backlight (Driver *drvthis, int on);
#define TEXTDRV_DEFAULT_SIZE "20x4"
#endif