aboutsummaryrefslogtreecommitdiffstats
path: root/drv_HD44780.c
diff options
context:
space:
mode:
Diffstat (limited to 'drv_HD44780.c')
-rw-r--r--drv_HD44780.c309
1 files changed, 55 insertions, 254 deletions
diff --git a/drv_HD44780.c b/drv_HD44780.c
index a838044..a8c5424 100644
--- a/drv_HD44780.c
+++ b/drv_HD44780.c
@@ -1,4 +1,5 @@
-/* $Id: drv_HD44780.c,v 1.64 2006/08/10 20:40:46 reinelt Exp $
+/* $Id: drv_HD44780.c 741 2007-01-17 05:56:27Z michael $
+ * $URL: https://ssl.bulix.org/svn/lcd4linux/branches/0.10.1/drv_HD44780.c $
*
* new style driver for HD44780-based displays
*
@@ -30,251 +31,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- *
- * $Log: drv_HD44780.c,v $
- * Revision 1.64 2006/08/10 20:40:46 reinelt
- * M50530 enhancements: Timings, busy-flag checking
- *
- * Revision 1.63 2006/07/29 20:59:12 lfcorreia
- * Fix wrong timing at I2C initialization
- *
- * Revision 1.62 2006/01/30 06:25:49 reinelt
- * added CVS Revision
- *
- * Revision 1.61 2006/01/05 19:27:26 reinelt
- * HD44780 power supply from parport
- *
- * Revision 1.60 2006/01/05 18:56:57 reinelt
- * more GPO stuff
- *
- * Revision 1.59 2006/01/03 06:13:44 reinelt
- * GPIO's for MatrixOrbital
- *
- * Revision 1.58 2005/12/20 07:07:44 reinelt
- * further work on GPO's, HD44780 GPO support
- *
- * Revision 1.57 2005/12/12 09:08:08 reinelt
- * finally removed old udelay code path; read timing values from config
- *
- * Revision 1.56 2005/12/12 05:52:03 reinelt
- * type of delays is 'unsigned long'
- *
- * Revision 1.55 2005/10/02 07:58:48 reinelt
- * HD44780 address setup time increased
- *
- * Revision 1.54 2005/06/09 17:41:47 reinelt
- * M50530 fixes (many thanks to Szymon Bieganski)
- *
- * Revision 1.53 2005/06/01 11:17:54 pk_richman
- * marked unused parameters
- *
- * Revision 1.52 2005/05/31 21:28:42 lfcorreia
- * fix typo
- *
- * Revision 1.50 2005/05/31 20:42:55 lfcorreia
- * new file: lcd4linux_i2c.h
- * avoid the problems detecting the proper I2C kernel include files
- *
- * rearrange all the other autoconf stuff to remove I2C detection
- *
- * new method by Paul Kamphuis to write to the I2C device
- *
- * Revision 1.49 2005/05/08 04:32:44 reinelt
- * CodingStyle added and applied
- *
- * Revision 1.48 2005/05/05 08:36:12 reinelt
- * changed SELECT to SLCTIN
- *
- * Revision 1.47 2005/03/28 22:29:23 reinelt
- * HD44780 multiple displays patch from geronet
- *
- * Revision 1.46 2005/03/28 19:39:23 reinelt
- * HD44780/I2C patch from Luis merged (still does not work for me)
- *
- * Revision 1.45 2005/03/25 15:44:43 reinelt
- * HD44780 Backlight fixed (thanks to geronet)
- *
- * Revision 1.44 2005/01/29 09:30:56 reinelt
- * minor HD44780 cleanups
- *
- * Revision 1.43 2005/01/18 06:30:23 reinelt
- * added (C) to all copyright statements
- *
- * Revision 1.42 2005/01/17 06:38:48 reinelt
- * info about backlight and brightness
- *
- * Revision 1.41 2005/01/17 06:29:24 reinelt
- * added software-controlled backlight support to HD44780
- *
- * Revision 1.40 2004/11/30 05:01:25 reinelt
- * removed compiler warnings for deactivated i2c bus
- *
- * Revision 1.39 2004/10/17 09:24:31 reinelt
- * I2C support for HD44780 displays by Luis (does not work by now)
- *
- * Revision 1.38 2004/09/19 09:31:19 reinelt
- * HD44780 busy flag checking improved: fall back to busy-waiting if too many errors occur
- *
- * Revision 1.37 2004/09/18 15:58:57 reinelt
- * even more HD44780 cleanups, hardwiring for LCM-162
- *
- * Revision 1.36 2004/09/18 10:57:29 reinelt
- * more parport/i2c cleanups
- *
- * Revision 1.35 2004/09/18 09:48:29 reinelt
- * HD44780 cleanup and prepararation for I2C backend
- * LCM-162 submodel framework
- *
- * Revision 1.34 2004/09/18 08:22:59 reinelt
- * drv_generic_parport_status() to read status lines
- *
- * Revision 1.33 2004/08/29 13:03:41 reinelt
- *
- * added RouterBoard driver
- *
- * Revision 1.32 2004/06/26 12:04:59 reinelt
- *
- * uh-oh... the last CVS log message messed up things a lot...
- *
- * Revision 1.31 2004/06/26 09:27:20 reinelt
- *
- * added '-W' to CFLAGS
- * changed all C++ comments to C ones
- * cleaned up a lot of signed/unsigned mistakes
- *
- * Revision 1.30 2004/06/20 10:09:54 reinelt
- *
- * 'const'ified the whole source
- *
- * Revision 1.29 2004/06/06 06:51:59 reinelt
- *
- * do not display end splash screen if quiet=1
- *
- * Revision 1.28 2004/06/05 06:41:39 reinelt
- *
- * chancged splash screen again
- *
- * Revision 1.27 2004/06/05 06:13:11 reinelt
- *
- * splash screen for all text-based display drivers
- *
- * Revision 1.26 2004/06/02 10:09:22 reinelt
- *
- * splash screen for HD44780
- *
- * Revision 1.25 2004/06/02 09:41:19 reinelt
- *
- * prepared support for startup splash screen
- *
- * Revision 1.24 2004/06/01 06:45:29 reinelt
- *
- * some Fixme's processed
- * documented some code
- *
- * Revision 1.23 2004/05/31 05:38:02 reinelt
- *
- * fixed possible bugs with user-defined chars (clear high bits)
- * thanks to Andy Baxter for debugging the MilfordInstruments driver!
- *
- * Revision 1.22 2004/05/27 03:39:47 reinelt
- *
- * changed function naming scheme to plugin::function
- *
- * Revision 1.21 2004/05/26 11:37:36 reinelt
- *
- * Curses driver ported.
- *
- * Revision 1.20 2004/05/22 04:23:49 reinelt
- *
- * removed 16*x fix again (next time think before commit :-)
- *
- * Revision 1.19 2004/05/22 04:21:02 reinelt
- *
- * fix for display RAM layout on 16x4 displays (thanks to toxicated101)
- *
- * Revision 1.18 2004/03/20 07:31:32 reinelt
- * support for HD66712 (which has a different RAM layout)
- * further threading development
- *
- * Revision 1.17 2004/03/19 09:17:46 reinelt
- *
- * removed the extra 'goto' function, row and col are additional parameters
- * of the write() function now.
- *
- * Revision 1.16 2004/03/11 06:39:58 reinelt
- * big patch from Martin:
- * - reuse filehandles
- * - memory leaks fixed
- * - earlier busy-flag checking with HD44780
- * - reuse memory for strings in RESULT and hash
- * - netdev_fast to wavid time-consuming regex
- *
- * Revision 1.15 2004/03/03 03:47:04 reinelt
- * big patch from Martin Hejl:
- * - use qprintf() where appropriate
- * - save CPU cycles on gettimeofday()
- * - add quit() functions to free allocated memory
- * - fixed lots of memory leaks
- *
- * Revision 1.14 2004/03/01 04:29:51 reinelt
- * cfg_number() returns -1 on error, 0 if value not found (but default val used),
- * and 1 if value was used from the configuration.
- * HD44780 driver adopted to new cfg_number()
- * Crystalfontz 631 driver nearly finished
- *
- * Revision 1.13 2004/02/15 21:43:43 reinelt
- * T6963 driver nearly finished
- * framework for graphic displays done
- * i2c_sensors patch from Xavier
- * some more old generation files removed
- *
- * Revision 1.12 2004/02/14 11:56:17 reinelt
- * M50530 driver ported
- * changed lots of 'char' to 'unsigned char'
- *
- * Revision 1.11 2004/02/04 19:10:51 reinelt
- * Crystalfontz driver nearly finished
- *
- * Revision 1.10 2004/02/02 05:22:16 reinelt
- * Brightness fpr Noritake Displays avaliable as a plugin
- *
- * Revision 1.9 2004/02/01 11:51:22 hejl
- * Fixes for busy flag
- *
- * Revision 1.8 2004/02/01 08:05:12 reinelt
- * Crystalfontz 633 extensions (CRC checking and stuff)
- * Models table for HD44780
- * Noritake VFD BVrightness patch from Bill Paxton
- *
- * Revision 1.7 2004/01/30 07:12:35 reinelt
- * HD44780 busy-flag support from Martin Hejl
- * loadavg() uClibc replacement from Martin Heyl
- * round() uClibc replacement from Martin Hejl
- * warning in i2c_sensors fixed
- * [
- *
- * Revision 1.6 2004/01/29 04:40:02 reinelt
- * every .c file includes "config.h" now
- *
- * Revision 1.5 2004/01/23 07:04:17 reinelt
- * icons finished!
- *
- * Revision 1.4 2004/01/23 04:53:48 reinelt
- * icon widget added (not finished yet!)
- *
- * Revision 1.3 2004/01/22 07:57:45 reinelt
- * several bugs fixed where segfaulting on layout>display
- * Crystalfontz driver optimized, 632 display already works
- *
- * Revision 1.2 2004/01/21 06:39:27 reinelt
- * HD44780 missed the "clear display' sequence
- * asc255bug handling added
- * HD44780 tested, works here!
- *
- * Revision 1.1 2004/01/20 15:32:49 reinelt
- * first version of Next Generation HD44780 (untested! but it compiles...)
- * some cleanup in the other drivers
- *
*/
/*
@@ -310,7 +66,10 @@
#include "drv.h"
#include "drv_generic_text.h"
#include "drv_generic_gpio.h"
+
+#ifdef WITH_PARPORT
#include "drv_generic_parport.h"
+#endif
#ifdef WITH_I2C
#include "drv_generic_i2c.h"
@@ -324,10 +83,13 @@ static int Capabilities;
/* Timings */
+#ifdef WITH_PARPORT
static int T_CY, T_PW, T_AS, T_AH;
-static int T_POWER, T_INIT1, T_INIT2, T_EXEC, T_WRCG, T_CLEAR, T_HOME, T_ONOFF;
-static int T_GPO_ST, T_GPO_PW;
-static int T_POWER;
+#endif
+static int T_INIT1, T_INIT2, T_EXEC, T_WRCG, T_CLEAR, T_HOME, T_ONOFF;
+#ifdef WITH_PARPORT
+static int T_POWER, T_GPO_ST, T_GPO_PW;
+#endif
static int Bits = 0;
static int numControllers = 0;
@@ -344,9 +106,12 @@ static unsigned char SIGNAL_ENABLE;
static unsigned char SIGNAL_ENABLE2;
static unsigned char SIGNAL_ENABLE3;
static unsigned char SIGNAL_ENABLE4;
-static unsigned char SIGNAL_BACKLIGHT;
+
static unsigned char SIGNAL_GPO;
+#ifdef WITH_PARPORT
+static unsigned char SIGNAL_BACKLIGHT;
static unsigned char SIGNAL_POWER;
+#endif
/* maximum time to wait for the busy-flag (in usec) */
#define MAX_BUSYFLAG_WAIT 10000
@@ -355,11 +120,14 @@ static unsigned char SIGNAL_POWER;
#define MAX_BUSYFLAG_ERRORS 20
/* flag for busy-waiting vs. busy flag checking */
+#ifdef WITH_PARPORT
static int UseBusy = 0;
+#endif
/* buffer holding the GPO state */
+#ifdef WITH_PARPORT
static unsigned char GPO = 0;
-
+#endif
typedef struct {
int type;
@@ -406,6 +174,8 @@ static void (*drv_HD_stop) (void);
/*** parport dependant functions ***/
/****************************************/
+#ifdef WITH_PARPORT
+
static void drv_HD_PP_busy(const int controller)
{
static unsigned int errors = 0;
@@ -902,6 +672,8 @@ static void drv_HD_PP_stop(void)
}
+#endif
+
#ifdef WITH_I2C
@@ -1132,6 +904,8 @@ static void drv_HD_defchar(const int ascii, const unsigned char *matrix)
}
+#ifdef WITH_PARPORT
+
static int drv_HD_backlight(int backlight)
{
if (!(Capabilities & CAP_BACKLIGHT))
@@ -1147,6 +921,8 @@ static int drv_HD_backlight(int backlight)
return backlight;
}
+#endif
+
static int drv_HD_brightness(int brightness)
{
@@ -1169,6 +945,8 @@ static int drv_HD_brightness(int brightness)
}
+#ifdef WITH_PARPORT
+
static int drv_HD_GPO(const int num, const int val)
{
int v;
@@ -1196,6 +974,10 @@ static int drv_HD_GPO(const int num, const int val)
return v;
}
+#endif
+
+
+#ifdef WITH_PARPORT
static void drv_HD_LCM162_timer(void __attribute__ ((unused)) * notused)
{
@@ -1225,6 +1007,8 @@ static void drv_HD_LCM162_timer(void __attribute__ ((unused)) * notused)
}
}
+#endif
+
static int drv_HD_start(const char *section, const int quiet)
{
@@ -1262,14 +1046,23 @@ static int drv_HD_start(const char *section, const int quiet)
}
if (strcasecmp(bus, "parport") == 0) {
+
+#ifdef WITH_PARPORT
info("%s: using parallel port", Name);
Bus = BUS_PP;
drv_HD_load = drv_HD_PP_load;
drv_HD_command = drv_HD_PP_command;
drv_HD_data = drv_HD_PP_data;
drv_HD_stop = drv_HD_PP_stop;
+#else
+ error("%s: %s.Bus '%s' from %s not available:", Name, section, bus, cfg_source());
+ error("%s: lcd4linux was compiled without parport support!", Name);
+ free(bus);
+ return -1;
+#endif
} else if (strcasecmp(bus, "i2c") == 0) {
+
#ifdef WITH_I2C
info("%s: using I2C bus", Name);
Bus = BUS_I2C;
@@ -1396,6 +1189,7 @@ static int drv_HD_start(const char *section, const int quiet)
drv_HD_command(allControllers, 0x03, T_HOME); /* return home */
/* maybe set backlight */
+#ifdef WITH_PARPORT
if (Capabilities & CAP_BACKLIGHT) {
int backlight;
if (cfg_number(section, "Backlight", 0, 0, 1, &backlight) > 0) {
@@ -1403,6 +1197,7 @@ static int drv_HD_start(const char *section, const int quiet)
drv_HD_backlight(backlight);
}
}
+#endif
/* maybe set brightness */
if (Capabilities & CAP_BRIGHTNESS) {
@@ -1414,9 +1209,11 @@ static int drv_HD_start(const char *section, const int quiet)
}
/* install keypad polling timer for LCM-162 */
+#ifdef WITH_PARPORT
if (Capabilities & CAP_LCM162) {
timer_add(drv_HD_LCM162_timer, NULL, 10, 0);
}
+#endif
if (!quiet) {
char buffer[40];
@@ -1436,6 +1233,7 @@ static int drv_HD_start(const char *section, const int quiet)
/****************************************/
+#ifdef WITH_PARPORT
static void plugin_backlight(RESULT * result, RESULT * arg1)
{
double backlight;
@@ -1443,7 +1241,7 @@ static void plugin_backlight(RESULT * result, RESULT * arg1)
backlight = drv_HD_backlight(R2N(arg1));
SetResult(&result, R_NUMBER, &backlight);
}
-
+#endif
static void plugin_brightness(RESULT * result, RESULT * arg1)
{
@@ -1489,7 +1287,7 @@ int drv_HD_init(const char *section, const int quiet)
int asc255bug;
int ret;
- info("%s: %s", Name, "$Revision: 1.64 $");
+ info("%s: %s", Name, "$Rev: 741 $");
/* display preferences */
XRES = 5; /* pixel width of one char */
@@ -1501,8 +1299,9 @@ int drv_HD_init(const char *section, const int quiet)
/* real worker functions */
drv_generic_text_real_write = drv_HD_write;
drv_generic_text_real_defchar = drv_HD_defchar;
+#ifdef WITH_PARPORT
drv_generic_gpio_real_set = drv_HD_GPO;
-
+#endif
/* start display */
if ((ret = drv_HD_start(section, quiet)) != 0)
@@ -1549,9 +1348,11 @@ int drv_HD_init(const char *section, const int quiet)
widget_register(&wc);
/* register plugins */
+#ifdef WITH_PARPORT
if (Capabilities & CAP_BACKLIGHT) {
AddFunction("LCD::backlight", 1, plugin_backlight);
}
+#endif
if (Capabilities & CAP_BRIGHTNESS) {
AddFunction("LCD::brightness", 1, plugin_brightness);
}