diff --git a/ChangeLog b/ChangeLog index b0f76d1..21e64c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -29,6 +29,7 @@ v.0.5dev (ongoing development) * CFontz633: Deprecate this driver. Use CFontzPacket with Model=633 instead! - Remove native win32 support. * picolcd: Use module output function to control key LEDs (Martin Jones) + + hd44780: Added 'usbtiny' connection type (Siarhei Herasimchuk) v0.5.3 + lcdexec: notification when called program finishes diff --git a/acinclude.m4 b/acinclude.m4 index ea423e4..2dfdd65 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -196,7 +196,7 @@ dnl else HD44780_DRIVERS="$HD44780_DRIVERS hd44780-hd44780-4bit.o hd44780-hd44780-ext8bit.o hd44780-lcd_sem.o hd44780-hd44780-winamp.o hd44780-hd44780-serialLpt.o" fi if test "$enable_libusb" = yes ; then - HD44780_DRIVERS="$HD44780_DRIVERS hd44780-hd44780-bwct-usb.o hd44780-hd44780-lcd2usb.o hd44780-hd44780-uss720.o" + HD44780_DRIVERS="$HD44780_DRIVERS hd44780-hd44780-bwct-usb.o hd44780-hd44780-lcd2usb.o hd44780-hd44780-uss720.o hd44780-hd44780-usbtiny.o" fi if test "$enable_libftdi" = yes ; then HD44780_DRIVERS="$HD44780_DRIVERS hd44780-hd44780-ftdi.o" diff --git a/docs/lcdproc-user/drivers/hd44780.docbook b/docs/lcdproc-user/drivers/hd44780.docbook index 58862ae..4266eac 100644 --- a/docs/lcdproc-user/drivers/hd44780.docbook +++ b/docs/lcdproc-user/drivers/hd44780.docbook @@ -104,6 +104,11 @@ more important. Here are the USB connection types the HD44780 driver supports: Till Harbaum's LCD2USB () + + usbtiny: + Dick Streefland's USBtiny () + + uss720: Display connected to USS-720 USB-to-IEEE 1284 Bridge (Belkin F5U002) @@ -2365,6 +2370,33 @@ KeyDirect_3=Escape + +Dick Streefland's "USBtiny" + + +USBtiny +is a software implementation of the USB low-speed protocol for +the Atmel ATtiny microcontrollers. It is also the name of a 'reference +circuit' using the ATtiny2313. + + + +The reference circuit features an IR receiver for remote controls and a LCD. +Due to hardware limitations of the ATtiny2313 the LCD does not have switchable +backlight, adjustable contrast, any keys, nor does it support displays with +more than one controller. If you want these features and do not require the +IR receiver we recommend to take a look at the LCD2USB +device. + + + + + LCDproc does not make use of the IR receiver. 3rd party software is required + to make it do anything, e.g. LIRC. + + + + @@ -2760,6 +2792,10 @@ This can be done by specifying or by inclu lcd2usb Till Harbaum's LCD2USB () + + usbtiny + Dick Streefland's USBtiny () + lis2 LIS2 from VLSystem () diff --git a/server/drivers/Makefile.am b/server/drivers/Makefile.am index e71068d..0d1733f 100644 --- a/server/drivers/Makefile.am +++ b/server/drivers/Makefile.am @@ -84,7 +84,7 @@ g15_SOURCES = lcd.h lcd_lib.h g15.h g15-num.c g15.c report.h glcdlib_SOURCES = lcd.h lcd_lib.h glcdlib.h glcdlib.c report.h glk_SOURCES = lcd.h glk.c glk.h glkproto.c glkproto.h report.h hd44780_SOURCES = lcd.h lcd_lib.h hd44780.h hd44780.c hd44780-drivers.h hd44780-low.h hd44780-charmap.h report.h adv_bignum.h -EXTRA_hd44780_SOURCES = hd44780-4bit.c hd44780-4bit.h hd44780-ext8bit.c hd44780-ext8bit.h lcd_sem.c lcd_sem.h hd44780-serialLpt.c hd44780-serialLpt.h hd44780-serial.c hd44780-serial.h hd44780-winamp.c hd44780-winamp.h hd44780-bwct-usb.c hd44780-bwct-usb.h hd44780-lcd2usb.c hd44780-lcd2usb.h hd44780-lis2.c hd44780-lis2.h hd44780-i2c.c hd44780-i2c.h hd44780-ftdi.c hd44780-ftdi.h hd44780-ethlcd.c hd44780-ethlcd.h hd44780-uss720.c hd44780-uss720.h hd44780-usblcd.c hd44780-usblcd.h port.h lpt-port.h timing.h +EXTRA_hd44780_SOURCES = hd44780-4bit.c hd44780-4bit.h hd44780-ext8bit.c hd44780-ext8bit.h lcd_sem.c lcd_sem.h hd44780-serialLpt.c hd44780-serialLpt.h hd44780-serial.c hd44780-serial.h hd44780-winamp.c hd44780-winamp.h hd44780-bwct-usb.c hd44780-bwct-usb.h hd44780-lcd2usb.c hd44780-lcd2usb.h hd44780-usbtiny.c hd44780-usbtiny.h hd44780-lis2.c hd44780-lis2.h hd44780-i2c.c hd44780-i2c.h hd44780-ftdi.c hd44780-ftdi.h hd44780-ethlcd.c hd44780-ethlcd.h hd44780-uss720.c hd44780-uss720.h hd44780-usblcd.c hd44780-usblcd.h port.h lpt-port.h timing.h i2500vfd_SOURCES = lcd.h i2500vfd.c i2500vfd.h i2500vfdfm.c i2500vfdfm.h report.h icp_a106_SOURCES = lcd.h lcd_lib.h icp_a106.c icp_a106.h report.h imon_SOURCES = lcd.h lcd_lib.h imon.h imon.c report.h diff --git a/server/drivers/hd44780-drivers.h b/server/drivers/hd44780-drivers.h index 288504e..995be02 100644 --- a/server/drivers/hd44780-drivers.h +++ b/server/drivers/hd44780-drivers.h @@ -22,6 +22,7 @@ #ifdef HAVE_LIBUSB # include "hd44780-bwct-usb.h" # include "hd44780-lcd2usb.h" +# include "hd44780-usbtiny.h" # include "hd44780-uss720.h" #endif #ifdef HAVE_LIBFTDI @@ -65,6 +66,7 @@ static const ConnectionMapping connectionMapping[] = { #ifdef HAVE_LIBUSB { "bwctusb", HD44780_CT_BWCTUSB, IF_TYPE_USB, hd_init_bwct_usb }, { "lcd2usb", HD44780_CT_LCD2USB, IF_TYPE_USB, hd_init_lcd2usb }, + { "usbtiny", HD44780_CT_USBTINY, IF_TYPE_USB, hd_init_usbtiny }, { "uss720", HD44780_CT_USS720, IF_TYPE_USB, hd_init_uss720 }, #endif #ifdef HAVE_LIBFTDI diff --git a/server/drivers/hd44780-low.h b/server/drivers/hd44780-low.h index 250dc10..9ad9d9c 100644 --- a/server/drivers/hd44780-low.h +++ b/server/drivers/hd44780-low.h @@ -50,6 +50,7 @@ #define HD44780_CT_ETHLCD 17 #define HD44780_CT_USS720 18 #define HD44780_CT_USBLCD 19 +#define HD44780_CT_USBTINY 20 // symbolic names for interface types #define IF_TYPE_UNKNOWN 0 diff --git a/server/drivers/hd44780-usbtiny.c b/server/drivers/hd44780-usbtiny.c new file mode 100644 index 0000000..3e3e4c1 --- /dev/null +++ b/server/drivers/hd44780-usbtiny.c @@ -0,0 +1,139 @@ +/** \file server/drivers/hd44780-usbtiny.c + * \c USBtiny connection type of \c hd44780 driver for Hitachi HD44780 based LCD displays. + * + * http://www.xs4all.nl/~dicks/avr/usbtiny/ + */ + +/*- + * Copyright (C) 2007 Peter Marschall + * 2010 Siarhei Herasimchuk + * + * This file is released under the GNU General Public License. + * Refer to the COPYING file distributed with this package. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include + +#include "hd44780-usbtiny.h" +#include "report.h" + + +/* connection type specific functions to be exposed using pointers in init() */ +void usbtiny_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch); +void usbtiny_HD44780_close(PrivateData *p); + + +/** + * Pseudo (empty) uPause function. + * Override the uPause function as a usbtiny device takes care of timing itself. + * \param p Pointer to PrivateData structure (unused) + * \param usecs Number of micro-seconds to sleep (ignored) + */ +void +usbtiny_HD44780_uPause(PrivateData *p, int usecs) +{ +} + + +/** + * Initialize the driver. + * \param drvthis Pointer to driver structure. + * \retval 0 Success. + * \retval -1 Error. + */ +int +hd_init_usbtiny(Driver *drvthis) +{ + PrivateData *p = (PrivateData *) drvthis->private_data; + + struct usb_bus *bus; + + p->hd44780_functions->senddata = usbtiny_HD44780_senddata; + p->hd44780_functions->close = usbtiny_HD44780_close; + + /* try to find USB device */ + usb_init(); + usb_find_busses(); + usb_find_devices(); + + p->usbHandle = NULL; + for (bus = usb_get_busses(); bus != NULL; bus = bus->next) { + struct usb_device *dev; + + for (dev = bus->devices; dev != NULL; dev = dev->next) { + + /* Check if this device is a usbtiny device */ + if ((dev->descriptor.idVendor == USBTINY_VENDORID) && + (dev->descriptor.idProduct == USBTINY_PRODUCTID)) { + + /* USBtiny device found; try to open it */ + p->usbHandle = usb_open(dev); + if (p->usbHandle == NULL) { + report(RPT_WARNING, "hd_init_usbtiny: unable to open device"); + /* + * Do not exit here because other + * (possibly working) devices may be + * connected. + */ + } + else { + report(RPT_INFO, "hd_init_usbtiny: USBtiny device found"); + } + } + } + } + + /* No device found at all */ + if (p->usbHandle == NULL) { + report(RPT_ERR, "hd_init_usbtiny: no (matching) USBtiny device found"); + return -1; + } + + common_init(p, IF_4BIT); + + /* replace uPause with empty one after initialization */ + p->hd44780_functions->uPause = usbtiny_HD44780_uPause; + + return 0; +} + + +/** + * Send data or commands to the display. + * \param p Pointer to driver's private data structure. + * \param displayID ID of the display (or 0 for all) to send data to. + * \param flags Defines whether to end a command or data. + * \param ch The value to send. + */ +void +usbtiny_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch) +{ + int type = (flags == RS_DATA) ? USBTINY_DATA : USBTINY_INSTR; + char buffer[1]; + buffer[0] = (char) ch; + + usb_control_msg(p->usbHandle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, type, 0, 0, buffer, 1, 1000); +} + + +/** + * Close the driver (do necessary clean-up). + * \param p Pointer to driver's private data structure. + */ +void +usbtiny_HD44780_close(PrivateData *p) +{ + if (p->usbHandle != NULL) { + usb_close(p->usbHandle); + p->usbHandle = NULL; + } +} + +/* EOF */ diff --git a/server/drivers/hd44780-usbtiny.h b/server/drivers/hd44780-usbtiny.h new file mode 100644 index 0000000..5079209 --- /dev/null +++ b/server/drivers/hd44780-usbtiny.h @@ -0,0 +1,19 @@ +#ifndef HD_USBTINY_H +#define HD_USBTINY_H + +#include "lcd.h" /* for Driver */ +#include "hd44780-low.h" + +/* vendor and product id */ +#define USBTINY_VENDORID 0x03EB +#define USBTINY_PRODUCTID 0x0002 + +/* Protocole IR/LCD */ +#define USBTINY_INSTR 20 +#define USBTINY_DATA 21 + + +/* initialise this particular driver */ +int hd_init_usbtiny(Driver *drvthis); + +#endif