aboutsummaryrefslogtreecommitdiffstats
path: root/MatrixOrbital.c
diff options
context:
space:
mode:
authorreinelt <>2003-09-09 06:54:43 +0000
committerreinelt <>2003-09-09 06:54:43 +0000
commitb1f5fffddaf31835515f88859f8a4670b6252deb (patch)
treec78e80eb3a22e818c6039ca5aa68c7f46000fd94 /MatrixOrbital.c
parentb39a42b909dfb1c174044cf977d272f94445b18e (diff)
downloadlcd4linux-b1f5fffddaf31835515f88859f8a4670b6252deb.tar.gz
[lcd4linux @ 2003-09-09 06:54:43 by reinelt]
new function 'cfg_number()'
Diffstat (limited to 'MatrixOrbital.c')
-rw-r--r--MatrixOrbital.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/MatrixOrbital.c b/MatrixOrbital.c
index f27b04a..2c0a193 100644
--- a/MatrixOrbital.c
+++ b/MatrixOrbital.c
@@ -1,4 +1,4 @@
-/* $Id: MatrixOrbital.c,v 1.36 2003/09/09 05:30:33 reinelt Exp $
+/* $Id: MatrixOrbital.c,v 1.37 2003/09/09 06:54:43 reinelt Exp $
*
* driver for Matrix Orbital serial display modules
*
@@ -20,6 +20,9 @@
*
*
* $Log: MatrixOrbital.c,v $
+ * Revision 1.37 2003/09/09 06:54:43 reinelt
+ * new function 'cfg_number()'
+ *
* Revision 1.36 2003/09/09 05:30:33 reinelt
* even more icons stuff
*
@@ -255,7 +258,7 @@ static int MO_contrast (void)
char buffer[4];
int contrast;
- contrast=atoi(cfg_get("Contrast","160"));
+ if (cfg_number("Contrast", 160, 0, 255, &contrast)<0) return -1;
snprintf (buffer, 4, "\376P%c", contrast);
MO_write (buffer, 3);
return 0;
@@ -317,7 +320,7 @@ int MO_clear2 (int full)
static int MO_init (LCD *Self, int protocol)
{
char *port;
- char *s, *e;
+ int speed;
Lcd=*Self;
@@ -341,9 +344,8 @@ static int MO_init (LCD *Self, int protocol)
}
Port=strdup(port);
- s=cfg_get("Speed","19200");
-
- switch (atoi(s)) {
+ if (cfg_number("Speed", 19200, 1200,19200, &speed)<0) return -1;
+ switch (speed) {
case 1200:
Speed=B1200;
break;
@@ -357,28 +359,23 @@ static int MO_init (LCD *Self, int protocol)
Speed=B19200;
break;
default:
- error ("MatrixOrbital: unsupported speed '%s' in %s", s, cfg_source());
+ error ("MatrixOrbital: unsupported speed '%d' in %s", speed, cfg_source());
return -1;
}
-
- debug ("using port %s at %d baud", Port, atoi(s));
-
+
+ debug ("using port %s at %d baud", Port, speed);
+
Device=MO_open();
if (Device==-1) return -1;
- s=cfg_get("Icons", "0");
- Icons=strtol(s, &e, 0);
- if (*e!='\0' || Icons<0 || Icons>8) {
- error ("MatrixOrbital: bad Icons '%s' in %s, must be between 0 and 8", s, cfg_source());
- return -1;
- }
+ if (cfg_number("Icons", 0, 0, 8, &Icons)<0) return -1;
if (Icons>0) {
info ("reserving %d of %d user-defined characters for icons", Icons, CHARS);
icon_init(Lcd.rows, Lcd.cols, XRES, YRES, CHARS, Icons, MO_define_char);
Self->icons=Icons;
Lcd.icons=Icons;
}
-
+
bar_init(Lcd.rows, Lcd.cols, XRES, YRES, CHARS-Icons);
bar_add_segment( 0, 0,255, 32); // ASCII 32 = blank
bar_add_segment(255,255,255,255); // ASCII 255 = block