aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreinelt <>2004-01-18 21:25:16 +0000
committerreinelt <>2004-01-18 21:25:16 +0000
commit928b0e09a5725abfd53421f19e5e53845e7aa100 (patch)
tree9d47c4f079c67ebc5feda0535d82ab2b734552cd
parent6c86643d7e174294488e42c5f0404f5a6244668f (diff)
downloadlcd4linux-928b0e09a5725abfd53421f19e5e53845e7aa100.tar.gz
[lcd4linux @ 2004-01-18 21:25:16 by reinelt]
Framework for bar widget opened
Diffstat (limited to '')
-rw-r--r--Makefile.am3
-rw-r--r--Makefile.in25
-rw-r--r--drv_MatrixOrbital.c30
-rw-r--r--widget_bar.c136
-rw-r--r--widget_bar.h49
5 files changed, 225 insertions, 18 deletions
diff --git a/Makefile.am b/Makefile.am
index 44755d7..d0b5732 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -25,7 +25,8 @@ layout.c layout.h \
timer.c timer.h \
evaluator.c evaluator.h \
widget.c widget.h \
-widget_text.c \
+widget_text.c widget_text.h \
+widget_bar.c widget_bar.h \
plugin.c plugin.h \
plugin_math.c \
plugin_string.c \
diff --git a/Makefile.in b/Makefile.in
index 40bda22..9d903e3 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -106,7 +106,7 @@ lcd4linux_LDADD = @DRIVERS@ @DRVLIBS@
#remove next line for liblcd4linux
lcd4linux_DEPENDENCIES = @DRIVERS@
-lcd4linux_SOURCES = lcd4linux.c pid.c pid.h hash.c hash.h parser.c parser.h processor.c processor.h layout.c layout.h timer.c timer.h evaluator.c evaluator.h widget.c widget.h widget_text.c plugin.c plugin.h plugin_math.c plugin_string.c plugin_cfg.c plugin_uname.c plugin_loadavg.c plugin_proc_stat.c plugin_cpuinfo.c plugin_meminfo.c plugin_i2c_sensors.c plugin_xmms.c system.c system.h isdn.c isdn.h wifi.c wifi.h mail.c mail.h seti.c seti.h battery.c battery.h dvb.c dvb.h filter.c filter.h exec.c exec.h expr.c expr.h mail2.c socket.c socket.h imon.c imon.h display.c display.h drv.c drv.h debug.c debug.h cfg.c cfg.h lock.c lock.h pixmap.c pixmap.h bar.c bar.h icon.c icon.h fontmap.c fontmap.h udelay.c udelay.h
+lcd4linux_SOURCES = lcd4linux.c pid.c pid.h hash.c hash.h parser.c parser.h processor.c processor.h layout.c layout.h timer.c timer.h evaluator.c evaluator.h widget.c widget.h widget_text.c widget_text.h widget_bar.c widget_bar.h plugin.c plugin.h plugin_math.c plugin_string.c plugin_cfg.c plugin_uname.c plugin_loadavg.c plugin_proc_stat.c plugin_cpuinfo.c plugin_meminfo.c plugin_i2c_sensors.c plugin_xmms.c system.c system.h isdn.c isdn.h wifi.c wifi.h mail.c mail.h seti.c seti.h battery.c battery.h dvb.c dvb.h filter.c filter.h exec.c exec.h expr.c expr.h mail2.c socket.c socket.h imon.c imon.h display.c display.h drv.c drv.h debug.c debug.h cfg.c cfg.h lock.c lock.h pixmap.c pixmap.h bar.c bar.h icon.c icon.h fontmap.c fontmap.h udelay.c udelay.h
#liblcd4linux_la_DEPENDENCIES = @DRIVERS@
@@ -149,16 +149,17 @@ X_PRE_LIBS = @X_PRE_LIBS@
lcd4linux_OBJECTS = lcd4linux.$(OBJEXT) pid.$(OBJEXT) hash.$(OBJEXT) \
parser.$(OBJEXT) processor.$(OBJEXT) layout.$(OBJEXT) timer.$(OBJEXT) \
evaluator.$(OBJEXT) widget.$(OBJEXT) widget_text.$(OBJEXT) \
-plugin.$(OBJEXT) plugin_math.$(OBJEXT) plugin_string.$(OBJEXT) \
-plugin_cfg.$(OBJEXT) plugin_uname.$(OBJEXT) plugin_loadavg.$(OBJEXT) \
-plugin_proc_stat.$(OBJEXT) plugin_cpuinfo.$(OBJEXT) \
-plugin_meminfo.$(OBJEXT) plugin_i2c_sensors.$(OBJEXT) \
-plugin_xmms.$(OBJEXT) system.$(OBJEXT) isdn.$(OBJEXT) wifi.$(OBJEXT) \
-mail.$(OBJEXT) seti.$(OBJEXT) battery.$(OBJEXT) dvb.$(OBJEXT) \
-filter.$(OBJEXT) exec.$(OBJEXT) expr.$(OBJEXT) mail2.$(OBJEXT) \
-socket.$(OBJEXT) imon.$(OBJEXT) display.$(OBJEXT) drv.$(OBJEXT) \
-debug.$(OBJEXT) cfg.$(OBJEXT) lock.$(OBJEXT) pixmap.$(OBJEXT) \
-bar.$(OBJEXT) icon.$(OBJEXT) fontmap.$(OBJEXT) udelay.$(OBJEXT)
+widget_bar.$(OBJEXT) plugin.$(OBJEXT) plugin_math.$(OBJEXT) \
+plugin_string.$(OBJEXT) plugin_cfg.$(OBJEXT) plugin_uname.$(OBJEXT) \
+plugin_loadavg.$(OBJEXT) plugin_proc_stat.$(OBJEXT) \
+plugin_cpuinfo.$(OBJEXT) plugin_meminfo.$(OBJEXT) \
+plugin_i2c_sensors.$(OBJEXT) plugin_xmms.$(OBJEXT) system.$(OBJEXT) \
+isdn.$(OBJEXT) wifi.$(OBJEXT) mail.$(OBJEXT) seti.$(OBJEXT) \
+battery.$(OBJEXT) dvb.$(OBJEXT) filter.$(OBJEXT) exec.$(OBJEXT) \
+expr.$(OBJEXT) mail2.$(OBJEXT) socket.$(OBJEXT) imon.$(OBJEXT) \
+display.$(OBJEXT) drv.$(OBJEXT) debug.$(OBJEXT) cfg.$(OBJEXT) \
+lock.$(OBJEXT) pixmap.$(OBJEXT) bar.$(OBJEXT) icon.$(OBJEXT) \
+fontmap.$(OBJEXT) udelay.$(OBJEXT)
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -188,7 +189,7 @@ DEP_FILES = .deps/BeckmannEgle.P .deps/Crystalfontz.P .deps/Cwlinux.P \
.deps/plugin_meminfo.P .deps/plugin_proc_stat.P .deps/plugin_string.P \
.deps/plugin_uname.P .deps/plugin_xmms.P .deps/processor.P .deps/seti.P \
.deps/socket.P .deps/system.P .deps/timer.P .deps/udelay.P \
-.deps/widget.P .deps/widget_text.P .deps/wifi.P
+.deps/widget.P .deps/widget_bar.P .deps/widget_text.P .deps/wifi.P
SOURCES = $(lcd4linux_SOURCES) $(EXTRA_lcd4linux_SOURCES)
OBJECTS = $(lcd4linux_OBJECTS)
diff --git a/drv_MatrixOrbital.c b/drv_MatrixOrbital.c
index 43b7dd7..96692ae 100644
--- a/drv_MatrixOrbital.c
+++ b/drv_MatrixOrbital.c
@@ -1,4 +1,4 @@
-/* $Id: drv_MatrixOrbital.c,v 1.8 2004/01/15 07:47:02 reinelt Exp $
+/* $Id: drv_MatrixOrbital.c,v 1.9 2004/01/18 21:25:16 reinelt Exp $
*
* new style driver for Matrix Orbital serial display modules
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_MatrixOrbital.c,v $
+ * Revision 1.9 2004/01/18 21:25:16 reinelt
+ * Framework for bar widget opened
+ *
* Revision 1.8 2004/01/15 07:47:02 reinelt
* debian/ postinst and watch added (did CVS forget about them?)
* evaluator: conditional expressions (a?b:c) added
@@ -86,6 +89,7 @@
#include "icon.h"
#include "widget.h"
#include "widget_text.h"
+#include "widget_bar.h"
// these values are hardcoded
@@ -718,8 +722,8 @@ int drv_MO_draw_text (WIDGET *W)
// maybe grow layout framebuffer
drv_MO_resize (W->row, W->col+len-1);
- fb1=LayoutFB+row*LCOLS;
- fb2=DisplayFB+row*DCOLS;
+ fb1 = LayoutFB + row*LCOLS;
+ fb2 = DisplayFB + row*DCOLS;
// transfer new text into layout buffer
memcpy (fb1+col, txt, len);
@@ -738,14 +742,25 @@ int drv_MO_draw_text (WIDGET *W)
equal=0;
}
}
- memcpy (fb2+pos1, fb1+pos1, pos2-pos1+1);
- drv_MO_write (fb2+pos1, pos2-pos1+1);
+ memcpy (fb2+pos1, fb1+pos1, pos2-pos1+1);
+ drv_MO_write (fb2+pos1, pos2-pos1+1);
}
return 0;
}
+int drv_MO_draw_bar (WIDGET *W)
+{
+ WIDGET_BAR *B=W->data;
+
+ debug ("drv_MO_draw_bar(%s) x=%2d y=%2d ", W->name, W->col, W->row);
+
+
+ return 0;
+}
+
+
// ****************************************
// *** exported functions ***
// ****************************************
@@ -789,6 +804,11 @@ int drv_MO_init (char *section)
return -1;
}
+ // register bar widget
+ wc=Widget_Bar;
+ wc.draw=drv_MO_draw_bar;
+ widget_register(&wc);
+
// register text widget
wc=Widget_Text;
wc.draw=drv_MO_draw_text;
diff --git a/widget_bar.c b/widget_bar.c
new file mode 100644
index 0000000..7ed6f28
--- /dev/null
+++ b/widget_bar.c
@@ -0,0 +1,136 @@
+/* $Id: widget_bar.c,v 1.1 2004/01/18 21:25:16 reinelt Exp $
+ *
+ * bar widget handling
+ *
+ * Copyright 2003,2004 Michael Reinelt <reinelt@eunet.at>
+ * Copyright 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
+ *
+ * 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, or (at your option)
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ * $Log: widget_bar.c,v $
+ * Revision 1.1 2004/01/18 21:25:16 reinelt
+ * Framework for bar widget opened
+ *
+ */
+
+/*
+ * exported functions:
+ *
+ * WIDGET_CLASS Widget_Bar
+ * the bar widget
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "debug.h"
+#include "cfg.h"
+#include "evaluator.h"
+#include "timer.h"
+#include "widget.h"
+#include "widget_bar.h"
+
+
+void widget_bar_update (void *Self)
+{
+ WIDGET *W = (WIDGET*)Self;
+ WIDGET_BAR *T = W->data;
+ RESULT result = {0, 0.0, NULL};
+}
+
+
+int widget_bar_init (WIDGET *Self)
+{
+ char *section; char *c;
+ WIDGET_BAR *B;
+
+ // prepare config section
+ // strlen("Widget:")=7
+ section=malloc(strlen(Self->name)+8);
+ strcpy(section, "Widget:");
+ strcat(section, Self->name);
+
+ B=malloc(sizeof(WIDGET_BAR));
+ memset (B, 0, sizeof(WIDGET_BAR));
+
+ // get raw expressions (we evaluate them ourselves)
+ B->expression1 = cfg_get_raw (section, "expression", "''");
+ B->expression2 = cfg_get_raw (section, "expression2", "''");
+
+ // bar length, default 1
+ cfg_number (section, "length", 1, 0, 99999, &(B->length));
+
+ // direction: East (default), West, North, South
+ c = cfg_get (section, "direction", "E");
+ switch (toupper(*c)) {
+ case 'E':
+ B->direction=DIR_EAST;
+ break;
+ case 'W':
+ B->direction=DIR_WEST;
+ break;
+ case 'N':
+ B->direction=DIR_NORTH;
+ break;
+ case 'S':
+ B->direction=DIR_SOUTH;
+ break;
+ default:
+ error ("widget %s has unknown direction '%s', using 'East'", section, c);
+ B->direction=DIR_EAST;
+ }
+ free (c);
+
+ // update interval (msec), default 1 sec
+ cfg_number (section, "update", 1000, 10, 99999, &(B->update));
+
+ // buffer
+ // B->buffer=malloc(B->width+1);
+
+ free (section);
+ Self->data=B;
+
+ timer_add (widget_bar_update, Self, B->update, 0);
+
+ return 0;
+}
+
+
+int widget_bar_quit (WIDGET *Self) {
+
+ if (Self->data) {
+ free (Self->data);
+ Self->data=NULL;
+ }
+
+ return 0;
+
+}
+
+
+
+WIDGET_CLASS Widget_Bar = {
+ name: "text",
+ init: widget_bar_init,
+ draw: NULL,
+ quit: widget_bar_quit,
+};
+
+
diff --git a/widget_bar.h b/widget_bar.h
new file mode 100644
index 0000000..3c725cc
--- /dev/null
+++ b/widget_bar.h
@@ -0,0 +1,49 @@
+/* $Id: widget_bar.h,v 1.1 2004/01/18 21:25:16 reinelt Exp $
+ *
+ * bar widget handling
+ *
+ * Copyright 2003,2004 Michael Reinelt <reinelt@eunet.at>
+ * Copyright 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
+ *
+ * This file is part of LCD4Linux.
+ *
+ * LCD4Linux 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, or (at your option)
+ * any later version.
+ *
+ * LCD4Linux 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ * $Log: widget_bar.h,v $
+ * Revision 1.1 2004/01/18 21:25:16 reinelt
+ * Framework for bar widget opened
+ *
+ */
+
+
+#ifndef _WIDGET_BAR_H_
+#define _WIDGET_BAR_H_
+
+typedef enum { DIR_EAST, DIR_WEST, DIR_NORTH, DIR_SOUTH } DIRECTION;
+
+typedef struct WIDGET_BAR {
+ char *expression1; // expression that delivers the value
+ char *expression2; // expression that delivers the value
+ DIRECTION direction; // bar direction
+ int length; // bar length
+ int update; // update interval (msec)
+
+} WIDGET_BAR;
+
+
+extern WIDGET_CLASS Widget_Bar;
+
+#endif