aboutsummaryrefslogtreecommitdiffstats
path: root/Cwlinux.c
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2003-09-09 06:54:43 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2003-09-09 06:54:43 +0000
commitdd4d20ad1a3970752a4fe81c95c164bf751c0f16 (patch)
treec78e80eb3a22e818c6039ca5aa68c7f46000fd94 /Cwlinux.c
parentca55019e85e081afe878a93ba0dc83a44d862de9 (diff)
downloadlcd4linux-dd4d20ad1a3970752a4fe81c95c164bf751c0f16.tar.gz
[lcd4linux @ 2003-09-09 06:54:43 by reinelt]
new function 'cfg_number()' git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@233 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'Cwlinux.c')
-rw-r--r--Cwlinux.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/Cwlinux.c b/Cwlinux.c
index bd61317..affffc9 100644
--- a/Cwlinux.c
+++ b/Cwlinux.c
@@ -1,4 +1,4 @@
-/* $Id: Cwlinux.c,v 1.12 2003/08/24 05:17:58 reinelt Exp $
+/* $Id: Cwlinux.c,v 1.13 2003/09/09 06:54:43 reinelt Exp $
*
* driver for Cwlinux serial display modules
*
@@ -20,6 +20,9 @@
*
*
* $Log: Cwlinux.c,v $
+ * Revision 1.13 2003/09/09 06:54:43 reinelt
+ * new function 'cfg_number()'
+ *
* Revision 1.12 2003/08/24 05:17:58 reinelt
* liblcd4linux patch from Patrick Schemitz
*
@@ -242,10 +245,8 @@ static void CW_Brightness(void)
{
int level;
char cmd[5]="\376A_\375";
-
- level=atoi(cfg_get("Brightness","8"));
- if (level<0) level=0;
- if (level>8) level=8;
+
+ if (cfg_number("Brightness", 8, 0, 8, &level)<0) return;
switch (level) {
case 0:
@@ -268,7 +269,7 @@ static void CW_Brightness(void)
int CW_init(LCD * Self)
{
char *port;
- char *speed;
+ int speed;
// char buffer[16];
Lcd = *Self;
@@ -293,9 +294,8 @@ int CW_init(LCD * Self)
}
Port = strdup(port);
- speed = cfg_get("Speed","19200");
-
- switch (atoi(speed)) {
+ if (cfg_number("Speed", 19200, 9600,19200, &speed)<0) return -1;
+ switch (speed) {
case 9600:
Speed = B9600;
break;
@@ -303,11 +303,11 @@ int CW_init(LCD * Self)
Speed = B19200;
break;
default:
- error("Cwlinux: unsupported speed '%s' in %s", speed, cfg_source());
+ error("Cwlinux: unsupported speed '%d' in %s", speed, cfg_source());
return -1;
}
- debug("using port %s at %d baud", Port, atoi(speed));
+ debug("using port %s at %d baud", Port, speed);
Device = CW_open();
if (Device == -1)