aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2006-07-31 03:48:09 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2006-07-31 03:48:09 +0000
commit8a89eeab079decfc4c312438c67d4fc51b8de3c1 (patch)
treea86b6f002c007cb57dd07af2a37621683e59a003
parent16fabe7b64a6e40008403da5d1107ade8f43eb3b (diff)
downloadlcd4linux-8a89eeab079decfc4c312438c67d4fc51b8de3c1.tar.gz
[lcd4linux @ 2006-07-31 03:48:09 by reinelt]
preparations for scrolling git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@680 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
-rw-r--r--Makefile.am3
-rw-r--r--Makefile.in23
-rw-r--r--configure.in2
-rw-r--r--drv.c26
-rw-r--r--drv_generic.c119
-rw-r--r--drv_generic.h47
-rw-r--r--drv_generic_graphic.c16
-rw-r--r--drv_generic_graphic.h9
-rw-r--r--drv_generic_i2c.c13
-rw-r--r--drv_generic_i2c.h23
-rw-r--r--drv_generic_text.c195
-rw-r--r--drv_generic_text.h10
-rw-r--r--lcd4linux.conf.sample9
-rw-r--r--plugin.c6
-rw-r--r--plugin_string.c27
-rw-r--r--widget_timer.c11
16 files changed, 359 insertions, 180 deletions
diff --git a/Makefile.am b/Makefile.am
index b52d8a5..64ce9c5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,6 +18,7 @@ lcd4linux.c \
cfg.c cfg.h \
debug.c debug.h \
drv.c drv.h \
+drv_generic.c drv_generic.h \
evaluator.c evaluator.h \
hash.c hash.h \
layout.c layout.h \
@@ -32,7 +33,7 @@ widget.c widget.h \
widget_text.c widget_text.h \
widget_bar.c widget_bar.h \
widget_icon.c widget_icon.h \
-widget_keypad.c widget_keypad.h \
+widget_keypad.c widget_keypad.h \
widget_timer.c widget_timer.h \
widget_gpo.c widget_gpo.h \
\
diff --git a/Makefile.in b/Makefile.in
index 7329470..d69e22c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -58,15 +58,16 @@ am__installdirs = "$(DESTDIR)$(bindir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am_lcd4linux_OBJECTS = lcd4linux.$(OBJEXT) cfg.$(OBJEXT) \
- debug.$(OBJEXT) drv.$(OBJEXT) evaluator.$(OBJEXT) \
- hash.$(OBJEXT) layout.$(OBJEXT) pid.$(OBJEXT) timer.$(OBJEXT) \
- thread.$(OBJEXT) udelay.$(OBJEXT) qprintf.$(OBJEXT) \
- rgb.$(OBJEXT) widget.$(OBJEXT) widget_text.$(OBJEXT) \
- widget_bar.$(OBJEXT) widget_icon.$(OBJEXT) \
- widget_keypad.$(OBJEXT) widget_timer.$(OBJEXT) \
- widget_gpo.$(OBJEXT) plugin.$(OBJEXT) plugin_cfg.$(OBJEXT) \
- plugin_math.$(OBJEXT) plugin_string.$(OBJEXT) \
- plugin_test.$(OBJEXT) plugin_time.$(OBJEXT)
+ debug.$(OBJEXT) drv.$(OBJEXT) drv_generic.$(OBJEXT) \
+ evaluator.$(OBJEXT) hash.$(OBJEXT) layout.$(OBJEXT) \
+ pid.$(OBJEXT) timer.$(OBJEXT) thread.$(OBJEXT) \
+ udelay.$(OBJEXT) qprintf.$(OBJEXT) rgb.$(OBJEXT) \
+ widget.$(OBJEXT) widget_text.$(OBJEXT) widget_bar.$(OBJEXT) \
+ widget_icon.$(OBJEXT) widget_keypad.$(OBJEXT) \
+ widget_timer.$(OBJEXT) widget_gpo.$(OBJEXT) plugin.$(OBJEXT) \
+ plugin_cfg.$(OBJEXT) plugin_math.$(OBJEXT) \
+ plugin_string.$(OBJEXT) plugin_test.$(OBJEXT) \
+ plugin_time.$(OBJEXT)
lcd4linux_OBJECTS = $(am_lcd4linux_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -192,6 +193,7 @@ lcd4linux.c \
cfg.c cfg.h \
debug.c debug.h \
drv.c drv.h \
+drv_generic.c drv_generic.h \
evaluator.c evaluator.h \
hash.c hash.h \
layout.c layout.h \
@@ -206,7 +208,7 @@ widget.c widget.h \
widget_text.c widget_text.h \
widget_bar.c widget_bar.h \
widget_icon.c widget_icon.h \
-widget_keypad.c widget_keypad.h \
+widget_keypad.c widget_keypad.h \
widget_timer.c widget_timer.h \
widget_gpo.c widget_gpo.h \
\
@@ -426,6 +428,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drv_USBLCD.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drv_WincorNixdorf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drv_X11.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drv_generic.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drv_generic_gpio.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drv_generic_graphic.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drv_generic_i2c.Po@am__quote@
diff --git a/configure.in b/configure.in
index 38f1c1b..ca233da 100644
--- a/configure.in
+++ b/configure.in
@@ -22,7 +22,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-AC_PREREQ(2.59e)
+AC_PREREQ(2.59)
AC_INIT([LCD4Linux],[0.10.1-CVS],[lcd4linux-users@lists.sourceforge.net])
AC_CONFIG_SRCDIR([lcd4linux.c])
AM_INIT_AUTOMAKE([lcd4linux],0.10.1-CVS)
diff --git a/drv.c b/drv.c
index c61bebe..912ae7a 100644
--- a/drv.c
+++ b/drv.c
@@ -1,4 +1,4 @@
-/* $Id: drv.c,v 1.40 2006/04/14 20:59:38 harbaum Exp $
+/* $Id: drv.c,v 1.41 2006/07/31 03:48:09 reinelt Exp $
*
* new framework for display drivers
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv.c,v $
+ * Revision 1.41 2006/07/31 03:48:09 reinelt
+ * preparations for scrolling
+ *
* Revision 1.40 2006/04/14 20:59:38 harbaum
* Disable inclusion of Image driver in drv.c if no gd was found.
*
@@ -187,27 +190,6 @@
* drv_init (char *driver)
* initializes the named driver
*
- * drv_query (int *rows, int *cols, int *xres, int *yres, int *bars, int *gpos)
- * queries the attributes of the selected driver
- *
- * drv_clear ()
- * clears the display
- *
- * int drv_put (int row, int col, char *text)
- * writes text at row, col
- *
- * int drv_bar (int type, int row, int col, int max, int len1, int len2)
- * draws a specified bar at row, col with len
- *
- * int drv_icon (int num, int seq, int row, int col)
- * draws icon #num sequence #seq at row, col
- *
- * int drv_gpo (int num, int val)
- * sets GPO #num to val
- *
- * int drv_flush (void)
- * flushes the framebuffer to the display
- *
* int drv_quit (void)
* de-initializes the driver
*/
diff --git a/drv_generic.c b/drv_generic.c
new file mode 100644
index 0000000..d898a85
--- /dev/null
+++ b/drv_generic.c
@@ -0,0 +1,119 @@
+/* $Id: drv_generic.c,v 1.4 2006/07/31 03:48:09 reinelt Exp $
+ *
+ * generic driver helper
+ *
+ * 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: drv_generic.c,v $
+ * Revision 1.4 2006/07/31 03:48:09 reinelt
+ * preparations for scrolling
+ *
+ */
+
+/*
+ *
+ * exported functions:
+ *
+ * drv_generic_init (void)
+ * initializes generic stuff and registers plugins
+ *
+ */
+
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "debug.h"
+#include "plugin.h"
+#include "drv_generic.h"
+
+#ifdef WITH_DMALLOC
+#include <dmalloc.h>
+#endif
+
+/* these values are chars (text displays) or pixels (graphic displays) */
+
+int LROWS = 0; /* layout size: rows */
+int LCOLS = 0; /* layout size: columns */
+
+int DROWS = 4; /* display size: rows */
+int DCOLS = 20; /* display size: columns */
+
+int XRES = 6; /* pixel widtht of one char */
+int YRES = 8; /* pixel height of one char */
+
+
+void (*drv_generic_blit) () = NULL;
+
+
+static void my_drows(RESULT * result)
+{
+ double value = DROWS;
+ SetResult(&result, R_NUMBER, &value);
+}
+
+static void my_dcols(RESULT * result)
+{
+ double value = DCOLS;
+ SetResult(&result, R_NUMBER, &value);
+}
+
+static void my_xres(RESULT * result)
+{
+ double value = XRES;
+ SetResult(&result, R_NUMBER, &value);
+}
+
+static void my_yres(RESULT * result)
+{
+ double value = YRES;
+ SetResult(&result, R_NUMBER, &value);
+}
+
+static void my_lrows(RESULT * result)
+{
+ double value = LROWS;
+ SetResult(&result, R_NUMBER, &value);
+}
+
+static void my_lcols(RESULT * result)
+{
+ double value = LCOLS;
+ SetResult(&result, R_NUMBER, &value);
+}
+
+int drv_generic_init(void)
+{
+
+ AddFunction("LCD::height", 0, my_drows);
+ AddFunction("LCD::width", 0, my_dcols);
+
+ AddFunction("LCD::xres", 0, my_xres);
+ AddFunction("LCD::yres", 0, my_yres);
+
+ AddFunction("Layout::height", 0, my_lrows);
+ AddFunction("Layout::width", 0, my_lcols);
+
+ return 0;
+}
diff --git a/drv_generic.h b/drv_generic.h
new file mode 100644
index 0000000..e013fbd
--- /dev/null
+++ b/drv_generic.h
@@ -0,0 +1,47 @@
+/* $Id: drv_generic.h,v 1.4 2006/07/31 03:48:09 reinelt Exp $
+ *
+ * generic driver helper
+ *
+ * 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: drv_generic.h,v $
+ * Revision 1.4 2006/07/31 03:48:09 reinelt
+ * preparations for scrolling
+ *
+ */
+
+
+#ifndef _DRV_GENERIC_H_
+#define _DRV_GENERIC_H_
+
+/* these values are chars (text displays) or pixels (graphic displays) */
+
+extern int LROWS, LCOLS; /* layout size */
+extern int DROWS, DCOLS; /* display size */
+
+extern int XRES, YRES; /* pixel width/height of one char */
+
+/* these function must be implemented by the generic driver */
+extern void (*drv_generic_blit) (const int row, const int col, const int height, const int width);
+
+int drv_generic_init(void);
+
+#endif
diff --git a/drv_generic_graphic.c b/drv_generic_graphic.c
index bf11a24..197450c 100644
--- a/drv_generic_graphic.c
+++ b/drv_generic_graphic.c
@@ -1,4 +1,4 @@
-/* $Id
+/* $Id: drv_generic_graphic.c,v 1.29 2006/07/31 03:48:09 reinelt Exp $
*
* generic driver helper for graphic displays
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_generic_graphic.c,v $
+ * Revision 1.29 2006/07/31 03:48:09 reinelt
+ * preparations for scrolling
+ *
* Revision 1.28 2006/06/20 08:50:58 reinelt
* widget_image linker error hopefully finally fixed
*
@@ -174,6 +177,7 @@
#include "widget_image.h"
#include "rgb.h"
#include "drv.h"
+#include "drv_generic.h"
#include "drv_generic_graphic.h"
#include "font_6x8.h"
@@ -181,9 +185,6 @@
#include <dmalloc.h>
#endif
-int DROWS, DCOLS; /* display size (pixels!) */
-int XRES, YRES; /* pixels of one char cell */
-
/* pixel colors */
RGBA FG_COL = { R: 0x00, G: 0x00, B: 0x00, A:0xff };
RGBA BG_COL = { R: 0xff, G: 0xff, B: 0xff, A:0xff };
@@ -193,10 +194,6 @@ RGBA NO_COL = { R: 0x00, G: 0x00, B: 0x00, A:0x00 };
static char *Section = NULL;
static char *Driver = NULL;
-/* layout size (pixels!) */
-static int LROWS = 0;
-static int LCOLS = 0;
-
/* framebuffer */
static RGBA *drv_generic_graphic_FB[LAYERS] = { NULL, };
@@ -647,6 +644,9 @@ int drv_generic_graphic_init(const char *section, const char *driver)
}
}
+ /* init generic driver & register plugins */
+ drv_generic_init();
+
/* set default colors */
color = cfg_get(Section, "foreground", "000000ff");
if (color2RGBA(color, &FG_COL) < 0) {
diff --git a/drv_generic_graphic.h b/drv_generic_graphic.h
index c51dfdc..106ac2a 100644
--- a/drv_generic_graphic.h
+++ b/drv_generic_graphic.h
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_graphic.h,v 1.12 2006/02/27 06:14:46 reinelt Exp $
+/* $Id: drv_generic_graphic.h,v 1.13 2006/07/31 03:48:09 reinelt Exp $
*
* generic driver helper for graphic displays
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_generic_graphic.h,v $
+ * Revision 1.13 2006/07/31 03:48:09 reinelt
+ * preparations for scrolling
+ *
* Revision 1.12 2006/02/27 06:14:46 reinelt
* graphic bug resulting in all black pixels solved
*
@@ -76,12 +79,10 @@
#ifndef _DRV_GENERIC_GRAPHIC_H_
#define _DRV_GENERIC_GRAPHIC_H_
+#include "drv_generic.h"
#include "widget.h"
#include "rgb.h"
-extern int DROWS, DCOLS; /* display size */
-extern int XRES, YRES; /* pixel width/height of one char */
-
extern RGBA FG_COL; /* foreground color */
extern RGBA HG_COL; /* halfground color */
extern RGBA BG_COL; /* background color */
diff --git a/drv_generic_i2c.c b/drv_generic_i2c.c
index a77d020..b9ef1b6 100644
--- a/drv_generic_i2c.c
+++ b/drv_generic_i2c.c
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_i2c.c,v 1.7 2006/07/30 11:16:27 lfcorreia Exp $
+/* $Id: drv_generic_i2c.c,v 1.8 2006/07/31 03:48:09 reinelt Exp $
*
* generic driver helper for i2c displays
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_generic_i2c.c,v $
+ * Revision 1.8 2006/07/31 03:48:09 reinelt
+ * preparations for scrolling
+ *
* Revision 1.7 2006/07/30 11:16:27 lfcorreia
* Add back drv_generic_i2c_close function
*
@@ -142,18 +145,18 @@ int drv_generic_i2c_open(const char *section, const char *driver)
}
info("%s: initializing I2C slave device 0x%x", Driver, dev);
- if (i2c_smbus_write_quick(i2c_device, I2C_SMBUS_WRITE) < 0 ){
+ if (i2c_smbus_write_quick(i2c_device, I2C_SMBUS_WRITE) < 0) {
error("%s: error initializing device 0x%x\n", Driver, dev);
close(i2c_device);
- }
+ }
return 0;
exit_error:
free(bus);
free(device);
- close(i2c_device);
- return -1;
+ close(i2c_device);
+ return -1;
}
int drv_generic_i2c_close(void)
diff --git a/drv_generic_i2c.h b/drv_generic_i2c.h
index e30e8f8..579fcbe 100644
--- a/drv_generic_i2c.h
+++ b/drv_generic_i2c.h
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_i2c.h,v 1.6 2006/02/27 06:15:55 reinelt Exp $
+/* $Id: drv_generic_i2c.h,v 1.7 2006/07/31 03:48:09 reinelt Exp $
*
* generic driver helper for i2c displays
*
@@ -23,14 +23,17 @@
*
*
* $Log: drv_generic_i2c.h,v $
- * Revision 1.6 2006/02/27 06:15:55 reinelt
- * indent...
- *
- * Revision 1.5 2006/02/25 13:36:33 geronet
- * updated indent.sh, applied coding style
- *
- * Revision 1.4 2005/05/31 21:32:00 lfcorreia
- * fix my email address
+ * Revision 1.7 2006/07/31 03:48:09 reinelt
+ * preparations for scrolling
+ *
+ * Revision 1.6 2006/02/27 06:15:55 reinelt
+ * indent...
+ *
+ * Revision 1.5 2006/02/25 13:36:33 geronet
+ * updated indent.sh, applied coding style
+ *
+ * Revision 1.4 2005/05/31 21:32:00 lfcorreia
+ * fix my email address
*
* Revision 1.3 2005/05/31 20:42:55 lfcorreia
* new file: lcd4linux_i2c.h
@@ -82,4 +85,4 @@
void drv_generic_i2c_data(const unsigned char data);
void drv_generic_i2c_command(const unsigned char command, const unsigned char *data, const unsigned char length);
-#endif /* */
+#endif /* */
diff --git a/drv_generic_text.c b/drv_generic_text.c
index 8be347c..4bcbb51 100644
--- a/drv_generic_text.c
+++ b/drv_generic_text.c
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_text.c,v 1.35 2006/03/29 08:57:58 reinelt Exp $
+/* $Id: drv_generic_text.c,v 1.36 2006/07/31 03:48:09 reinelt Exp $
*
* generic driver helper for text-based displays
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_generic_text.c,v $
+ * Revision 1.36 2006/07/31 03:48:09 reinelt
+ * preparations for scrolling
+ *
* Revision 1.35 2006/03/29 08:57:58 reinelt
* vertical bar patch from Manuel Lausch
*
@@ -166,8 +169,6 @@
*
* exported variables:
*
- * extern int DROWS, DCOLS; display size
- * extern int XRES, YRES; pixel width/height of one char
* extern int CHARS, CHAR0; number of user-defineable characters, ASCII of first char
* extern int ICONS; number of user-defineable characters reserved for icons
* extern int GOTO_COST; number of bytes a goto command requires
@@ -232,6 +233,7 @@
#include "widget_icon.h"
#include "widget_bar.h"
#include "drv.h"
+#include "drv_generic.h"
#include "drv_generic_text.h"
#ifdef WITH_DMALLOC
@@ -260,11 +262,6 @@ typedef struct {
static char *Section = NULL;
static char *Driver = NULL;
-
-int DROWS = 20; /* display size: rows */
-int DCOLS = 4; /* display size: columns */
-int XRES = 6; /* pixels of one char cell */
-int YRES = 8; /* pixels of one char cell */
int CHARS = 0; /* number of user-defineable characters */
int CHAR0 = 0; /* ASCII of first user-defineable char */
int ICONS = 0; /* number of user-defineable characters reserved for icons */
@@ -277,11 +274,9 @@ void (*drv_generic_text_real_write) () = NULL;
void (*drv_generic_text_real_defchar) () = NULL;
-static int LROWS = 20; /* layout size: rows */
-static int LCOLS = 4; /* layout size: columns */
-
static char *LayoutFB = NULL;
static char *DisplayFB = NULL;
+static int *L2D = NULL;
static int Single_Segments = 0;
@@ -291,7 +286,6 @@ static SEGMENT Segment[128];
static BAR *BarFB = NULL;
-
/****************************************/
/*** generic Framebuffer stuff ***/
/****************************************/
@@ -299,6 +293,7 @@ static BAR *BarFB = NULL;
static void drv_generic_text_resizeFB(int rows, int cols)
{
char *newFB;
+ int *newL2D;
BAR *newBar;
int i, row, col;
@@ -313,8 +308,8 @@ static void drv_generic_text_resizeFB(int rows, int cols)
cols = LCOLS;
/* allocate new Layout FB */
- newFB = malloc(cols * rows * sizeof(char));
- memset(newFB, ' ', rows * cols * sizeof(char));
+ newFB = malloc(cols * rows * sizeof(*newFB));
+ memset(newFB, ' ', rows * cols * sizeof(*newFB));
/* transfer contents */
if (LayoutFB != NULL) {
@@ -327,6 +322,26 @@ static void drv_generic_text_resizeFB(int rows, int cols)
}
LayoutFB = newFB;
+ /* allocate new transformer */
+ newL2D = malloc(cols * rows * sizeof(*newL2D));
+
+ /* intitialize translator */
+ for (row = 0; row < rows; row++) {
+ for (col = 0; col < cols; col++) {
+ newL2D[row * cols + col] = row * DCOLS + col;
+ }
+ }
+
+ /* transfer transformer */
+ if (L2D != NULL) {
+ for (row = 0; row < LROWS; row++) {
+ for (col = 0; col < LCOLS; col++) {
+ newL2D[row * cols + col] = L2D[row * LCOLS + col];
+ }
+ }
+ free(L2D);
+ }
+ L2D = newL2D;
/* resize Bar buffer */
if (BarFB) {
@@ -357,6 +372,54 @@ static void drv_generic_text_resizeFB(int rows, int cols)
}
+static void drv_generic_text_blit(const int row, const int col, const int height, const int width)
+{
+ int lr, lc; /* layout row/col */
+ int dr, dc; /* display row/col */
+ int p1, p2; /* start/end positon of changed area */
+ int eq; /* counter for equal contents */
+
+ /* loop over layout rows */
+ for (lr = row; lr < LROWS && lr < row + height; lr++) {
+ /* transform layout to display row */
+ dr = lr;
+ /* sanity check */
+ if (dr < 0 || dr >= DROWS)
+ continue;
+ /* loop over layout cols */
+ for (lc = col; lc < LCOLS && lc < col + width; lc++) {
+ /* transform layout to display column */
+ dc = lc;
+ /* sanity check */
+ if (dc < 0 || dc >= DCOLS)
+ continue;
+ /* find start of difference */
+ if (DisplayFB[dr * DCOLS + dc] == LayoutFB[lr * LCOLS + lc])
+ continue;
+ /* find end of difference */
+ for (p1 = dc, p2 = p1, eq = 0, lc++; lc < LCOLS && lc < col + width; lc++) {
+ /* transform layout to display column */
+ dc = lc;
+ /* sanity check */
+ if (dc < 0 || dc >= DCOLS)
+ continue;
+ if (DisplayFB[dr * DCOLS + dc] == LayoutFB[lr * LCOLS + lc]) {
+ if (++eq > GOTO_COST)
+ break;
+ } else {
+ p2 = dc;
+ eq = 0;
+ }
+ }
+ /* send to display */
+ memcpy(DisplayFB + dr * DCOLS + p1, LayoutFB + lr * LCOLS + p1, p2 - p1 + 1);
+ if (drv_generic_text_real_write)
+ drv_generic_text_real_write(dr, p1, DisplayFB + dr * DCOLS + p1, p2 - p1 + 1);
+ }
+ }
+}
+
+
/****************************************/
/*** generic text handling ***/
/****************************************/
@@ -368,21 +431,26 @@ int drv_generic_text_init(const char *section, const char *driver)
Driver = (char *) driver;
/* init display framebuffer */
- DisplayFB = (char *) malloc(DCOLS * DROWS * sizeof(char));
- memset(DisplayFB, ' ', DROWS * DCOLS * sizeof(char));
+ DisplayFB = (char *) malloc(DCOLS * DROWS * sizeof(*DisplayFB));
+ memset(DisplayFB, ' ', DROWS * DCOLS * sizeof(*DisplayFB));
/* init layout framebuffer */
LROWS = 0;
LCOLS = 0;
LayoutFB = NULL;
+ L2D = NULL;
drv_generic_text_resizeFB(DROWS, DCOLS);
/* sanity check */
- if (LayoutFB == NULL || DisplayFB == NULL) {
+ if (DisplayFB == NULL || LayoutFB == NULL || L2D == NULL) {
error("%s: framebuffer could not be allocated: malloc() failed", Driver);
return -1;
}
+ /* init generic driver & register plugins */
+ drv_generic_blit = drv_generic_text_blit;
+ drv_generic_init();
+
return 0;
}
@@ -452,46 +520,22 @@ int drv_generic_text_greet(const char *msg1, const char *msg2)
int drv_generic_text_draw(WIDGET * W)
{
WIDGET_TEXT *Text = W->data;
- char *txt, *fb1, *fb2;
- int row, col, col0, len, end;
+ char *txt;
+ int row, col, len;
row = W->row;
col = W->col;
txt = Text->buffer;
len = strlen(txt);
- end = col + len;
/* maybe grow layout framebuffer */
drv_generic_text_resizeFB(row + 1, col + len);
- fb1 = LayoutFB + row * LCOLS;
- fb2 = DisplayFB + row * DCOLS;
-
/* transfer new text into layout buffer */
- memcpy(fb1 + col, txt, len);
+ memcpy(LayoutFB + row * LCOLS + col, txt, len);
- if (row < DROWS) {
- for (; col <= end && col < DCOLS; col++) {
- int pos1, pos2, equal;
- if (fb1[col] == fb2[col])
- continue;
- col0 = col;
- for (pos1 = col, pos2 = pos1, col++, equal = 0; col <= end && col < DCOLS; col++) {
- if (fb1[col] == fb2[col]) {
- /* If we find just one equal byte, we don't break, because this */
- /* would require a goto, which takes several bytes, too. */
- if (GOTO_COST >= 0 && ++equal > GOTO_COST)
- break;
- } else {
- pos2 = col;
- equal = 0;
- }
- }
- memcpy(fb2 + pos1, fb1 + pos1, pos2 - pos1 + 1);
- if (drv_generic_text_real_write)
- drv_generic_text_real_write(row, col0, fb2 + pos1, pos2 - pos1 + 1);
- }
- }
+ /* blit it */
+ drv_generic_text_blit(row, col, 1, len);
return 0;
}
@@ -500,20 +544,26 @@ int drv_generic_text_draw(WIDGET * W)
int drv_generic_text_quit(void)
{
+ if (DisplayFB) {
+ free(DisplayFB);
+ DisplayFB = NULL;
+ }
+
if (LayoutFB) {
free(LayoutFB);
LayoutFB = NULL;
}
- if (DisplayFB) {
- free(DisplayFB);
- DisplayFB = NULL;
+ if (L2D) {
+ free(L2D);
+ L2D = NULL;
}
if (BarFB) {
free(BarFB);
BarFB = NULL;
}
+
widget_unregister();
return (0);
@@ -540,7 +590,6 @@ int drv_generic_text_icon_draw(WIDGET * W)
static int icon_counter = 0;
WIDGET_ICON *Icon = W->data;
int row, col;
- int l_idx, d_idx;
int invalidate = 0;
unsigned char ascii;
@@ -576,20 +625,17 @@ int drv_generic_text_icon_draw(WIDGET * W)
/* use blank if invisible */
ascii = Icon->visible ? Icon->ascii : ' ';
- /* index into the two framebuffers */
- l_idx = row * LCOLS + col;
- d_idx = row * DCOLS + col;
-
/* transfer icon into layout buffer */
- LayoutFB[l_idx] = ascii;
+ LayoutFB[row * LCOLS + col] = ascii;
- /* maybe send icon to the display */
- if (row < DROWS && col < DCOLS && (DisplayFB[d_idx] != ascii || invalidate)) {
- DisplayFB[d_idx] = ascii;
- if (drv_generic_text_real_write)
- drv_generic_text_real_write(row, col, DisplayFB + d_idx, 1);
+ /* ugly invalidation: change display FB to a wrong value so blit() will really send it */
+ if (invalidate) {
+ DisplayFB[row * DCOLS + col] = ~ascii;
}
+ /* blit it */
+ drv_generic_text_blit(row, col, 1, 1);
+
return 0;
}
@@ -1005,7 +1051,7 @@ static void drv_generic_text_bar_define_chars(void)
int drv_generic_text_bar_draw(WIDGET * W)
{
WIDGET_BAR *Bar = W->data;
- int row, col, col0, len, res, max, val1, val2;
+ int row, col, len, res, max, val1, val2;
int c, n, s;
DIRECTION dir;
STYLE style;
@@ -1077,34 +1123,15 @@ int drv_generic_text_bar_draw(WIDGET * W)
/* maybe invalidate display framebuffer */
if (BarFB[n].invalid) {
BarFB[n].invalid = 0;
+ /* ugly invalidation: change display FB to a wrong value so blit() will really send it */
DisplayFB[row * DCOLS + col] = ~LayoutFB[n];
}
}
}
- /* transfer differences to the display */
- for (row = 0; row < DROWS; row++) {
- for (col = 0; col < DCOLS; col++) {
- int pos1, pos2, equal;
- if (LayoutFB[row * LCOLS + col] == DisplayFB[row * DCOLS + col])
- continue;
- col0 = col;
- for (pos1 = col, pos2 = pos1, col++, equal = 0; col < DCOLS; col++) {
- if (LayoutFB[row * LCOLS + col] == DisplayFB[row * DCOLS + col]) {
- /* If we find just one equal byte, we don't break, because this */
- /* would require a goto, which takes several bytes, too. */
- if (++equal > GOTO_COST)
- break;
- } else {
- pos2 = col;
- equal = 0;
- }
- }
- memcpy(DisplayFB + row * DCOLS + pos1, LayoutFB + row * LCOLS + pos1, pos2 - pos1 + 1);
- if (drv_generic_text_real_write)
- drv_generic_text_real_write(row, col0, DisplayFB + row * DCOLS + pos1, pos2 - pos1 + 1);
- }
- }
+ /* blit whole layout FB */
+ drv_generic_text_blit(0, 0, LROWS, LCOLS);
+
return 0;
diff --git a/drv_generic_text.h b/drv_generic_text.h
index 61e9320..1ba9b1b 100644
--- a/drv_generic_text.h
+++ b/drv_generic_text.h
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_text.h,v 1.20 2006/01/30 05:47:38 reinelt Exp $
+/* $Id: drv_generic_text.h,v 1.21 2006/07/31 03:48:09 reinelt Exp $
*
* generic driver helper for text-based displays
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_generic_text.h,v $
+ * Revision 1.21 2006/07/31 03:48:09 reinelt
+ * preparations for scrolling
+ *
* Revision 1.20 2006/01/30 05:47:38 reinelt
* graphic subsystem changed to full-color RGBA
*
@@ -108,12 +111,9 @@
#define _DRV_GENERIC_TEXT_H_
-#include <termios.h>
+#include "drv_generic.h"
#include "widget.h"
-
-extern int DROWS, DCOLS; /* display size */
-extern int XRES, YRES; /* pixel width/height of one char */
extern int CHARS, CHAR0; /* number of user-defineable characters, ASCII of first char */
extern int ICONS; /* number of user-defineable characters reserved for icons */
extern int GOTO_COST; /* number of bytes a goto command requires */
diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample
index 123a14d..884eb84 100644
--- a/lcd4linux.conf.sample
+++ b/lcd4linux.conf.sample
@@ -474,7 +474,6 @@ Widget BusyBar {
expression2 proc_stat::cpu('system', 500)
length 10
direction 'E'
- style 'H'
update tack
}
@@ -1052,14 +1051,14 @@ Layout testMySQL {
#Display 'BWCT'
#Display 'Image'
#Display 'Trefon'
-#Display 'LCD2USB'
+Display 'LCD2USB'
#Display 'LPH7508-serdisplib'
-Display 'LPH7508'
+#Display 'LPH7508'
#Display 'ctinclud'
-#Layout 'Default'
+Layout 'Default'
#Layout 'TestLayer'
-Layout 'TestImage'
+#Layout 'TestImage'
#Layout 'L8x2'
#Layout 'L16x1'
#Layout 'L16x2'
diff --git a/plugin.c b/plugin.c
index b2f924b..00f26ee 100644
--- a/plugin.c
+++ b/plugin.c
@@ -1,4 +1,4 @@
-/* $Id: plugin.c,v 1.43 2006/07/30 11:29:02 lfcorreia Exp $
+/* $Id: plugin.c,v 1.44 2006/07/31 03:48:09 reinelt Exp $
*
* plugin handler for the Evaluator
*
@@ -23,6 +23,9 @@
*
*
* $Log: plugin.c,v $
+ * Revision 1.44 2006/07/31 03:48:09 reinelt
+ * preparations for scrolling
+ *
* Revision 1.43 2006/07/30 11:29:02 lfcorreia
* Make changes suggested by Michael, only one init function is needed
*
@@ -286,7 +289,6 @@ int plugin_init(void)
plugin_init_cfg();
plugin_init_math();
plugin_init_string();
- plugin_init_strupper();
plugin_init_test();
plugin_init_time();
diff --git a/plugin_string.c b/plugin_string.c
index 7684f67..1aeb478 100644
--- a/plugin_string.c
+++ b/plugin_string.c
@@ -1,4 +1,4 @@
-/* $Id: plugin_string.c,v 1.10 2006/07/30 11:29:02 lfcorreia Exp $
+/* $Id: plugin_string.c,v 1.11 2006/07/31 03:48:09 reinelt Exp $
*
* string plugin
*
@@ -23,6 +23,9 @@
*
*
* $Log: plugin_string.c,v $
+ * Revision 1.11 2006/07/31 03:48:09 reinelt
+ * preparations for scrolling
+ *
* Revision 1.10 2006/07/30 11:29:02 lfcorreia
* Make changes suggested by Michael, only one init function is needed
*
@@ -77,6 +80,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <ctype.h>
#include "debug.h"
#include "plugin.h"
@@ -89,29 +93,17 @@ static void my_strlen(RESULT * result, RESULT * arg1)
}
/* 'upcase' function (shamelessly stolen from plugin_sample.c)*/
-/* takes one argument, a string */
/* returns the string in upper case letters */
-
-static void my_upcase(RESULT * result, RESULT * arg1)
+static void my_strupper(RESULT * result, RESULT * arg1)
{
char *value, *p;
- /* create a local copy of the argument */
- /* Do *NOT* try to modify the original string! */
value = strdup(R2S(arg1));
- /* process the string */
for (p = value; *p != '\0'; p++)
*p = toupper(*p);
- /* store result */
- /* when called with R_STRING, it assumes the */
- /* next parameter to be a pointer to a string */
- /* 'value' is already a char*, so use 'value', not '&value' */
SetResult(&result, R_STRING, value);
-
- /* free local copy again */
- /* Note that SetResult() makes its own string copy */
free(value);
}
@@ -120,14 +112,11 @@ int plugin_init_string(void)
/* register some basic string functions */
AddFunction("strlen", 1, my_strlen);
-
- /* register my UPPERCASE transforming function */
- AddFunction("strupper", 1, my_upcase);
-
+ AddFunction("strupper", 1, my_strupper);
return 0;
}
void plugin_exit_string(void)
{
/* empty */
-} \ No newline at end of file
+}
diff --git a/widget_timer.c b/widget_timer.c
index 0190acd..4c6b055 100644
--- a/widget_timer.c
+++ b/widget_timer.c
@@ -1,4 +1,4 @@
-/* $Id: widget_timer.c,v 1.2 2006/02/25 13:36:33 geronet Exp $
+/* $Id: widget_timer.c,v 1.3 2006/07/31 03:48:09 reinelt Exp $
*
* timer widget handling
*
@@ -21,6 +21,9 @@
*
*
* $Log: widget_timer.c,v $
+ * Revision 1.3 2006/07/31 03:48:09 reinelt
+ * preparations for scrolling
+ *
* Revision 1.2 2006/02/25 13:36:33 geronet
* updated indent.sh, applied coding style
*
@@ -109,17 +112,17 @@ int widget_timer_init(WIDGET * Self)
memset(Timer, 0, sizeof(WIDGET_TIMER));
/* get raw expressions (we evaluate them ourselves) */
- Timer->expression = cfg_get_raw(section, "axpression", NULL);
+ Timer->expression = cfg_get_raw(section, "expression", 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);
+ 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);
+ error("Timer '%s' has no update, using '100'", Self->name);
Timer->update_expr = "100";
}