aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile.am215
-rw-r--r--Makefile.in15
-rw-r--r--layout.c30
-rw-r--r--lcd4linux.c10
-rw-r--r--widget.h11
-rw-r--r--widget_bar.c7
-rw-r--r--widget_icon.c15
-rw-r--r--widget_image.c15
-rw-r--r--widget_text.c7
-rw-r--r--widget_timer.c175
-rw-r--r--widget_timer.h50
11 files changed, 410 insertions, 140 deletions
diff --git a/Makefile.am b/Makefile.am
index 7d9b8dc..a5eeee7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,118 +13,119 @@ lcd4linux_LDFLAGS =
lcd4linux_LDADD = @DRIVERS@ @PLUGINS@ @DRVLIBS@ @PLUGINLIBS@
lcd4linux_DEPENDENCIES = @DRIVERS@ @PLUGINS@
-lcd4linux_SOURCES = \
-lcd4linux.c \
-cfg.c cfg.h \
-debug.c debug.h \
-drv.c drv.h \
-evaluator.c evaluator.h \
-hash.c hash.h \
-layout.c layout.h \
-pid.c pid.h \
-timer.c timer.h \
-thread.c thread.h \
-udelay.c udelay.h \
-qprintf.c qprintf.h \
- \
-widget.c widget.h \
-widget_text.c widget_text.h \
-widget_bar.c widget_bar.h \
-widget_icon.c widget_icon.h \
+lcd4linux_SOURCES = \
+lcd4linux.c \
+cfg.c cfg.h \
+debug.c debug.h \
+drv.c drv.h \
+evaluator.c evaluator.h \
+hash.c hash.h \
+layout.c layout.h \
+pid.c pid.h \
+timer.c timer.h \
+thread.c thread.h \
+udelay.c udelay.h \
+qprintf.c qprintf.h \
+ \
+widget.c widget.h \
+widget_text.c widget_text.h \
+widget_bar.c widget_bar.h \
+widget_icon.c widget_icon.h \
widget_image.c widget_image.h \
-widget_gpo.c widget_gpo.h \
- \
-plugin.c plugin.h \
-plugin_cfg.c \
-plugin_math.c \
-plugin_string.c \
-plugin_test.c \
+widget_timer.c widget_timer.h \
+widget_gpo.c widget_gpo.h \
+ \
+plugin.c plugin.h \
+plugin_cfg.c \
+plugin_math.c \
+plugin_string.c \
+plugin_test.c \
plugin_time.c
-EXTRA_lcd4linux_SOURCES= \
-drv_generic_text.c \
-drv_generic_text.h \
-drv_generic_graphic.c \
-drv_generic_graphic.h \
-drv_generic_gpio.c \
-drv_generic_gpio.h \
-drv_generic_serial.c \
-drv_generic_serial.h \
-drv_generic_parport.c \
-drv_generic_parport.h \
-drv_generic_i2c.c \
-drv_generic_i2c.h \
-drv_BeckmannEgle.c \
-drv_BWCT.c \
-drv_Crystalfontz.c \
-drv_Curses.c \
-drv_Cwlinux.c \
-drv_G15.c \
-drv_HD44780.c \
-drv_Image.c \
-drv_LCDLinux.c \
-drv_LCDTerm.c \
-drv_LPH7508.c \
-drv_LUIse.c \
-drv_M50530.c \
-drv_MatrixOrbital.c \
-drv_MilfordInstruments.c \
-drv_Noritake.c \
-drv_NULL.c \
-drv_RouterBoard.c \
-drv_Sample.c \
-drv_serdisplib.c \
-drv_SimpleLCD.c \
-drv_T6963.c \
-drv_Trefon.c \
-drv_USBLCD.c \
-drv_WincorNixdorf.c \
-drv_X11.c \
- \
-font_6x8.h \
- \
-lcd4linux_i2c.h \
- \
-plugin_apm.c \
-plugin_cpuinfo.c \
-plugin_diskstats.c \
-plugin_dvb.c \
-plugin_exec.c \
-plugin_i2c_sensors.c \
-plugin_imon.c \
-plugin_isdn.c \
-plugin_loadavg.c \
-plugin_meminfo.c \
-plugin_mysql.c \
-plugin_netdev.c \
-plugin_pop3.c \
-plugin_ppp.c \
-plugin_proc_stat.c \
-plugin_python.c \
-plugin_sample.c \
-plugin_seti.c \
-plugin_statfs.c \
-plugin_uname.c \
-plugin_uptime.c \
-plugin_wireless.c \
+EXTRA_lcd4linux_SOURCES= \
+drv_generic_text.c \
+drv_generic_text.h \
+drv_generic_graphic.c \
+drv_generic_graphic.h \
+drv_generic_gpio.c \
+drv_generic_gpio.h \
+drv_generic_serial.c \
+drv_generic_serial.h \
+drv_generic_parport.c \
+drv_generic_parport.h \
+drv_generic_i2c.c \
+drv_generic_i2c.h \
+drv_BeckmannEgle.c \
+drv_BWCT.c \
+drv_Crystalfontz.c \
+drv_Curses.c \
+drv_Cwlinux.c \
+drv_G15.c \
+drv_HD44780.c \
+drv_Image.c \
+drv_LCDLinux.c \
+drv_LCDTerm.c \
+drv_LPH7508.c \
+drv_LUIse.c \
+drv_M50530.c \
+drv_MatrixOrbital.c \
+drv_MilfordInstruments.c \
+drv_Noritake.c \
+drv_NULL.c \
+drv_RouterBoard.c \
+drv_Sample.c \
+drv_serdisplib.c \
+drv_SimpleLCD.c \
+drv_T6963.c \
+drv_Trefon.c \
+drv_USBLCD.c \
+drv_WincorNixdorf.c \
+drv_X11.c \
+ \
+font_6x8.h \
+ \
+lcd4linux_i2c.h \
+ \
+plugin_apm.c \
+plugin_cpuinfo.c \
+plugin_diskstats.c \
+plugin_dvb.c \
+plugin_exec.c \
+plugin_i2c_sensors.c \
+plugin_imon.c \
+plugin_isdn.c \
+plugin_loadavg.c \
+plugin_meminfo.c \
+plugin_mysql.c \
+plugin_netdev.c \
+plugin_pop3.c \
+plugin_ppp.c \
+plugin_proc_stat.c \
+plugin_python.c \
+plugin_sample.c \
+plugin_seti.c \
+plugin_statfs.c \
+plugin_uname.c \
+plugin_uptime.c \
+plugin_wireless.c \
plugin_xmms.c
-EXTRA_DIST = \
-lcd4linux.conf.sample \
-lcd4kde.conf \
-lcd4linux.kdelnk \
-lcd4linux.xpm \
-lcd4linux.lsm \
-curses.m4 \
-AUTHORS \
-CREDITS \
-FAQ \
-NEWS \
-TODO \
-README \
-README.Drivers \
-README.Plugins \
-README.KDE \
+EXTRA_DIST = \
+lcd4linux.conf.sample \
+lcd4kde.conf \
+lcd4linux.kdelnk \
+lcd4linux.xpm \
+lcd4linux.lsm \
+curses.m4 \
+AUTHORS \
+CREDITS \
+FAQ \
+NEWS \
+TODO \
+README \
+README.Drivers \
+README.Plugins \
+README.KDE \
plugin_sample.c
diff --git a/Makefile.in b/Makefile.in
index 02632af..7113bd0 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -101,13 +101,13 @@ lcd4linux_LDFLAGS =
lcd4linux_LDADD = @DRIVERS@ @PLUGINS@ @DRVLIBS@ @PLUGINLIBS@
lcd4linux_DEPENDENCIES = @DRIVERS@ @PLUGINS@
-lcd4linux_SOURCES = lcd4linux.c cfg.c cfg.h debug.c debug.h drv.c drv.h evaluator.c evaluator.h hash.c hash.h layout.c layout.h pid.c pid.h timer.c timer.h thread.c thread.h udelay.c udelay.h qprintf.c qprintf.h widget.c widget.h widget_text.c widget_text.h widget_bar.c widget_bar.h widget_icon.c widget_icon.h widget_image.c widget_image.h widget_gpo.c widget_gpo.h plugin.c plugin.h plugin_cfg.c plugin_math.c plugin_string.c plugin_test.c plugin_time.c
+lcd4linux_SOURCES = lcd4linux.c cfg.c cfg.h debug.c debug.h drv.c drv.h evaluator.c evaluator.h hash.c hash.h layout.c layout.h pid.c pid.h timer.c timer.h thread.c thread.h udelay.c udelay.h qprintf.c qprintf.h widget.c widget.h widget_text.c widget_text.h widget_bar.c widget_bar.h widget_icon.c widget_icon.h widget_image.c widget_image.h widget_timer.c widget_timer.h widget_gpo.c widget_gpo.h plugin.c plugin.h plugin_cfg.c plugin_math.c plugin_string.c plugin_test.c plugin_time.c
-EXTRA_lcd4linux_SOURCES = drv_generic_text.c drv_generic_text.h drv_generic_graphic.c drv_generic_graphic.h drv_generic_gpio.c drv_generic_gpio.h drv_generic_serial.c drv_generic_serial.h drv_generic_parport.c drv_generic_parport.h drv_generic_i2c.c drv_generic_i2c.h drv_BeckmannEgle.c drv_BWCT.c drv_Crystalfontz.c drv_Curses.c drv_Cwlinux.c drv_G15.c drv_HD44780.c drv_Image.c drv_LCDLinux.c drv_LCDTerm.c drv_LPH7508.c drv_LUIse.c drv_M50530.c drv_MatrixOrbital.c drv_MilfordInstruments.c drv_Noritake.c drv_NULL.c drv_RouterBoard.c drv_Sample.c drv_serdisplib.c drv_SimpleLCD.c drv_T6963.c drv_Trefon.c drv_USBLCD.c drv_WincorNixdorf.c drv_X11.c font_6x8.h lcd4linux_i2c.h plugin_apm.c plugin_cpuinfo.c plugin_diskstats.c plugin_dvb.c plugin_exec.c plugin_i2c_sensors.c plugin_imon.c plugin_isdn.c plugin_loadavg.c plugin_meminfo.c plugin_mysql.c plugin_netdev.c plugin_pop3.c plugin_ppp.c plugin_proc_stat.c plugin_python.c plugin_sample.c plugin_seti.c plugin_statfs.c plugin_uname.c plugin_uptime.c plugin_wireless.c plugin_xmms.c
+EXTRA_lcd4linux_SOURCES = drv_generic_text.c drv_generic_text.h drv_generic_graphic.c drv_generic_graphic.h drv_generic_gpio.c drv_generic_gpio.h drv_generic_serial.c drv_generic_serial.h drv_generic_parport.c drv_generic_parport.h drv_generic_i2c.c drv_generic_i2c.h drv_BeckmannEgle.c drv_BWCT.c drv_Crystalfontz.c drv_Curses.c drv_Cwlinux.c drv_G15.c drv_HD44780.c drv_Image.c drv_LCDLinux.c drv_LCDTerm.c drv_LPH7508.c drv_LUIse.c drv_M50530.c drv_MatrixOrbital.c drv_MilfordInstruments.c drv_Noritake.c drv_NULL.c drv_RouterBoard.c drv_Sample.c drv_serdisplib.c drv_SimpleLCD.c drv_T6963.c drv_Trefon.c drv_USBLCD.c drv_WincorNixdorf.c drv_X11.c font_6x8.h lcd4linux_i2c.h plugin_apm.c plugin_cpuinfo.c plugin_diskstats.c plugin_dvb.c plugin_exec.c plugin_i2c_sensors.c plugin_imon.c plugin_isdn.c plugin_loadavg.c plugin_meminfo.c plugin_mysql.c plugin_netdev.c plugin_pop3.c plugin_ppp.c plugin_proc_stat.c plugin_python.c plugin_sample.c plugin_seti.c plugin_statfs.c plugin_uname.c plugin_uptime.c plugin_wireless.c plugin_xmms.c
-EXTRA_DIST = lcd4linux.conf.sample lcd4kde.conf lcd4linux.kdelnk lcd4linux.xpm lcd4linux.lsm curses.m4 AUTHORS CREDITS FAQ NEWS TODO README README.Drivers README.Plugins README.KDE plugin_sample.c
+EXTRA_DIST = lcd4linux.conf.sample lcd4kde.conf lcd4linux.kdelnk lcd4linux.xpm lcd4linux.lsm curses.m4 AUTHORS CREDITS FAQ NEWS TODO README README.Drivers README.Plugins README.KDE plugin_sample.c
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -126,9 +126,9 @@ X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
lcd4linux_OBJECTS = lcd4linux.o cfg.o debug.o drv.o evaluator.o hash.o \
layout.o pid.o timer.o thread.o udelay.o qprintf.o widget.o \
-widget_text.o widget_bar.o widget_icon.o widget_image.o widget_gpo.o \
-plugin.o plugin_cfg.o plugin_math.o plugin_string.o plugin_test.o \
-plugin_time.o
+widget_text.o widget_bar.o widget_icon.o widget_image.o widget_timer.o \
+widget_gpo.o plugin.o plugin_cfg.o plugin_math.o plugin_string.o \
+plugin_test.o plugin_time.o
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
@@ -167,7 +167,8 @@ DEP_FILES = .deps/cfg.P .deps/debug.P .deps/drv.P .deps/drv_BWCT.P \
.deps/plugin_uptime.P .deps/plugin_wireless.P .deps/plugin_xmms.P \
.deps/qprintf.P .deps/thread.P .deps/timer.P .deps/udelay.P \
.deps/widget.P .deps/widget_bar.P .deps/widget_gpo.P \
-.deps/widget_icon.P .deps/widget_image.P .deps/widget_text.P
+.deps/widget_icon.P .deps/widget_image.P .deps/widget_text.P \
+.deps/widget_timer.P
SOURCES = $(lcd4linux_SOURCES) $(EXTRA_lcd4linux_SOURCES)
OBJECTS = $(lcd4linux_OBJECTS)
diff --git a/layout.c b/layout.c
index 7b4fd57..91715d7 100644
--- a/layout.c
+++ b/layout.c
@@ -1,4 +1,4 @@
-/* $Id: layout.c,v 1.17 2005/12/18 16:18:36 reinelt Exp $
+/* $Id: layout.c,v 1.18 2006/01/23 06:17:18 reinelt Exp $
*
* new layouter framework
*
@@ -23,6 +23,9 @@
*
*
* $Log: layout.c,v $
+ * Revision 1.18 2006/01/23 06:17:18 reinelt
+ * timer widget added
+ *
* Revision 1.17 2005/12/18 16:18:36 reinelt
* GPO's added again
*
@@ -124,7 +127,7 @@ int layout_init(const char *layout)
char *section;
char *list, *l;
char *widget;
- int row, col, gpo;
+ int row, col, num;
info("initializing layout '%s'", layout);
@@ -143,31 +146,46 @@ int layout_init(const char *layout)
l = list;
while (l != NULL) {
+
char *p;
int i, n;
+
/* list is delimited by | */
while (*l == '|')
l++;
if ((p = strchr(l, '|')) != NULL)
*p = '\0';
- /* visible widgets */
+
+ /* row/col widgets */
i = sscanf(l, "row%d.col%d%n", &row, &col, &n);
if (i == 2 && l[n] == '\0') {
widget = cfg_get(section, l, NULL);
if (widget != NULL && *widget != '\0') {
- widget_add(widget, WIDGET_TYPE_VIS, row - 1, col - 1);
+ widget_add(widget, WIDGET_TYPE_RC, row - 1, col - 1);
}
free(widget);
}
+
/* GPO widgets */
- i = sscanf(l, "gpo%d%n", &gpo, &n);
+ i = sscanf(l, "gpo%d%n", &num, &n);
if (i == 1 && l[n] == '\0') {
widget = cfg_get(section, l, NULL);
if (widget != NULL && *widget != '\0') {
- widget_add(widget, WIDGET_TYPE_GPO, gpo - 1, 0);
+ widget_add(widget, WIDGET_TYPE_GPO, num - 1, 0);
}
free(widget);
}
+
+ /* timer widgets */
+ i = sscanf(l, "timer%d%n", &num, &n);
+ if (i == 1 && l[n] == '\0') {
+ widget = cfg_get(section, l, NULL);
+ if (widget != NULL && *widget != '\0') {
+ widget_add(widget, WIDGET_TYPE_TIMER, num - 1, 0);
+ }
+ free(widget);
+ }
+
/* next field */
l = p ? p + 1 : NULL;
}
diff --git a/lcd4linux.c b/lcd4linux.c
index 062ce51..3cbb583 100644
--- a/lcd4linux.c
+++ b/lcd4linux.c
@@ -1,4 +1,4 @@
-/* $Id: lcd4linux.c,v 1.79 2005/09/02 05:27:08 reinelt Exp $
+/* $Id: lcd4linux.c,v 1.80 2006/01/23 06:17:18 reinelt Exp $
*
* LCD4Linux
*
@@ -23,6 +23,9 @@
*
*
* $Log: lcd4linux.c,v $
+ * Revision 1.80 2006/01/23 06:17:18 reinelt
+ * timer widget added
+ *
* Revision 1.79 2005/09/02 05:27:08 reinelt
* double-fork daemonize patch from Petri Damsten
*
@@ -389,6 +392,8 @@
#include "layout.h"
#include "plugin.h"
+#include "widget.h"
+#include "widget_timer.h"
#ifdef WITH_DMALLOC
#include <dmalloc.h>
@@ -652,6 +657,9 @@ int main(int argc, char *argv[])
}
free(driver);
+ /* register timer widget */
+ widget_timer_register();
+
/* go into interactive mode (display has been initialized) */
if (interactive >= 1) {
interactive_mode();
diff --git a/widget.h b/widget.h
index 04de327..e418184 100644
--- a/widget.h
+++ b/widget.h
@@ -1,4 +1,4 @@
-/* $Id: widget.h,v 1.15 2005/12/18 16:18:36 reinelt Exp $
+/* $Id: widget.h,v 1.16 2006/01/23 06:17:18 reinelt Exp $
*
* generic widget handling
*
@@ -23,6 +23,9 @@
*
*
* $Log: widget.h,v $
+ * Revision 1.16 2006/01/23 06:17:18 reinelt
+ * timer widget added
+ *
* Revision 1.15 2005/12/18 16:18:36 reinelt
* GPO's added again
*
@@ -113,8 +116,10 @@ typedef struct WIDGET {
} WIDGET;
-#define WIDGET_TYPE_VIS 1
-#define WIDGET_TYPE_GPO 2
+#define WIDGET_TYPE_RC 1
+#define WIDGET_TYPE_XY 2
+#define WIDGET_TYPE_GPO 3
+#define WIDGET_TYPE_TIMER 4
int widget_register(WIDGET_CLASS * widget);
diff --git a/widget_bar.c b/widget_bar.c
index 62db084..079e327 100644
--- a/widget_bar.c
+++ b/widget_bar.c
@@ -1,4 +1,4 @@
-/* $Id: widget_bar.c,v 1.17 2005/12/18 16:18:36 reinelt Exp $
+/* $Id: widget_bar.c,v 1.18 2006/01/23 06:17:18 reinelt Exp $
*
* bar widget handling
*
@@ -21,6 +21,9 @@
*
*
* $Log: widget_bar.c,v $
+ * Revision 1.18 2006/01/23 06:17:18 reinelt
+ * timer widget added
+ *
* Revision 1.17 2005/12/18 16:18:36 reinelt
* GPO's added again
*
@@ -299,7 +302,7 @@ int widget_bar_quit(WIDGET * Self)
WIDGET_CLASS Widget_Bar = {
name:"bar",
- type:WIDGET_TYPE_VIS,
+ type:WIDGET_TYPE_RC,
init:widget_bar_init,
draw:NULL,
quit:widget_bar_quit,
diff --git a/widget_icon.c b/widget_icon.c
index 4f12aac..e677f56 100644
--- a/widget_icon.c
+++ b/widget_icon.c
@@ -1,4 +1,4 @@
-/* $Id: widget_icon.c,v 1.21 2006/01/22 10:01:09 reinelt Exp $
+/* $Id: widget_icon.c,v 1.22 2006/01/23 06:17:18 reinelt Exp $
*
* icon widget handling
*
@@ -21,6 +21,9 @@
*
*
* $Log: widget_icon.c,v $
+ * Revision 1.22 2006/01/23 06:17:18 reinelt
+ * timer widget added
+ *
* Revision 1.21 2006/01/22 10:01:09 reinelt
* allow 'static' icons with speed=0
*
@@ -245,16 +248,16 @@ int widget_icon_init(WIDGET * Self)
Icon->speed_expr = cfg_get_raw(section, "speed", NULL);
Icon->visible_expr = cfg_get_raw(section, "visible", NULL);
- /* compile'em */
- Compile(Icon->speed_expr, &Icon->speed_tree);
- Compile(Icon->visible_expr, &Icon->visible_tree);
-
/* sanity check */
if (Icon->speed_expr == NULL || *Icon->speed_expr == '\0') {
error("Icon %s has no speed, using '100'", Self->name);
Icon->speed_expr = "100";
}
+ /* compile'em */
+ Compile(Icon->speed_expr, &Icon->speed_tree);
+ Compile(Icon->visible_expr, &Icon->visible_tree);
+
/* read bitmap */
widget_icon_read_bitmap(section, Icon);
@@ -308,7 +311,7 @@ int widget_icon_quit(WIDGET * Self)
WIDGET_CLASS Widget_Icon = {
name:"icon",
- type:WIDGET_TYPE_VIS,
+ type:WIDGET_TYPE_RC,
init:widget_icon_init,
draw:NULL,
quit:widget_icon_quit,
diff --git a/widget_image.c b/widget_image.c
index 4b5c898..7281271 100644
--- a/widget_image.c
+++ b/widget_image.c
@@ -1,4 +1,4 @@
-/* $Id: widget_image.c,v 1.1 2006/01/22 09:16:11 reinelt Exp $
+/* $Id: widget_image.c,v 1.2 2006/01/23 06:17:18 reinelt Exp $
*
* image widget handling
*
@@ -21,6 +21,9 @@
*
*
* $Log: widget_image.c,v $
+ * Revision 1.2 2006/01/23 06:17:18 reinelt
+ * timer widget added
+ *
* Revision 1.1 2006/01/22 09:16:11 reinelt
* Image Widget framework added
*
@@ -115,16 +118,16 @@ int widget_image_init(WIDGET * Self)
Image->update_expr = cfg_get_raw(section, "update", NULL);
Image->visible_expr = cfg_get_raw(section, "visible", NULL);
- /* compile'em */
- Compile(Image->update_expr, &Image->update_tree);
- Compile(Image->visible_expr, &Image->visible_tree);
-
/* sanity check */
if (Image->update_expr == NULL || *Image->update_expr == '\0') {
error("Image %s has no update, using '100'", Self->name);
Image->update_expr = "100";
}
+ /* compile'em */
+ Compile(Image->update_expr, &Image->update_tree);
+ Compile(Image->visible_expr, &Image->visible_tree);
+
free(section);
Self->data = Image;
@@ -167,7 +170,7 @@ int widget_image_quit(WIDGET * Self)
WIDGET_CLASS Widget_Image = {
name:"image",
- type:WIDGET_TYPE_VIS,
+ type:WIDGET_TYPE_XY,
init:widget_image_init,
draw:NULL,
quit:widget_image_quit,
diff --git a/widget_text.c b/widget_text.c
index d34a7c0..a9430bf 100644
--- a/widget_text.c
+++ b/widget_text.c
@@ -1,4 +1,4 @@
-/* $Id: widget_text.c,v 1.23 2005/12/18 16:18:36 reinelt Exp $
+/* $Id: widget_text.c,v 1.24 2006/01/23 06:17:18 reinelt Exp $
*
* simple text widget handling
*
@@ -21,6 +21,9 @@
*
*
* $Log: widget_text.c,v $
+ * Revision 1.24 2006/01/23 06:17:18 reinelt
+ * timer widget added
+ *
* Revision 1.23 2005/12/18 16:18:36 reinelt
* GPO's added again
*
@@ -481,7 +484,7 @@ int widget_text_quit(WIDGET * Self)
WIDGET_CLASS Widget_Text = {
name:"text",
- type:WIDGET_TYPE_VIS,
+ type:WIDGET_TYPE_RC,
init:widget_text_init,
draw:NULL,
quit:widget_text_quit,
diff --git a/widget_timer.c b/widget_timer.c
new file mode 100644
index 0000000..6c9c832
--- /dev/null
+++ b/widget_timer.c
@@ -0,0 +1,175 @@
+/* $Id: widget_timer.c,v 1.1 2006/01/23 06:17:18 reinelt Exp $
+ *
+ * timer widget handling
+ *
+ * Copyright (C) 2006 Michael Reinelt <reinelt@eunet.at>
+ * Copyright (C) 2006 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_timer.c,v $
+ * Revision 1.1 2006/01/23 06:17:18 reinelt
+ * timer widget added
+ *
+ */
+
+/*
+ * exported functions:
+ *
+ * WIDGET_CLASS Widget_Timer
+ * the timer widget
+ *
+ */
+
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "debug.h"
+#include "cfg.h"
+#include "qprintf.h"
+#include "evaluator.h"
+#include "timer.h"
+#include "widget.h"
+#include "widget_timer.h"
+
+#ifdef WITH_DMALLOC
+#include <dmalloc.h>
+#endif
+
+void widget_timer_update(void *Self)
+{
+ WIDGET *W = (WIDGET *) Self;
+ WIDGET_TIMER *Timer = W->data;
+ RESULT result = { 0, 0, 0, NULL };
+
+ /* evaluate expressions */
+ Timer->update = 10;
+ if (Timer->update_tree != NULL) {
+ Eval(Timer->update_tree, &result);
+ Timer->update = R2N(&result);
+ if (Timer->update < 10)
+ Timer->update = 10;
+ DelResult(&result);
+ }
+
+ Timer->active = 1;
+ if (Timer->active_tree != NULL) {
+ Eval(Timer->active_tree, &result);
+ Timer->active = R2N(&result);
+ if (Timer->active < 0)
+ Timer->active = 0;
+ DelResult(&result);
+ }
+
+ /* finally, fire it! */
+ if (Timer->active) {
+ Eval(Timer->expr_tree, &result);
+ DelResult(&result);
+ }
+
+ /* add a new one-shot timer */
+ timer_add(widget_timer_update, Self, Timer->update, 1);
+}
+
+
+
+int widget_timer_init(WIDGET * Self)
+{
+ char *section;
+ WIDGET_TIMER *Timer;
+
+ /* prepare config section */
+ /* strlen("Widget:")=7 */
+ section = malloc(strlen(Self->name) + 8);
+ strcpy(section, "Widget:");
+ strcat(section, Self->name);
+
+ Timer = malloc(sizeof(WIDGET_TIMER));
+ memset(Timer, 0, sizeof(WIDGET_TIMER));
+
+ /* get raw expressions (we evaluate them ourselves) */
+ Timer->expression = cfg_get_raw(section, "axpression", NULL);
+ Timer->update_expr = cfg_get_raw(section, "update", "100");
+ Timer->active_expr = cfg_get_raw(section, "active", "1");
+
+ /* sanity checks */
+ if (Timer->expression == NULL || *Timer->expression == '\0') {
+ error("Timer %s has no expression, using '1'", Self->name);
+ Timer->expression = "1";
+ }
+ if (Timer->update_expr == NULL || *Timer->update_expr == '\0') {
+ error("Timer %s has no update, using '100'", Self->name);
+ Timer->update_expr = "100";
+ }
+
+ /* compile'em */
+ Compile(Timer->expression, &Timer->expr_tree);
+ Compile(Timer->update_expr, &Timer->update_tree);
+ Compile(Timer->active_expr, &Timer->active_tree);
+
+
+ free(section);
+ Self->data = Timer;
+
+ /* just do it! */
+ widget_timer_update(Self);
+
+ return 0;
+}
+
+
+int widget_timer_quit(WIDGET * Self)
+{
+ if (Self) {
+ /* do not deallocate child widget! */
+ if (Self->parent == NULL) {
+ if (Self->data) {
+ WIDGET_TIMER *Timer = Self->data;
+ DelTree(Timer->expr_tree);
+ DelTree(Timer->update_tree);
+ DelTree(Timer->active_tree);
+ free(Self->data);
+ Self->data = NULL;
+ }
+ }
+ }
+
+ return 0;
+
+}
+
+
+int widget_timer_register(void)
+{
+ WIDGET_CLASS wc;
+ wc = Widget_Timer;
+ widget_register(&wc);
+ return 0;
+}
+
+
+WIDGET_CLASS Widget_Timer = {
+ name:"timer",
+ type:WIDGET_TYPE_TIMER,
+ init:widget_timer_init,
+ draw:NULL,
+ quit:widget_timer_quit,
+};
diff --git a/widget_timer.h b/widget_timer.h
new file mode 100644
index 0000000..bf122d4
--- /dev/null
+++ b/widget_timer.h
@@ -0,0 +1,50 @@
+/* $Id: widget_timer.h,v 1.1 2006/01/23 06:17:18 reinelt Exp $
+ *
+ * timer widget handling
+ *
+ * Copyright (C) 2006 Michael Reinelt <reinelt@eunet.at>
+ * Copyright (C) 2006 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_timer.h,v $
+ * Revision 1.1 2006/01/23 06:17:18 reinelt
+ * timer widget added
+ *
+ */
+
+
+#ifndef _WIDGET_TIMER_H_
+#define _WIDGET_TIMER_H_
+
+typedef struct WIDGET_TIMER {
+ char *expression; /* main timer expression */
+ void *expr_tree; /* pre-compiled main expression */
+ char *update_expr; /* expression for update interval */
+ void *update_tree; /* pre-compiled expression for update interval */
+ int update; /* update interval (msec) */
+ char *active_expr; /* expression for active */
+ void *active_tree; /* pre-compiled expression for active */
+ int active; /* timer active? */
+} WIDGET_TIMER;
+
+extern WIDGET_CLASS Widget_Timer;
+
+int widget_timer_register(void);
+
+#endif