]> git.webhop.me Git - lcd4linux.git/commitdiff
driver for Newhaven's NHD‐0420D3Z‐FL‐GBW. 4x20 LCD by Rusty Clarkson
authormichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Wed, 27 Jul 2011 05:58:08 +0000 (05:58 +0000)
committermichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Wed, 27 Jul 2011 05:58:08 +0000 (05:58 +0000)
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1157 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

Makefile.am
Makefile.in
config.h.in
configure
drivers.m4
drv.c
drv_Newhaven.c [new file with mode: 0644]
drv_generic_i2c.c
drv_generic_i2c.h

index 0b3e9526f28a4f81de4b8ceb7c1526f0cf132821..d3717094811328774caec061b90639de45e4cdea 100644 (file)
@@ -97,6 +97,7 @@ drv_M50530.c                  \
 drv_MatrixOrbital.c           \
 drv_MatrixOrbitalGX.c         \
 drv_MilfordInstruments.c      \
+drv_Newhaven.c                \
 drv_Noritake.c                \
 drv_NULL.c                    \
 drv_Pertelian.c               \
index 776ae7ed98d37a976d2b05c71f8fe2fb0b4940ce..494806ab292f776e0d56c4987e61b574c79db0f3 100644 (file)
@@ -329,6 +329,7 @@ drv_M50530.c                  \
 drv_MatrixOrbital.c           \
 drv_MatrixOrbitalGX.c         \
 drv_MilfordInstruments.c      \
+drv_Newhaven.c                \
 drv_Noritake.c                \
 drv_NULL.c                    \
 drv_Pertelian.c               \
@@ -553,6 +554,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drv_MatrixOrbitalGX.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drv_MilfordInstruments.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drv_NULL.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drv_Newhaven.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drv_Noritake.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drv_PHAnderson.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drv_PICGraphic.Po@am__quote@
index 3cd728a3f62e7e9cc871bf86d5e8db0037a65e6a..d48c9fc622a7483ccd07c173a23255dd084c083c 100644 (file)
 /* Milford Instruments driver */
 #undef WITH_MILINST
 
+/* Newhaven driver */
+#undef WITH_NEWHAVEN
+
 /* Noritake driver */
 #undef WITH_NORITAKE
 
index 1856b0e3a96b94ef4a566bffd939dfc125415f3e..484146d7574bc5fcb41ac72a1bc0e27011b72628 100755 (executable)
--- a/configure
+++ b/configure
@@ -1443,8 +1443,8 @@ Optional Packages:
                           ASTUSB, BeckmannEgle, BWCT, CrystalFontz, Curses, Cwlinux, D4D,
                           EA232Graphic, EFN, FW8888, G15, GLCD2USB, HD44780, HD44780-I2C,
                           IRLCD, LCD2USB, LCDLinux, LEDMatrix, LCDTerm, LPH7508, LUIse,
-                          LW_ABP, M50530, MatrixOrbital, MatrixOrbitalGX,
-                          MilfordInstruments, Noritake, NULL, Pertelian, PHAnderson,
+                          LW_ABP, M50530, MatrixOrbital, MatrixOrbitalGX, MilfordInstruments,
+                          Newhaven, Noritake, NULL, Pertelian, PHAnderson,
                           PICGraphic, picoLCD, picoLCDGraphic, PNG, PPM, RouterBoard,
                           Sample, serdisplib, ShuttleVFD, SimpleLCD, st2205, T6963,
                           Trefon, ULA200, USBHUB, USBLCD, VNC, WincorNixdorf, X11
@@ -6250,6 +6250,7 @@ for driver in $drivers; do
          MATRIXORBITAL="yes"
          MATRIXORBITALGX="yes"
          MILINST="yes"
+         NEWHAVEN="yes"
          NORITAKE="yes"
          NULL="yes"
          PERTELIAN="yes"
@@ -6352,6 +6353,9 @@ for driver in $drivers; do
       MilfordInstruments)
          MILINST=$val
          ;;
+      Newhaven)
+         NEWHAVEN=$val
+         ;;
       Noritake)
          NORITAKE=$val;
          ;;
@@ -6773,6 +6777,16 @@ $as_echo "#define WITH_MILINST 1" >>confdefs.h
 
 fi
 
+if test "$NEWHAVEN" = "yes"; then
+   TEXT="yes"
+   #SERIAL="yes"
+   I2C="yes"
+   DRIVERS="$DRIVERS drv_Newhaven.o"
+
+$as_echo "#define WITH_NEWHAVEN 1" >>confdefs.h
+
+fi
+
 if test "$NORITAKE" = "yes"; then
    if test "$has_parport" = "true"; then
       TEXT="yes"
index 9e9908c5d6b59d44ebdf0f805d08980eb0137614..734903b91c1e24f0b19b4145cc8721ac356be1f7 100644 (file)
@@ -35,8 +35,8 @@ AC_ARG_WITH(
   [                        ASTUSB, BeckmannEgle, BWCT, CrystalFontz, Curses, Cwlinux, D4D,]
   [                        EA232Graphic, EFN, FW8888, G15, GLCD2USB, HD44780, HD44780-I2C,]
   [                        IRLCD, LCD2USB, LCDLinux, LEDMatrix, LCDTerm, LPH7508, LUIse,]
-  [                        LW_ABP, M50530, MatrixOrbital, MatrixOrbitalGX,]
-  [                        MilfordInstruments, Noritake, NULL, Pertelian, PHAnderson,]
+  [                        LW_ABP, M50530, MatrixOrbital, MatrixOrbitalGX, MilfordInstruments,]
+  [                        Newhaven, Noritake, NULL, Pertelian, PHAnderson,]
   [                        PICGraphic, picoLCD, picoLCDGraphic, PNG, PPM, RouterBoard,]
   [                        Sample, serdisplib, ShuttleVFD, SimpleLCD, st2205, T6963,]
   [                        Trefon, ULA200, USBHUB, USBLCD, VNC, WincorNixdorf, X11],
@@ -86,6 +86,7 @@ for driver in $drivers; do
          MATRIXORBITAL="yes"
          MATRIXORBITALGX="yes"
          MILINST="yes"
+         NEWHAVEN="yes"
          NORITAKE="yes"
          NULL="yes"
          PERTELIAN="yes"
@@ -188,6 +189,9 @@ for driver in $drivers; do
       MilfordInstruments)
          MILINST=$val
          ;;
+      Newhaven)
+         NEWHAVEN=$val
+         ;;
       Noritake)
          NORITAKE=$val;
          ;;
@@ -542,6 +546,14 @@ if test "$MILINST" = "yes"; then
    AC_DEFINE(WITH_MILINST,1,[Milford Instruments driver])
 fi
 
+if test "$NEWHAVEN" = "yes"; then
+   TEXT="yes"
+   #SERIAL="yes"
+   I2C="yes"
+   DRIVERS="$DRIVERS drv_Newhaven.o"
+   AC_DEFINE(WITH_NEWHAVEN,1,[Newhaven driver])
+fi
+
 if test "$NORITAKE" = "yes"; then
    if test "$has_parport" = "true"; then
       TEXT="yes"
diff --git a/drv.c b/drv.c
index 74af1c8d1578b6e8d55d6d06c1890ac444b1a497..778c4836d1dab648b8fb2e8767cb791270f4a6d5 100644 (file)
--- a/drv.c
+++ b/drv.c
@@ -73,6 +73,7 @@ extern DRIVER drv_M50530;
 extern DRIVER drv_MatrixOrbital;
 extern DRIVER drv_MatrixOrbitalGX;
 extern DRIVER drv_MilfordInstruments;
+extern DRIVER drv_Newhaven;
 extern DRIVER drv_Noritake;
 extern DRIVER drv_NULL;
 extern DRIVER drv_Pertelian;
@@ -182,6 +183,9 @@ DRIVER *Driver[] = {
 #ifdef WITH_MILINST
     &drv_MilfordInstruments,
 #endif
+#ifdef WITH_NEWHAVEN
+    &drv_Newhaven,
+#endif
 #ifdef WITH_NORITAKE
     &drv_Noritake,
 #endif
diff --git a/drv_Newhaven.c b/drv_Newhaven.c
new file mode 100644 (file)
index 0000000..1939a50
--- /dev/null
@@ -0,0 +1,526 @@
+/* $Id$
+ * $URL$
+ *
+ * Newhaven lcd4linux driver
+ *
+ * Copyright (C) 2005 Michael Reinelt <michael@reinelt.co.at>
+ * Copyright (C) 2005, 2006, 2007 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
+ * Copyright (C) 2011 Rusty Clarkson <rusty@sutus.com>
+ *
+ * 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.
+ *
+ */
+
+/*
+ * *** Newhaven NHD‐0420D3Z‐FL‐GBW ***
+ * A 20x4 LCD (Liquid Crystal Display).
+ *
+ * The display supports text mode provide 4 rows of 20 characters. This display
+ * also supports many functions. The documentation for this display can be found
+ * online easily. http://www.newhavendisplay.com/ would be a good place to start.
+ * This driver was designed with the NHD-0420D3Z-FL-GBW in mind, but I'm sure
+ * similar Newhaven displays will work with little to no effort.
+ *
+ * This driver is released under the GPL.
+ */
+
+/* 
+ *
+ * exported fuctions:
+ *
+ * struct DRIVER drv_Newhaven
+ *
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include "debug.h"
+#include "cfg.h"
+#include "qprintf.h"
+#include "udelay.h"
+#include "plugin.h"
+#include "widget.h"
+#include "widget_text.h"
+#include "widget_icon.h"
+#include "widget_bar.h"
+#include "drv.h"
+
+/* text mode display? */
+#include "drv_generic_text.h"
+
+/* serial port? */
+//#include "drv_generic_serial.h"
+
+/* i2c bus? */
+#ifdef WITH_I2C
+#include "drv_generic_i2c.h"
+#endif
+
+
+static char Name[] = "Newhaven";
+
+
+/* Newhaven Constants */
+
+/* Line 1 */
+#define NEWHAVEN_R1_C1 0x00
+/* Line 2 */
+#define NEWHAVEN_R2_C1 0x40
+/* Line 3 */
+#define NEWHAVEN_R3_C1 0x14
+/* Line 4 */
+#define NEWHAVEN_R4_C1 0x54
+
+#define NEWHAVEN_ROW_MAX 4
+#define NEWHAVEN_COL_MAX 20
+
+#define NEWHAVEN_COMMAND 0xFE
+
+#define NEWHAVEN_DISPLAY_ON 0x41
+#define NEWHAVEN_DISPLAY_OFF 0x42
+
+#define NEWHAVEN_BAUD_RATE_SET 0x61
+#define NEWHAVEN_BAUD_RATE_SHOW 0x71
+#define NEWHAVEN_I2C_ADDR_SET 0x62
+#define NEWHAVEN_I2C_ADDR_SHOW 0x72
+#define NEWHAVEN_I2C_ADDR_DEFAULT 0x28
+#define NEWHAVEN_DISPLAY_FIRMWARE_VER 0x70
+
+#define NEWHAVEN_CONTRAST_SET 0x52
+#define NEWHAVEN_CONTRAST_MIN 1
+#define NEWHAVEN_CONTRAST_MAX 50
+#define NEWHAVEN_CONTRAST_DEFAULT 25
+#define NEWHAVEN_BRIGHTNESS_SET 0x53
+#define NEWHAVEN_BRIGHTNESS_MIN 1
+#define NEWHAVEN_BRIGHTNESS_MAX 8
+#define NEWHAVEN_BRIGHTNESS_DEFAULT 6
+
+#define NEWHAVEN_CLEAR_SCREEN 0x51
+#define NEWHAVEN_DISPLAY_SHIFT_LEFT 0x55
+#define NEWHAVEN_DISPLAY_SHIFT_RIGHT 0x56
+
+#define NEWHAVEN_CURSOR_SET_POS 0x45
+#define NEWHAVEN_CURSOR_HOME 0x46
+#define NEWHAVEN_CURSOR_UNDERLINE_ON 0x47
+#define NEWHAVEN_CURSOR_UNDERLINE_OFF 0x48
+#define NEWHAVEN_CURSOR_LEFT_ONE 0x49
+#define NEWHAVEN_CURSOR_RIGHT_ONE 0x4A
+#define NEWHAVEN_CURSOR_BLINKING_ON 0x4B
+#define NEWHAVEN_CURSOR_BLINKING_OFF 0x4C
+#define NEWHAVEN_BACKSPACE 0x4E
+
+#define NEWHAVEN_LOAD_CUSTOM_CHAR 0x54
+
+
+/****************************************/
+/***  hardware dependant functions    ***/
+/****************************************/
+
+static int drv_Newhaven_open(const char *section)
+{
+    /* open serial port */
+    /* don't mind about device, speed and stuff, this function will take care of */
+
+    //if (drv_generic_serial_open(section, Name, 0) < 0)
+    //return -1;
+
+    /* open i2c port */
+
+    if (drv_generic_i2c_open(section, Name) < 0)
+       return -1;
+
+    return 0;
+}
+
+
+static int drv_Newhaven_close(void)
+{
+    /* close whatever port you've opened */
+    //drv_generic_serial_close();
+    drv_generic_i2c_close();
+
+    return 0;
+}
+
+
+/* dummy function that sends data to the display */
+static void drv_Newhaven_sendData(const char *data, const unsigned int len)
+{
+    unsigned int i;
+
+    /* send data to the serial port is easy... */
+    //drv_generic_serial_write(data, len);
+
+    /* sending data using other methods is a bit more tricky... */
+    for (i = 0; i < len; i++) {
+       /* send data to the i2c port */
+       drv_generic_i2c_byte(data[i]);
+    }
+
+}
+
+
+/* dummy function that sends commands to the display */
+static void drv_Newhaven_sendCommand(const char command, const char *data, const unsigned int len)
+{
+
+    /* send commands to the serial port */
+    //drv_generic_serial_write(NEWHAVEN_COMMAND, 1);
+    //drv_generic_serial_write(command, 1);
+
+    /* send commands to the i2c port */
+    drv_generic_i2c_byte(NEWHAVEN_COMMAND);
+    drv_generic_i2c_byte(command);
+
+    /* send data */
+    drv_Newhaven_sendData(data, len);
+
+}
+
+
+/* text mode displays only */
+static void drv_Newhaven_clear(void)
+{
+    char cmd;
+
+    /* do whatever is necessary to clear the display */
+    cmd = NEWHAVEN_CLEAR_SCREEN;
+    drv_Newhaven_sendCommand(cmd, NULL, 0);
+}
+
+
+/* Turn display on */
+static void drv_Newhaven_display_on(void)
+{
+    char cmd;
+
+    /* do whatever is necessary to turn on the display */
+    cmd = NEWHAVEN_DISPLAY_ON;
+    drv_Newhaven_sendCommand(cmd, NULL, 0);
+}
+
+
+/* Turn display off */
+static void __attribute__ ((unused)) drv_Newhaven_display_off(void)
+{
+    char cmd;
+
+    /* do whatever is necessary to turn off the display */
+    cmd = NEWHAVEN_DISPLAY_OFF;
+    drv_Newhaven_sendCommand(cmd, NULL, 0);
+}
+
+
+/* text mode displays only */
+static void drv_Newhaven_write(const int row, const int col, const char *data, int len)
+{
+    char cmd;
+    char wData[1];
+
+    /* do the cursor positioning here */
+    cmd = NEWHAVEN_CURSOR_SET_POS;
+    if (col < 0 || col > DCOLS - 1)
+       error("%s: Invalid col, %d. Valid cols 0-%d.", Name, col, DCOLS - 1);
+    if (len > DCOLS - (col + 1))
+       error("%s: Data length, %d, longer than columns left in row, %d.", Name, len, DCOLS - (col + 1));
+    switch (row) {
+    case 0:
+       wData[0] = NEWHAVEN_R1_C1 + col;
+       break;
+    case 1:
+       wData[0] = NEWHAVEN_R2_C1 + col;
+       break;
+    case 2:
+       wData[0] = NEWHAVEN_R3_C1 + col;
+       break;
+    case 3:
+       wData[0] = NEWHAVEN_R4_C1 + col;
+       break;
+    default:
+       error("%s: Invalid row, %d. Valid rows 0-%d.", Name, row, DROWS - 1);
+       return;
+    }
+    drv_Newhaven_sendCommand(cmd, wData, 1);
+
+    /* send string to the display */
+    drv_Newhaven_sendData(data, len);
+
+}
+
+/* text mode displays only */
+static void drv_Newhaven_defchar(const int ascii, const unsigned char *matrix)
+{
+    char cmd;
+    char wData[9];
+    int i;
+
+    /* call the 'define character' function */
+    cmd = NEWHAVEN_LOAD_CUSTOM_CHAR;
+    wData[0] = ascii;
+
+    /* send bitmap to the display */
+    for (i = 0; i < 8; i++) {
+       wData[i + 1] = *matrix++;
+    }
+    drv_Newhaven_sendCommand(cmd, wData, 9);
+}
+
+
+/* Set the contrast of the display */
+static int drv_Newhaven_contrast(int contrast)
+{
+    char cmd;
+    char wData[1];
+
+    /* adjust limits according to the display */
+    if (contrast < NEWHAVEN_CONTRAST_MIN)
+       contrast = NEWHAVEN_CONTRAST_MIN;
+    if (contrast > NEWHAVEN_CONTRAST_MAX)
+       contrast = NEWHAVEN_CONTRAST_MAX;
+
+    /* call a 'contrast' function */
+    cmd = NEWHAVEN_CONTRAST_SET;
+    wData[0] = contrast;
+    drv_Newhaven_sendCommand(cmd, wData, 1);
+
+    return contrast;
+}
+
+
+/* Set the brightness of the display */
+static int drv_Newhaven_brightness(int brightness)
+{
+    char cmd;
+    char wData[1];
+
+    /* adjust limits according to the display */
+    if (brightness < NEWHAVEN_BRIGHTNESS_MIN)
+       brightness = NEWHAVEN_BRIGHTNESS_MIN;
+    if (brightness > NEWHAVEN_BRIGHTNESS_MAX)
+       brightness = NEWHAVEN_BRIGHTNESS_MAX;
+
+    /* call a 'brightness' function */
+    cmd = NEWHAVEN_BRIGHTNESS_SET;
+    wData[0] = brightness;
+    drv_Newhaven_sendCommand(cmd, wData, 1);
+
+    return brightness;
+}
+
+
+/* start text mode display */
+static int drv_Newhaven_start(const char *section)
+{
+    int contrast, brightness;
+    int rows = -1, cols = -1;
+    char *s;
+
+    s = cfg_get(section, "Size", NULL);
+    if (s == NULL || *s == '\0') {
+       error("%s: no '%s.Size' entry from %s", Name, section, cfg_source());
+       return -1;
+    }
+    if (sscanf(s, "%dx%d", &cols, &rows) != 2 || rows < 1 || cols < 1 || rows > NEWHAVEN_ROW_MAX
+       || cols > NEWHAVEN_COL_MAX) {
+       error("%s: bad %s.Size '%s' from %s", Name, section, s, cfg_source());
+       free(s);
+       return -1;
+    }
+
+    DROWS = rows;
+    DCOLS = cols;
+
+    /* open communication with the display */
+    if (drv_Newhaven_open(section) < 0) {
+       return -1;
+    }
+
+    /* reset & initialize display */
+    drv_Newhaven_display_on();
+
+    if (cfg_number
+       (section, "Contrast", NEWHAVEN_CONTRAST_DEFAULT, NEWHAVEN_CONTRAST_MIN, NEWHAVEN_CONTRAST_MAX, &contrast) > 0) {
+       drv_Newhaven_contrast(contrast);
+    }
+
+    if (cfg_number
+       (section, "Brightness", NEWHAVEN_BRIGHTNESS_DEFAULT, NEWHAVEN_BRIGHTNESS_MIN, NEWHAVEN_BRIGHTNESS_MAX,
+        &brightness) > 0) {
+       drv_Newhaven_brightness(brightness);
+    }
+
+    drv_Newhaven_clear();      /* clear display */
+    sleep(1);
+
+    return 0;
+}
+
+
+/****************************************/
+/***            plugins               ***/
+/****************************************/
+
+static void plugin_contrast(RESULT * result, RESULT * arg1)
+{
+    double contrast;
+
+    contrast = drv_Newhaven_contrast(R2N(arg1));
+    SetResult(&result, R_NUMBER, &contrast);
+}
+
+static void plugin_brightness(RESULT * result, RESULT * arg1)
+{
+    double brightness;
+
+    brightness = drv_Newhaven_brightness(R2N(arg1));
+    SetResult(&result, R_NUMBER, &brightness);
+}
+
+
+/****************************************/
+/***        widget callbacks          ***/
+/****************************************/
+
+
+/* using drv_generic_text_draw(W) */
+/* using drv_generic_text_icon_draw(W) */
+/* using drv_generic_text_bar_draw(W) */
+
+
+/****************************************/
+/***        exported functions        ***/
+/****************************************/
+
+
+/* list models */
+int drv_Newhaven_list(void)
+{
+    printf("%s driver", Name);
+    return 0;
+}
+
+
+/* initialize driver & display */
+/* use this function for a text display */
+int drv_Newhaven_init(const char *section, const int quiet)
+{
+    WIDGET_CLASS wc;
+    int ret;
+
+    info("%s: %s", Name, "$Rev$");
+
+    /* display preferences */
+    XRES = 5;                  /* pixel width of one char  */
+    YRES = 8;                  /* pixel height of one char  */
+    CHARS = 8;                 /* number of user-defineable characters */
+    CHAR0 = 0;                 /* ASCII of first user-defineable char */
+    GOTO_COST = 2;             /* number of bytes a goto command requires */
+
+    /* real worker functions */
+    drv_generic_text_real_write = drv_Newhaven_write;
+    drv_generic_text_real_defchar = drv_Newhaven_defchar;
+
+
+    /* start display */
+    if ((ret = drv_Newhaven_start(section)) != 0)
+       return ret;
+
+    if (!quiet) {
+       char buffer[40];
+       qprintf(buffer, sizeof(buffer), "%s %dx%d", Name, DCOLS, DROWS);
+       if (drv_generic_text_greet(buffer, "www.bwct.de")) {
+           sleep(3);
+           drv_Newhaven_clear();
+       }
+    }
+
+    /* initialize generic text driver */
+    if ((ret = drv_generic_text_init(section, Name)) != 0)
+       return ret;
+
+    /* initialize generic icon driver */
+    if ((ret = drv_generic_text_icon_init()) != 0)
+       return ret;
+
+    /* initialize generic bar driver */
+    if ((ret = drv_generic_text_bar_init(0)) != 0)
+       return ret;
+
+    /* add fixed chars to the bar driver */
+    drv_generic_text_bar_add_segment(0, 0, 255, 32);   /* ASCII  32 = blank */
+
+
+    /* register text widget */
+    wc = Widget_Text;
+    wc.draw = drv_generic_text_draw;
+    widget_register(&wc);
+
+    /* register icon widget */
+    wc = Widget_Icon;
+    wc.draw = drv_generic_text_icon_draw;
+    widget_register(&wc);
+
+    /* register bar widget */
+    wc = Widget_Bar;
+    wc.draw = drv_generic_text_bar_draw;
+    widget_register(&wc);
+
+    /* register plugins */
+    AddFunction("LCD::contrast", 1, plugin_contrast);
+    AddFunction("LCD::brightness", 1, plugin_brightness);
+
+    return 0;
+}
+
+
+
+/* close driver & display */
+/* use this function for a text display */
+int drv_Newhaven_quit(const int quiet)
+{
+    info("%s: shutting down.", Name);
+
+    drv_generic_text_quit();
+
+    /* clear display */
+    drv_Newhaven_clear();
+
+    /* say goodbye... */
+    if (!quiet) {
+       drv_generic_text_greet("goodbye!", NULL);
+    }
+
+    debug("closing connection");
+    drv_Newhaven_close();
+
+    return (0);
+}
+
+
+/* use this one for a text display */
+DRIVER drv_Newhaven = {
+    .name = Name,
+    .list = drv_Newhaven_list,
+    .init = drv_Newhaven_init,
+    .quit = drv_Newhaven_quit,
+};
index f9fbafc09acefe3a984cb1db44af54d3e49b2784..2170b0cfaab8b60fcfd7a42eaf6d0d33116bdcdb 100644 (file)
@@ -161,6 +161,12 @@ unsigned char drv_generic_i2c_wire(const char *name, const char *deflt)
 }
 
 
+void drv_generic_i2c_byte(const unsigned char data)
+{
+    i2c_smbus_write_byte(i2c_device, data);
+}
+
+
 void drv_generic_i2c_data(const unsigned char data)
 {
     my_i2c_smbus_write_byte_data(i2c_device, data);
index 3cbfc4d996aad5b47435d079a0827abf24acba4e..2cc6a029effd69c0f1f940013097c9deb5bfd9e8 100644 (file)
@@ -55,6 +55,7 @@
 int drv_generic_i2c_open(const char *section, const char *driver);
 int drv_generic_i2c_close(void);
 unsigned char drv_generic_i2c_wire(const char *name, const char *deflt);
+void drv_generic_i2c_byte(const unsigned char data);
 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);