older version for rasplex, hope it works.
This commit is contained in:
@@ -23,7 +23,7 @@ AM_LDFLAGS = @LDSHARED@
|
||||
|
||||
lcdexecbindir = $(pkglibdir)
|
||||
lcdexecbin_PROGRAMS = @DRIVERS@
|
||||
EXTRA_PROGRAMS = bayrad CFontz CFontzPacket curses CwLnx debug ea65 EyeboxOne g15 glcd glcdlib glk hd44780 i2500vfd icp_a106 imon imonlcd IOWarrior irman irtrans joy lb216 lcdm001 lcterm linux_input lirc lis MD8800 mdm166a ms6931 mtc_s16209x MtxOrb mx5000 NoritakeVFD Olimex_MOD_LCD1x9 picolcd pyramid rawserial sdeclcd sed1330 sed1520 serialPOS serialVFD shuttleVFD sli stv5730 SureElec svga t6963 text tyan ula200 vlsys_m428 xosd yard2LCD
|
||||
EXTRA_PROGRAMS = bayrad CFontz CFontzPacket curses CwLnx debug ea65 EyeboxOne g15 glcd glcdlib glk hd44780 i2500vfd icp_a106 imon imonlcd IOWarrior irman irtrans joy lb216 lcdm001 lcterm lirc lis MD8800 mdm166a ms6931 mtc_s16209x MtxOrb mx5000 NoritakeVFD picolcd pyramid rawserial sdeclcd sed1330 sed1520 serialPOS serialVFD shuttleVFD sli stv5730 SureElec svga t6963 text tyan ula200 vlsys_m428 xosd
|
||||
noinst_LIBRARIES = libLCD.a libbignum.a
|
||||
|
||||
g15_CFLAGS = @LIBUSB_CFLAGS@ $(AM_CFLAGS)
|
||||
@@ -48,8 +48,8 @@ glcd_LDADD = libLCD.a @GLCD_DRIVERS@ @FT2_LIBS@ @LIBPNG_LIBS@ @LIBSERDIS
|
||||
glcd_DEPENDENCIES = @GLCD_DRIVERS@ glcd-glcd-render.o
|
||||
glcdlib_LDADD = @LIBGLCD@
|
||||
glk_LDADD = libbignum.a
|
||||
hd44780_LDADD = libLCD.a @HD44780_DRIVERS@ @HD44780_I2C@ @LIBUSB_LIBS@ @LIBFTDI_LIBS@ libbignum.a
|
||||
hd44780_DEPENDENCIES = @HD44780_DRIVERS@ @HD44780_I2C@
|
||||
hd44780_LDADD = libLCD.a @HD44780_DRIVERS@ @LIBUSB_LIBS@ @LIBFTDI_LIBS@ libbignum.a
|
||||
hd44780_DEPENDENCIES = @HD44780_DRIVERS@
|
||||
i2500vfd_LDADD = @LIBFTDI_LIBS@
|
||||
imon_LDADD = libLCD.a libbignum.a
|
||||
imonlcd_LDADD = libLCD.a
|
||||
@@ -94,8 +94,8 @@ glcd_SOURCES = lcd.h report.h glcd_drv.c glcd_drv.h glcd-low.h glcd-driver
|
||||
EXTRA_glcd_SOURCES = glcd-t6963.c t6963_low.c t6963_low.h glcd-png.c glcd-serdisp.c glcd-glcd2usb.c glcd-glcd2usb.h glcd-x11.c glcd-picolcdgfx.c
|
||||
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 i2c.h
|
||||
EXTRA_hd44780_SOURCES = port.h lpt-port.h timing.h i2c.c lcd_sem.c lcd_sem.h hd44780-4bit.c hd44780-4bit.h hd44780-bwct-usb.c hd44780-bwct-usb.h hd44780-ethlcd.c hd44780-ethlcd.h hd44780-ext8bit.c hd44780-ext8bit.h hd44780-ftdi.c hd44780-ftdi.h hd44780-i2c.c hd44780-i2c.h hd44780-lcd2usb.c hd44780-lcd2usb.h hd44780-lis2.c hd44780-lis2.h hd44780-pifacecad.c hd44780-pifacecad.h hd44780-piplate.c hd44780-piplate.h hd44780-rpi.c hd44780-rpi.h hd44780-serial.c hd44780-serial.h hd44780-serialLpt.c hd44780-serialLpt.h hd44780-spi.c hd44780-spi.h hd44780-usb4all.c hd44780-usb4all.h hd44780-usblcd.c hd44780-usblcd.h hd44780-usbtiny.c hd44780-usbtiny.h hd44780-uss720.c hd44780-uss720.h hd44780-winamp.c hd44780-winamp.h hd44780-lcm162.c hd44780-lcm162.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 = port.h lpt-port.h timing.h lcd_sem.c lcd_sem.h hd44780-4bit.c hd44780-4bit.h hd44780-bwct-usb.c hd44780-bwct-usb.h hd44780-ethlcd.c hd44780-ethlcd.h hd44780-ext8bit.c hd44780-ext8bit.h hd44780-ftdi.c hd44780-ftdi.h hd44780-i2c.c hd44780-i2c.h hd44780-lcd2usb.c hd44780-lcd2usb.h hd44780-lis2.c hd44780-lis2.h hd44780-pifacecad.c hd44780-pifacecad.h hd44780-piplate.c hd44780-piplate.h hd44780-rpi.c hd44780-rpi.h hd44780-serial.c hd44780-serial.h hd44780-serialLpt.c hd44780-serialLpt.h hd44780-spi.c hd44780-spi.h hd44780-usb4all.c hd44780-usb4all.h hd44780-usblcd.c hd44780-usblcd.h hd44780-usbtiny.c hd44780-usbtiny.h hd44780-uss720.c hd44780-uss720.h hd44780-winamp.c hd44780-winamp.h
|
||||
i2500vfd_SOURCES = lcd.h i2500vfd.c i2500vfd.h glcd_font5x8.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 hd44780-charmap.h imon.h imon.c report.h adv_bignum.h
|
||||
@@ -107,7 +107,6 @@ joy_SOURCES = lcd.h joy.c joy.h port.h report.h
|
||||
lb216_SOURCES = lcd.h lcd_lib.h lb216.c lb216.h report.h
|
||||
lcdm001_SOURCES = lcd.h lcdm001.c lcdm001.h report.h
|
||||
lcterm_SOURCES = lcd.h lcd_lib.h lcterm.c lcterm.h report.h
|
||||
linux_input_SOURCES = lcd.h linux_input.h linux_input.c report.h
|
||||
lirc_SOURCES = lcd.h lircin.c lircin.h report.h
|
||||
lis_SOURCES = lcd.h lcd_lib.h lis.h lis.c report.h
|
||||
MD8800_SOURCES = lcd.h lcd_lib.h MD8800.c MD8800.h report.h
|
||||
@@ -117,7 +116,6 @@ mtc_s16209x_SOURCES = lcd.h lcd_lib.h mtc_s16209x.c mtc_s16209x.h report.h
|
||||
MtxOrb_SOURCES = lcd.h lcd_lib.h MtxOrb.c MtxOrb.h report.h adv_bignum.h
|
||||
mx5000_SOURCES = lcd.h mx5000.c mx5000.h report.h
|
||||
NoritakeVFD_SOURCES = lcd.h lcd_lib.h NoritakeVFD.c NoritakeVFD.h report.h adv_bignum.h
|
||||
Olimex_MOD_LCD1x9_SOURCES = lcd.h report.h i2c.h i2c.c Olimex_MOD_LCD1x9.h Olimex_MOD_LCD1x9.c Olimex_MOD_LCD1x9_font.h
|
||||
rawserial_SOURCES = lcd.h rawserial.c rawserial.h
|
||||
picolcd_SOURCES = lcd.h picolcd.h picolcd.c report.h
|
||||
pyramid_SOURCES = lcd.h pylcd.c pylcd.h
|
||||
@@ -137,8 +135,6 @@ tyan_SOURCES = lcd.h lcd_lib.h tyan_lcdm.h tyan_lcdm.c report.h adv_bignum
|
||||
ula200_SOURCES = lcd.h adv_bignum.h ula200.h ula200.c report.h
|
||||
vlsys_m428_SOURCES = lcd.h report.h vlsys_m428.c vlsys_m428.h
|
||||
xosd_SOURCES = lcd.h xosdlib_drv.c xosdlib_drv.h report.h adv_bignum.h
|
||||
yard2LCD = lcd.h yard2LCD.c yard2LCD.h report.h
|
||||
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)
|
||||
|
||||
|
||||
@@ -1,227 +0,0 @@
|
||||
/** \file server/drivers/Olimex_MOD_LCD1x9.c
|
||||
* LCDd \c Olimex_MOD_LCD1x9 driver for MOD-LCD1x9 from Olimex.
|
||||
* This display uses a PCF857DU style controller.
|
||||
*/
|
||||
|
||||
/* Copyright (C) 2015 Harald Geyer <harald@ccbib.org>
|
||||
*
|
||||
* 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 of the License, or
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "lcd.h"
|
||||
#include "report.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "i2c.h"
|
||||
#include "Olimex_MOD_LCD1x9_font.h"
|
||||
|
||||
#define BUS_ADDRESS 0x38
|
||||
#define LEN_INIT_SEQ 24
|
||||
|
||||
/** private data for the \c Olimex_MOD_LCD1x9 driver */
|
||||
typedef struct olimex1x9_private_data {
|
||||
I2CHandle *dev; /**< handle of the i2c device */
|
||||
uint16_t buf[11]; /**< header + frame buffer */
|
||||
} PrivateData;
|
||||
|
||||
/* Vars for the server core */
|
||||
MODULE_EXPORT char *api_version = API_VERSION;
|
||||
MODULE_EXPORT int stay_in_foreground = 0;
|
||||
MODULE_EXPORT int supports_multiple = 1;
|
||||
MODULE_EXPORT char *symbol_prefix = "olimex1x9_";
|
||||
|
||||
/**
|
||||
* Initialize the driver.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \retval 0 Success.
|
||||
* \retval <0 Error.
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
olimex1x9_init (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p;
|
||||
const char *configvalue;
|
||||
char buffer[LEN_INIT_SEQ];
|
||||
uint8_t *preamble;
|
||||
int i;
|
||||
|
||||
/* Allocate and store private data */
|
||||
p = (PrivateData *) malloc(sizeof(PrivateData));
|
||||
if (p == NULL)
|
||||
return -1;
|
||||
if (drvthis->store_private_ptr(drvthis, p))
|
||||
return -1;
|
||||
|
||||
configvalue = drvthis->config_get_string(drvthis->name, "Device", 0, I2C_DEFAULT_DEVICE);
|
||||
p->dev = i2c_open(configvalue, BUS_ADDRESS);
|
||||
if (!p->dev) {
|
||||
report(RPT_ERR, "open i2c device '%s' failed: %s", configvalue, strerror(errno));
|
||||
return(-1);
|
||||
}
|
||||
|
||||
buffer[0] = 0xC8; /* Mode register */
|
||||
buffer[1] = 0xF0; /* Blink register */
|
||||
buffer[2] = 0xE0; /* Device select register */
|
||||
buffer[3] = 0x00; /* Point register */
|
||||
for (i = 4; i < LEN_INIT_SEQ; ++i)
|
||||
buffer[i] = 0xFF;
|
||||
|
||||
if (i2c_write(p->dev, buffer, LEN_INIT_SEQ) < 0) {
|
||||
report(RPT_ERR, "I2C: %s: sending of initialization data failed: %s", configvalue, strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
|
||||
preamble = (uint8_t *) p->buf;
|
||||
preamble[0] = 0xE0; /* Device select register */
|
||||
preamble[1] = 0x00; /* Point register */
|
||||
|
||||
report(RPT_DEBUG, "%s: init() done", drvthis->name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close the driver (do necessary clean-up).
|
||||
* \param drvthis Pointer to driver structure.
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
olimex1x9_close (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
if (p != NULL) {
|
||||
i2c_close(p->dev);
|
||||
free(p);
|
||||
}
|
||||
drvthis->store_private_ptr(drvthis, NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the display width in characters.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \return Number of characters the display is wide.
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
olimex1x9_width (Driver *drvthis)
|
||||
{
|
||||
return 9;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the display height in characters.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \return Number of characters the display is high.
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
olimex1x9_height (Driver *drvthis)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the screen.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
olimex1x9_clear (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
/* Don't overwrite the preamble part of the buffer */
|
||||
memset(&p->buf[1], 0, sizeof(p->buf) - sizeof(p->buf[0]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Flush data on screen to the display.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
olimex1x9_flush (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
i2c_write(p->dev, p->buf, sizeof(p->buf));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print a string on the screen at position (x,y).
|
||||
* The upper-left corner is (1,1), the lower-right corner is (9, 1).
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \param x Horizontal character position (column).
|
||||
* \param y Vertical character position (row).
|
||||
* \param string String that gets written.
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
olimex1x9_string (Driver *drvthis, int x, int y, const unsigned char string[])
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
int pos = 10 - x; /* The left side is on the upper end of the buffer */
|
||||
int count = 0;
|
||||
|
||||
while (string[count]) {
|
||||
switch (string[count]) {
|
||||
case '\b': /* Allow composition of characters */
|
||||
++pos;
|
||||
break;
|
||||
case ':': /* We can't display a proper ':' */
|
||||
case '.': /* Use the dot between characters if possible */
|
||||
if (pos < 9 &&
|
||||
!(p->buf[pos+1] & htons(olimex1x9_font['.'])))
|
||||
++pos;
|
||||
/* fall through */
|
||||
default:
|
||||
if (pos >= 1 && pos <= 9) /* no buffer overflow */
|
||||
p->buf[pos] |=
|
||||
htons(olimex1x9_font[string[count]]);
|
||||
--pos;
|
||||
}
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print a character on the screen at position (x,y).
|
||||
* The upper-left corner is (1,1), the lower-right corner is (9, 1).
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \param x Horizontal character position (column).
|
||||
* \param y Vertical character position (row).
|
||||
* \param c Character that gets written.
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
olimex1x9_chr (Driver *drvthis, int x, int y, unsigned char c)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
if (x < 1 || x > 9)
|
||||
return;
|
||||
|
||||
p->buf[10-x] |= olimex1x9_font[c];
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
#ifndef OLIMEX_LCD1x9_H
|
||||
#define OLIMEX_LCD1x9_H
|
||||
|
||||
MODULE_EXPORT int olimex1x9_init (Driver *drvthis);
|
||||
MODULE_EXPORT void olimex1x9_close (Driver *drvthis);
|
||||
MODULE_EXPORT int olimex1x9_width (Driver *drvthis);
|
||||
MODULE_EXPORT int olimex1x9_height (Driver *drvthis);
|
||||
MODULE_EXPORT void olimex1x9_clear (Driver *drvthis);
|
||||
MODULE_EXPORT void olimex1x9_flush (Driver *drvthis);
|
||||
MODULE_EXPORT void olimex1x9_string (Driver *drvthis, int x, int y, const char string[]);
|
||||
MODULE_EXPORT void olimex1x9_chr (Driver *drvthis, int x, int y, char c);
|
||||
|
||||
#endif
|
||||
@@ -1,131 +0,0 @@
|
||||
#ifndef OLIMEX_LCD1x9_FONT_H
|
||||
#define OLIMEX_LCD1x9_FONT_H
|
||||
|
||||
uint16_t olimex1x9_font[256] = {
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000, /* ' ' */
|
||||
0x9800, /* '!' */
|
||||
0x0101, /* '"' */
|
||||
0x5054, /* '#' -- use this for a degree sign */
|
||||
0x0000, /* '$' */
|
||||
0x0000, /* '%' */
|
||||
0x0000, /* '&' */
|
||||
0x0100, /* ''' */
|
||||
0x0096, /* '(' */
|
||||
0x9090, /* ')' */
|
||||
0x6761, /* '*' */
|
||||
0x4640, /* '+' */
|
||||
0x0020, /* ',' */
|
||||
0x4040, /* '-' */
|
||||
0x0800, /* '.' */
|
||||
0x0120, /* '/' */
|
||||
0x9096, /* '0' */
|
||||
0x9000, /* '1' */
|
||||
0x50d2, /* '2' */
|
||||
0xd0d0, /* '3' */
|
||||
0xd044, /* '4' */
|
||||
0xc0d4, /* '5' */
|
||||
0xc0d6, /* '6' */
|
||||
0x9010, /* '7' */
|
||||
0xd0d6, /* '8' */
|
||||
0xd0d4, /* '9' */
|
||||
0x0800, /* ':' same as '.' */
|
||||
0x0000, /* ';' */
|
||||
0x2100, /* '<' */
|
||||
0x0000, /* '=' */
|
||||
0x0021, /* '>' */
|
||||
0x0000, /* '?' */
|
||||
0xffff, /* '@' */
|
||||
0xd056, /* 'A' */
|
||||
0x21d6, /* 'B' */
|
||||
0x0096, /* 'C' */
|
||||
0x0027, /* 'D' */
|
||||
0x00d6, /* 'E' */
|
||||
0x4056, /* 'F' */
|
||||
0xc0d6, /* 'G' */
|
||||
0xd046, /* 'H' */
|
||||
0x0688, /* 'I' */
|
||||
0x9080, /* 'J' */
|
||||
0x2146, /* 'K' */
|
||||
0x0086, /* 'L' */
|
||||
0x9107, /* 'M' */
|
||||
0xb007, /* 'N' */
|
||||
0x9096, /* 'O' */
|
||||
0x5056, /* 'P' */
|
||||
0xb096, /* 'Q' */
|
||||
0x7056, /* 'R' */
|
||||
0xc0d4, /* 'S' */
|
||||
0x0610, /* 'T' */
|
||||
0x9086, /* 'U' */
|
||||
0x0126, /* 'V' */
|
||||
0xb026, /* 'W' */
|
||||
0x2121, /* 'X' */
|
||||
0xd0c4, /* 'Y' */
|
||||
0x01b0, /* 'Z' */
|
||||
0x0096, /* '[' */
|
||||
0x2001, /* '\' */
|
||||
0x9090, /* ']' */
|
||||
0x0010, /* '^' */
|
||||
0x0080, /* '_' */
|
||||
0x0400, /* '`' */
|
||||
0x02c2, /* 'a' */
|
||||
0xc0c6, /* 'b' */
|
||||
0x00c2, /* 'c' */
|
||||
0xd0c2, /* 'd' */
|
||||
0x00e2, /* 'e' */
|
||||
0x0056, /* 'f' */
|
||||
0xe080, /* 'g' */
|
||||
0xc046, /* 'h' */
|
||||
0x8000, /* 'i' */
|
||||
0x9080, /* 'j' */
|
||||
0x6046, /* 'k' */
|
||||
0x0026, /* 'l' */
|
||||
0xc242, /* 'm' */
|
||||
0xc042, /* 'n' */
|
||||
0xc0c2, /* 'o' */
|
||||
0x5056, /* 'p' */
|
||||
0xd054, /* 'q' */
|
||||
0x0042, /* 'r' */
|
||||
0x6080, /* 's' */
|
||||
0x00c6, /* 't' */
|
||||
0x8082, /* 'u' */
|
||||
0x0022, /* 'v' */
|
||||
0xa022, /* 'w' */
|
||||
0x2121, /* 'x' */
|
||||
0xa080, /* 'y' */
|
||||
0x00e0, /* 'z' */
|
||||
0x0000
|
||||
};
|
||||
|
||||
#endif
|
||||
+6
-21
@@ -188,11 +188,6 @@ glk_init(Driver *drvthis)
|
||||
p->width = 40; p->height = 8;
|
||||
p->gpo_count = 1;
|
||||
break;
|
||||
case 0x20 :
|
||||
p->model = "GLK12232-25-SM-USB";
|
||||
p->width = 20; p->height = 4;
|
||||
p->gpo_count = 2;
|
||||
break;
|
||||
case 0x21 :
|
||||
p->model = "GLK128128-25";
|
||||
p->width = 20; p->height = 16;
|
||||
@@ -203,10 +198,6 @@ glk_init(Driver *drvthis)
|
||||
p->gpo_count = 2;
|
||||
break;
|
||||
case 0x23 :
|
||||
p->model = "GLT12232-SM-USB";
|
||||
p->width = 20; p->height = 4;
|
||||
p->gpo_count = 2;
|
||||
break;
|
||||
case 0x24 :
|
||||
p->model = "GLK12232-25-SM";
|
||||
p->width = 20; p->height = 4;
|
||||
@@ -762,23 +753,17 @@ glk_get_key(Driver *drvthis)
|
||||
|
||||
/* Remap keys according to what LCDproc expects */
|
||||
switch (c) {
|
||||
case 'V' : // default mapping
|
||||
case 'I' : key = "Enter"; // pyramid mapping
|
||||
case 'V' : key = "Enter";
|
||||
break;
|
||||
case 'P' : // default mapping
|
||||
case 'D' : key = "Left"; // pyramid mapping
|
||||
case 'P' : key = "Left";
|
||||
break;
|
||||
case 'Q' : // default mapping
|
||||
case 'E' : key = "Right"; // pyramid mapping
|
||||
case 'Q' : key = "Right";
|
||||
break;
|
||||
case 'L' : // default mapping
|
||||
case 'J' : key = "Escape"; // pyramid mapping
|
||||
case 'L' : key = "Escape";
|
||||
break;
|
||||
case 'U' : // default mapping
|
||||
case 'C' : key = "Up"; // pyramid mapping
|
||||
case 'U' : key = "Up";
|
||||
break;
|
||||
case 'K' : // default mapping
|
||||
case 'H' : key = "Down"; // pyramid mapping
|
||||
case 'K' : key = "Down";
|
||||
break;
|
||||
default : break;
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# include "hd44780-ext8bit.h"
|
||||
# include "hd44780-serialLpt.h"
|
||||
# include "hd44780-winamp.h"
|
||||
# include "hd44780-lcm162.h"
|
||||
#endif
|
||||
#include "hd44780-serial.h"
|
||||
#include "hd44780-lis2.h"
|
||||
@@ -61,7 +60,6 @@ static const ConnectionMapping connectionMapping[] = {
|
||||
{ "8bit", HD44780_CT_8BIT, IF_TYPE_PARPORT, hd_init_ext8bit },
|
||||
{ "serialLpt", HD44780_CT_SERIALLPT, IF_TYPE_PARPORT, hd_init_serialLpt },
|
||||
{ "winamp", HD44780_CT_WINAMP, IF_TYPE_PARPORT, hd_init_winamp },
|
||||
{ "lcm162", HD44780_CT_LCM162, IF_TYPE_PARPORT, hd_init_lcm162 },
|
||||
#endif
|
||||
/* serial connection types */
|
||||
{ "picanlcd", HD44780_CT_PICANLCD, IF_TYPE_SERIAL, hd_init_serial },
|
||||
|
||||
+102
-109
@@ -13,38 +13,17 @@
|
||||
* 1997 Matthias Prinke <m.prinke@trashcan.mcnet.de>
|
||||
*
|
||||
* The connections are:
|
||||
* PCF8574AP Bit LCD
|
||||
* P0 (4) 0x01 D4 (11)
|
||||
* P1 (5) 0x02 D5 (12)
|
||||
* P2 (6) 0x04 D6 (13)
|
||||
* P3 (7) 0x08 D7 (14)
|
||||
* P4 (9) 0x10 RS (4)
|
||||
* P5 (10) 0x20 RW (5)
|
||||
* P6 (11) 0x40 EN (6)
|
||||
* P7 (12) 0x80 /backlight (optional, active-low)
|
||||
* PCF8574AP LCD
|
||||
* P0 (4) D4 (11)
|
||||
* P1 (5) D5 (12)
|
||||
* P2 (6) D6 (13)
|
||||
* P3 (7) D7 (14)
|
||||
* P4 (9) RS (4)
|
||||
* P5 (10) RW (5)
|
||||
* P6 (11) EN (6)
|
||||
*
|
||||
* Configuration:
|
||||
\verbatim
|
||||
alternative wiring example:
|
||||
PCF8574AP: P0 P1 P2 P3 P4 P5 P6 P7
|
||||
| | | | | | | |
|
||||
HD44780: RS RW EN BL D4 D5 D6 D7
|
||||
|
||||
in LCDd.conf we then need to define
|
||||
i2c_line_RS=0x01
|
||||
i2c_line_RW=0x02
|
||||
i2c_line_EN=0x04
|
||||
i2c_line_BL=0x80
|
||||
i2c_line_D4=0x10
|
||||
i2c_line_D5=0x20
|
||||
i2c_line_D6=0x40
|
||||
i2c_line_D7=0x80
|
||||
Backlight=yes
|
||||
BacklightInvert=yes
|
||||
|
||||
The Backlight Invert is used if a 0 turns the backlight on, and 1 turns it off, i.e. npn transistor
|
||||
\endverbatim
|
||||
|
||||
* Backlight
|
||||
* P7 (12) /backlight (optional, active-low)
|
||||
*
|
||||
* Configuration:
|
||||
* device=/dev/i2c-0 # the device file of the i2c bus
|
||||
@@ -82,8 +61,19 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#ifdef HAVE_DEV_IICBUS_IIC_H
|
||||
#include <dev/iicbus/iic.h>
|
||||
#else /* HAVE_LINUX_I2C_DEV_H */
|
||||
#include <linux/i2c-dev.h>
|
||||
/* I2C_SLAVE is missing in linux/i2c-dev.h from kernel headers of 2.4.x kernels */
|
||||
#ifndef I2C_SLAVE
|
||||
#define I2C_SLAVE 0x0703 /* Change slave address */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "i2c.h"
|
||||
|
||||
// Generally, any function that accesses the LCD control lines needs to be
|
||||
// implemented separately for each HW design. This is typically (but not
|
||||
@@ -99,11 +89,6 @@ void i2c_HD44780_close(PrivateData *p);
|
||||
#define RW 0x20
|
||||
#define EN 0x40
|
||||
#define BL 0x80
|
||||
#define D4 0x01
|
||||
#define D5 0x02
|
||||
#define D6 0x04
|
||||
#define D7 0x08
|
||||
#define BL_INVERT 0
|
||||
// note that the above bits are all meant for the data port of PCF8574
|
||||
|
||||
#define I2C_ADDR_MASK 0x7f
|
||||
@@ -112,9 +97,13 @@ void i2c_HD44780_close(PrivateData *p);
|
||||
static void
|
||||
i2c_out(PrivateData *p, unsigned char val)
|
||||
{
|
||||
unsigned char data[2];
|
||||
char data[2];
|
||||
int datalen;
|
||||
static int no_more_errormsgs=0;
|
||||
#ifdef HAVE_DEV_IICBUS_IIC_H
|
||||
struct iiccmd cmd;
|
||||
bzero(&cmd, sizeof(cmd));
|
||||
#endif
|
||||
|
||||
if (p->port & I2C_PCAX_MASK) { // we have a PCA9554 or similar, that needs a 2-byte command
|
||||
data[0]=1; // command: read/write output port register
|
||||
@@ -125,13 +114,24 @@ i2c_out(PrivateData *p, unsigned char val)
|
||||
datalen=1;
|
||||
}
|
||||
|
||||
if (i2c_write(p->i2c, data, datalen) < 0) {
|
||||
p->hd44780_functions->drv_report(no_more_errormsgs?RPT_DEBUG:RPT_ERR, "HD44780: I2C: i2c write data %u failed: %s",
|
||||
val, strerror(errno));
|
||||
#ifdef HAVE_DEV_IICBUS_IIC_H
|
||||
cmd.slave = (p->port & I2C_ADDR_MASK) << 1;
|
||||
cmd.last = 1;
|
||||
cmd.count = datalen;
|
||||
cmd.buf = data;
|
||||
|
||||
if (ioctl(p->fd, I2CWRITE, &cmd) < 0) {
|
||||
#else /* HAVE_LINUX_I2C_DEV_H */
|
||||
if (write(p->fd,data,datalen) != datalen) {
|
||||
#endif
|
||||
p->hd44780_functions->drv_report(no_more_errormsgs?RPT_DEBUG:RPT_ERR, "HD44780: I2C: i2c write data %u to address 0x%02X failed: %s",
|
||||
val, p->port & I2C_ADDR_MASK, strerror(errno));
|
||||
no_more_errormsgs=1;
|
||||
}
|
||||
}
|
||||
|
||||
#define DEFAULT_DEVICE "/dev/i2c-0"
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the driver.
|
||||
@@ -144,60 +144,61 @@ hd_init_i2c(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData*) drvthis->private_data;
|
||||
HD44780_functions *hd44780_functions = p->hd44780_functions;
|
||||
char device[256] = I2C_DEFAULT_DEVICE;
|
||||
|
||||
p->i2c_backlight_invert = drvthis->config_get_bool(drvthis->name, "BacklightInvert", 0, BL_INVERT);
|
||||
p->i2c_line_RS = drvthis->config_get_int(drvthis->name, "i2c_line_RS", 0, RS);
|
||||
p->i2c_line_RW = drvthis->config_get_int(drvthis->name, "i2c_line_RW", 0, RW);
|
||||
p->i2c_line_EN = drvthis->config_get_int(drvthis->name, "i2c_line_EN", 0, EN);
|
||||
p->i2c_line_BL = drvthis->config_get_int(drvthis->name, "i2c_line_BL", 0, BL);
|
||||
p->i2c_line_D4 = drvthis->config_get_int(drvthis->name, "i2c_line_D4", 0, D4);
|
||||
p->i2c_line_D5 = drvthis->config_get_int(drvthis->name, "i2c_line_D5", 0, D5);
|
||||
p->i2c_line_D6 = drvthis->config_get_int(drvthis->name, "i2c_line_D6", 0, D6);
|
||||
p->i2c_line_D7 = drvthis->config_get_int(drvthis->name, "i2c_line_D7", 0, D7);
|
||||
|
||||
report(RPT_INFO, "HD44780: I2C: Init using D4 and D5, and or'd lines, invert", p->i2c_line_RS);
|
||||
report(RPT_INFO, "HD44780: I2C: Pin RS mapped to 0x%02X", p->i2c_line_RS);
|
||||
report(RPT_INFO, "HD44780: I2C: Pin RW mapped to 0x%02X", p->i2c_line_RW);
|
||||
report(RPT_INFO, "HD44780: I2C: Pin EN mapped to 0x%02X", p->i2c_line_EN);
|
||||
report(RPT_INFO, "HD44780: I2C: Pin BL mapped to 0x%02X", p->i2c_line_BL);
|
||||
report(RPT_INFO, "HD44780: I2C: Pin D4 mapped to 0x%02X", p->i2c_line_D4);
|
||||
report(RPT_INFO, "HD44780: I2C: Pin D5 mapped to 0x%02X", p->i2c_line_D5);
|
||||
report(RPT_INFO, "HD44780: I2C: Pin D6 mapped to 0x%02X", p->i2c_line_D6);
|
||||
report(RPT_INFO, "HD44780: I2C: Pin D7 mapped to 0x%02X", p->i2c_line_D7);
|
||||
report(RPT_INFO, "HD44780: I2C: Invert Backlight %d", p->i2c_backlight_invert);
|
||||
|
||||
int enableLines = EN;
|
||||
char device[256] = DEFAULT_DEVICE;
|
||||
#ifdef HAVE_DEV_IICBUS_IIC_H
|
||||
struct iiccmd cmd;
|
||||
bzero(&cmd, sizeof(cmd));
|
||||
#endif
|
||||
|
||||
p->backlight_bit = p->i2c_line_BL;
|
||||
p->backlight_bit = BL;
|
||||
|
||||
/* READ CONFIG FILE */
|
||||
|
||||
/* Get serial device to use */
|
||||
strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0, I2C_DEFAULT_DEVICE), sizeof(device));
|
||||
strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(device));
|
||||
device[sizeof(device)-1] = '\0';
|
||||
report(RPT_INFO,"HD44780: I2C: Using device '%s' and address 0x%02X for a %s",
|
||||
device, p->port & I2C_ADDR_MASK, (p->port & I2C_PCAX_MASK) ? "PCA9554(A)" : "PCF8574(A)");
|
||||
|
||||
p->i2c = i2c_open(device, p->port & I2C_ADDR_MASK);
|
||||
if (!p->i2c) {
|
||||
report(RPT_ERR, "HD44780: I2C: connecting to device '%s' slave 0x%02X failed:", device, p->port & I2C_ADDR_MASK, strerror(errno));
|
||||
// Open the I2C device
|
||||
p->fd = open(device, O_RDWR);
|
||||
if (p->fd < 0) {
|
||||
report(RPT_ERR, "HD44780: I2C: open i2c device '%s' failed: %s", device, strerror(errno));
|
||||
return(-1);
|
||||
}
|
||||
|
||||
// Set I2C address
|
||||
#ifdef HAVE_DEV_IICBUS_IIC_H
|
||||
cmd.slave = (p->port & I2C_ADDR_MASK) << 1;
|
||||
cmd.last = 0;
|
||||
cmd.count = 0;
|
||||
if (ioctl(p->fd, I2CRSTCARD, &cmd) < 0) {
|
||||
report(RPT_ERR, "HD44780: I2C: reset bus failed: %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (ioctl(p->fd, I2CSTART, &cmd) < 0) {
|
||||
report(RPT_ERR, "HD44780: I2C: set address to 0x%02X: %s", p->port & I2C_ADDR_MASK, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
#else /* HAVE_LINUX_I2C_DEV_H */
|
||||
if (ioctl(p->fd,I2C_SLAVE, p->port & I2C_ADDR_MASK) < 0) {
|
||||
report(RPT_ERR, "HD44780: I2C: set address to '%i': %s", p->port & I2C_ADDR_MASK, strerror(errno));
|
||||
return(-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (p->port & I2C_PCAX_MASK) { // we have a PCA9554 or similar, that needs special config
|
||||
unsigned char data[2];
|
||||
char data[2];
|
||||
data[0] = 2; // command: set polarity inversion
|
||||
data[1] = 0; // -> no polarity inversion
|
||||
if (i2c_write(p->i2c, data, 2) < 0) {
|
||||
if (write(p->fd,data,2) != 2) {
|
||||
report(RPT_ERR, "HD44780: I2C: i2c set polarity inversion failed: %s", strerror(errno));
|
||||
}
|
||||
data[0] = 3; // command: set output direction
|
||||
data[1] = 0; // -> all pins are outputs
|
||||
if (i2c_write(p->i2c, data, 2) <0) {
|
||||
if (write(p->fd,data,2) != 2) {
|
||||
report(RPT_ERR, "HD44780: I2C: i2c set output direction failed: %s", strerror(errno));
|
||||
}
|
||||
}
|
||||
@@ -208,49 +209,44 @@ hd_init_i2c(Driver *drvthis)
|
||||
|
||||
// powerup the lcd now
|
||||
/* We'll now send 0x03 a couple of times,
|
||||
* which is in fact (FUNCSET | IF_8BIT) >> 4
|
||||
*/
|
||||
i2c_out(p, p->i2c_line_D4 | p->i2c_line_D5);
|
||||
* which is in fact (FUNCSET | IF_8BIT) >> 4 */
|
||||
i2c_out(p, 0x03);
|
||||
if (p->delayBus)
|
||||
hd44780_functions->uPause(p, 1);
|
||||
|
||||
i2c_out(p, p->i2c_line_EN | p->i2c_line_D4 | p->i2c_line_D5);
|
||||
i2c_out(p, enableLines | 0x03);
|
||||
if (p->delayBus)
|
||||
hd44780_functions->uPause(p, 1);
|
||||
i2c_out(p, p->i2c_line_D4 | p->i2c_line_D5);
|
||||
i2c_out(p, 0x03);
|
||||
hd44780_functions->uPause(p, 15000);
|
||||
|
||||
i2c_out(p, p->i2c_line_EN | p->i2c_line_D4 | p->i2c_line_D5);
|
||||
i2c_out(p, enableLines | 0x03);
|
||||
if (p->delayBus)
|
||||
hd44780_functions->uPause(p, 1);
|
||||
i2c_out(p, p->i2c_line_D4 | p->i2c_line_D5);
|
||||
i2c_out(p, 0x03);
|
||||
hd44780_functions->uPause(p, 5000);
|
||||
|
||||
i2c_out(p, p->i2c_line_EN | p->i2c_line_D4 | p->i2c_line_D5);
|
||||
i2c_out(p, enableLines | 0x03);
|
||||
if (p->delayBus)
|
||||
hd44780_functions->uPause(p, 1);
|
||||
i2c_out(p, p->i2c_line_D4 | p->i2c_line_D5);
|
||||
i2c_out(p, 0x03);
|
||||
hd44780_functions->uPause(p, 100);
|
||||
|
||||
i2c_out(p, p->i2c_line_EN | p->i2c_line_D4 | p->i2c_line_D5);
|
||||
i2c_out(p, enableLines | 0x03);
|
||||
if (p->delayBus)
|
||||
hd44780_functions->uPause(p, 1);
|
||||
i2c_out(p, p->i2c_line_D4 | p->i2c_line_D5);
|
||||
i2c_out(p, 0x03);
|
||||
hd44780_functions->uPause(p, 100);
|
||||
|
||||
// now in 8-bit mode... set 4-bit mode
|
||||
/*
|
||||
OLD (FUNCSET | IF_4BIT) >> 4 0x02
|
||||
ALT (FUNCSET | IF_4BIT) 0x20
|
||||
*/
|
||||
i2c_out(p, p->i2c_line_D5);
|
||||
i2c_out(p, 0x02);
|
||||
if (p->delayBus)
|
||||
hd44780_functions->uPause(p, 1);
|
||||
|
||||
i2c_out(p, p->i2c_line_EN | p->i2c_line_D5);
|
||||
i2c_out(p, enableLines | 0x02);
|
||||
if (p->delayBus)
|
||||
hd44780_functions->uPause(p, 1);
|
||||
i2c_out(p, p->i2c_line_D5);
|
||||
i2c_out(p, 0x02);
|
||||
hd44780_functions->uPause(p, 100);
|
||||
|
||||
// Set up two-line, small character (5x8) mode
|
||||
@@ -264,8 +260,12 @@ hd_init_i2c(Driver *drvthis)
|
||||
|
||||
void
|
||||
i2c_HD44780_close(PrivateData *p) {
|
||||
if (p->i2c >= 0)
|
||||
i2c_close(p->i2c);
|
||||
if (p->fd >= 0) {
|
||||
#ifdef HAVE_DEV_IICBUS_IIC_H
|
||||
ioctl(p->fd, I2CSTOP);
|
||||
#endif
|
||||
close(p->fd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -279,28 +279,23 @@ i2c_HD44780_close(PrivateData *p) {
|
||||
void
|
||||
i2c_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
{
|
||||
unsigned char portControl = 0;
|
||||
unsigned char h=0;
|
||||
unsigned char l=0;
|
||||
if( ch & 0x80 ) h |= p->i2c_line_D7;
|
||||
if( ch & 0x40 ) h |= p->i2c_line_D6;
|
||||
if( ch & 0x20 ) h |= p->i2c_line_D5;
|
||||
if( ch & 0x10 ) h |= p->i2c_line_D4;
|
||||
if( ch & 0x08 ) l |= p->i2c_line_D7;
|
||||
if( ch & 0x04 ) l |= p->i2c_line_D6;
|
||||
if( ch & 0x02 ) l |= p->i2c_line_D5;
|
||||
if( ch & 0x01 ) l |= p->i2c_line_D4;
|
||||
unsigned char enableLines = 0, portControl = 0;
|
||||
unsigned char h = (ch >> 4) & 0x0f; // high and low nibbles
|
||||
unsigned char l = ch & 0x0f;
|
||||
|
||||
if (flags == RS_INSTR)
|
||||
portControl = 0;
|
||||
else //if (flags == RS_DATA)
|
||||
portControl = p->i2c_line_RS;
|
||||
portControl = RS;
|
||||
|
||||
portControl |= p->backlight_bit;
|
||||
|
||||
enableLines = EN;
|
||||
|
||||
i2c_out(p, portControl | h);
|
||||
if (p->delayBus)
|
||||
p->hd44780_functions->uPause(p, 1);
|
||||
i2c_out(p, p->i2c_line_EN | portControl | h);
|
||||
i2c_out(p, enableLines | portControl | h);
|
||||
if (p->delayBus)
|
||||
p->hd44780_functions->uPause(p, 1);
|
||||
i2c_out(p, portControl | h);
|
||||
@@ -308,7 +303,7 @@ i2c_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flag
|
||||
i2c_out(p, portControl | l);
|
||||
if (p->delayBus)
|
||||
p->hd44780_functions->uPause(p, 1);
|
||||
i2c_out(p, p->i2c_line_EN | portControl | l);
|
||||
i2c_out(p, enableLines | portControl | l);
|
||||
if (p->delayBus)
|
||||
p->hd44780_functions->uPause(p, 1);
|
||||
i2c_out(p, portControl | l);
|
||||
@@ -322,9 +317,7 @@ i2c_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flag
|
||||
*/
|
||||
void i2c_HD44780_backlight(PrivateData *p, unsigned char state)
|
||||
{
|
||||
if ( p->i2c_backlight_invert == 0 )
|
||||
p->backlight_bit = ((!p->have_backlight||state) ? 0 : p->i2c_line_BL);
|
||||
else // Inverted backlight - npn transistor
|
||||
p->backlight_bit = ((p->have_backlight && state) ? p->i2c_line_BL : 0);
|
||||
p->backlight_bit = ((!p->have_backlight||state) ? 0 : BL);
|
||||
|
||||
i2c_out(p, p->backlight_bit);
|
||||
}
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* 8-bit driver module for Hitachi HD44780 based LCD displays.
|
||||
* The LCD is operated in it's 8 bit-mode to be connected to a single
|
||||
* PC parallel port.
|
||||
*
|
||||
* Copyright (c) 1999, 1995 Benjamin Tse <blt@Comports.com>
|
||||
* 2001 Joris Robijn <joris@robijn.net>
|
||||
* 2009 Holger Rasch <rasch@bytemine.net>
|
||||
*
|
||||
* Created modular driver Dec 1999, Benjamin Tse <blt@Comports.com>
|
||||
*
|
||||
* Based on the code in the lcdtime package which uses the LCD
|
||||
* controller in its 8-bit mode.
|
||||
*
|
||||
* This file is released under the GNU General Public License. Refer to the
|
||||
* COPYING file distributed with this package.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copied from "hd44780-ext8.c" and modified for lcm-162 module
|
||||
* found in nexcom nsaXXXX models.
|
||||
*/
|
||||
|
||||
#include "hd44780-lcm162.h"
|
||||
#include "hd44780-low.h"
|
||||
#include "lpt-port.h"
|
||||
#include "port.h"
|
||||
#include "report.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
// Generally, any function that accesses the LCD control lines needs to be
|
||||
// implemented separately for each HW design. This is typically (but not
|
||||
// restricted to):
|
||||
// HD44780_senddata
|
||||
// HD44780_readkeypad
|
||||
|
||||
void lcm162_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lcm162_HD44780_backlight(PrivateData *p, unsigned char state);
|
||||
unsigned char lcm162_HD44780_readkeypad(PrivateData *p, unsigned int YData);
|
||||
void lcm162_HD44780_output(PrivateData *p, int data);
|
||||
|
||||
/* lcm-162 specific mapping parport <-> hd44780 signals */
|
||||
#define RS SEL
|
||||
#define RW INIT
|
||||
#define EN1 LF
|
||||
|
||||
|
||||
// initialise the driver
|
||||
int
|
||||
hd_init_lcm162(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData*) drvthis->private_data;
|
||||
HD44780_functions *hd44780_functions = p->hd44780_functions;
|
||||
|
||||
// Reserve the port registers
|
||||
if (port_access_multiple(p->port,3)) {
|
||||
report(RPT_ERR, "%s: cannot get IO-permission for 0x%03X: %s",
|
||||
drvthis->name, p->port, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
hd44780_functions->senddata = lcm162_HD44780_senddata;
|
||||
hd44780_functions->backlight = lcm162_HD44780_backlight;
|
||||
hd44780_functions->readkeypad = lcm162_HD44780_readkeypad;
|
||||
|
||||
// setup the lcd in 8 bit mode
|
||||
hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||
hd44780_functions->uPause(p, 4100);
|
||||
hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||
hd44780_functions->uPause(p, 100);
|
||||
hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | IF_8BIT | TWOLINE | SMALLCHAR);
|
||||
hd44780_functions->uPause(p, 40);
|
||||
|
||||
common_init (p, IF_8BIT);
|
||||
|
||||
if (p->have_keypad)
|
||||
p->stuckinputs = 0; /* unused here */
|
||||
|
||||
// Writes new value to the "bargraph" latches
|
||||
hd44780_functions->output = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// lcm162_HD44780_senddata
|
||||
void
|
||||
lcm162_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
{
|
||||
unsigned char enableLines = 0, portControl;
|
||||
|
||||
// Only one controller is supported
|
||||
enableLines = EN1;
|
||||
|
||||
if (flags == RS_INSTR)
|
||||
portControl = 0;
|
||||
else //if (iflags == RS_DATA)
|
||||
portControl = RS;
|
||||
|
||||
portControl |= p->backlight_bit;
|
||||
|
||||
port_out(p->port + 2, portControl ^ OUTMASK);
|
||||
port_out(p->port, ch);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port + 2, (enableLines|portControl) ^ OUTMASK);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port + 2, portControl ^ OUTMASK);
|
||||
}
|
||||
|
||||
void lcm162_HD44780_backlight(PrivateData *p, unsigned char state)
|
||||
{
|
||||
/* ignore config, there is no backlight control on the lcm-162 */
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char lcm162_HD44780_readkeypad(PrivateData *p, unsigned int YData)
|
||||
{
|
||||
unsigned char readval;
|
||||
|
||||
if (YData) return 0; /* no keymatrix */
|
||||
|
||||
readval = port_in(p->port + 1);
|
||||
if (readval & ACK) { /* a key is pressed */
|
||||
/* 4 keys encoded in signals PAPEREND and FAULT */
|
||||
/* map them to low nibble (multiple keys not supported) */
|
||||
return 1 << (
|
||||
((readval & FAULT) / FAULT << 1) |
|
||||
((readval & PAPEREND) / PAPEREND)
|
||||
);
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
#ifndef HD_LCM162_H
|
||||
#define HD_LCM162_H
|
||||
|
||||
#include "lcd.h" /* for Driver */
|
||||
|
||||
// initialise this particular driver
|
||||
int hd_init_lcm162(Driver *drvthis);
|
||||
|
||||
#endif
|
||||
@@ -29,8 +29,6 @@
|
||||
# include <ftdi.h>
|
||||
#endif
|
||||
|
||||
#include "i2c.h"
|
||||
|
||||
/** \name Symbolic names for connection types
|
||||
*@{*/
|
||||
#define HD44780_CT_UNKNOWN 0
|
||||
@@ -59,7 +57,6 @@
|
||||
#define HD44780_CT_PIPLATE 23
|
||||
#define HD44780_CT_SPI 24
|
||||
#define HD44780_CT_PIFACECAD 25
|
||||
#define HD44780_CT_LCM162 26
|
||||
/**@}*/
|
||||
|
||||
/** \name Symbolic names for interface types
|
||||
@@ -158,22 +155,6 @@ typedef struct hd44780_private_data {
|
||||
int ftdi_line_backlight;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_I2C
|
||||
/* i2c based connection types */
|
||||
|
||||
int i2c_backlight_invert;
|
||||
int i2c_line_RS;
|
||||
int i2c_line_RW;
|
||||
int i2c_line_EN;
|
||||
int i2c_line_BL;
|
||||
int i2c_line_D4;
|
||||
int i2c_line_D5;
|
||||
int i2c_line_D6;
|
||||
int i2c_line_D7;
|
||||
|
||||
I2CHandle *i2c;
|
||||
#endif
|
||||
|
||||
#ifdef WITH_ETHLCD
|
||||
int sock; /**< socket for TCP devices */
|
||||
#endif
|
||||
|
||||
@@ -71,8 +71,6 @@ void lcdrpi_HD44780_close(PrivateData *p);
|
||||
*/
|
||||
static volatile unsigned int *gpio_map = NULL;
|
||||
|
||||
static unsigned int gpio_base_address = 0;
|
||||
|
||||
/*
|
||||
* Two different board revisions are currently in widespread use. The
|
||||
* GPIO mappings differ slightly - Not enough to kill a system yet.
|
||||
@@ -121,7 +119,7 @@ setup_io(Driver *drvthis)
|
||||
PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED,
|
||||
mem_fd,
|
||||
gpio_base_address);
|
||||
GPIO_BASE);
|
||||
|
||||
if (gpio_map == MAP_FAILED) {
|
||||
report(RPT_ERR, "setup_io: mmap failed: %s", strerror(errno));
|
||||
@@ -163,8 +161,9 @@ check_board_rev(Driver *drvthis)
|
||||
|
||||
/* On boards that have been overvolted, the MSB will be set */
|
||||
rev &= 0x00ff;
|
||||
if ((strcmp(hw, "BCM2708") != 0 && strcmp(hw, "BCM2709") != 0) || rev == 0) {
|
||||
report(RPT_ERR, "check_board_rev: This board is not recognized as a Raspberry Pi! Found:%s",hw);
|
||||
|
||||
if (strcmp(hw, "BCM2708") != 0 || rev == 0) {
|
||||
report(RPT_ERR, "check_board_rev: This board is not recognized as a Raspberry Pi!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -172,22 +171,17 @@ check_board_rev(Driver *drvthis)
|
||||
* in the wild). */
|
||||
if (rev < 4) {
|
||||
report(RPT_INFO, "check_board_rev: Revision 1 board detected");
|
||||
gpio_base_address = BCM2835_PERI_BASE_PI12 + GPIO_BASE_OFFSET;
|
||||
return gpio_pins_R1;
|
||||
}
|
||||
/* Currently, Rev 2 boards are 0x004, 0x005, or 0x006. This will need
|
||||
* updating as new revisions are released, but it is unlikely that P1
|
||||
* will change. */
|
||||
if (rev > 3 && rev <= 21) {
|
||||
if (rev > 3) {
|
||||
report(RPT_INFO, "check_board_rev: Revision 2 board detected");
|
||||
gpio_base_address = BCM2835_PERI_BASE_PI12 + GPIO_BASE_OFFSET;
|
||||
return gpio_pins_R2;
|
||||
}
|
||||
|
||||
report(RPT_INFO, "check_board_rev: Raspberry Pi 3 board detected");
|
||||
gpio_base_address = BCM2835_PERI_BASE_PI3 + GPIO_BASE_OFFSET;
|
||||
return gpio_pins_R2;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -291,7 +285,7 @@ lcdrpi_HD44780_close(PrivateData *p)
|
||||
|
||||
/* Unmap and free memory */
|
||||
if (gpio_map != NULL)
|
||||
munmap((void *) gpio_map, GPIO_BLOCK_SIZE);
|
||||
munmap((caddr_t) gpio_map, GPIO_BLOCK_SIZE);
|
||||
if (p->rpi_gpio != NULL)
|
||||
free(p->rpi_gpio);
|
||||
p->rpi_gpio = NULL;
|
||||
|
||||
@@ -20,10 +20,9 @@ struct rpi_gpio_map {
|
||||
};
|
||||
|
||||
/** Peripheral base address of the BCM2835 */
|
||||
#define BCM2835_PERI_BASE_PI12 0x20000000
|
||||
#define BCM2835_PERI_BASE_PI3 0x3F000000
|
||||
/** GPIO register start address offset from PERI_BASE */
|
||||
#define GPIO_BASE_OFFSET 0x200000
|
||||
#define BCM2835_PERI_BASE 0x20000000
|
||||
/** GPIO register start address */
|
||||
#define GPIO_BASE BCM2835_PERI_BASE + 0x200000
|
||||
/** Length of register space */
|
||||
#define GPIO_BLOCK_SIZE 180
|
||||
/** The Pi has 32 GPIO pins */
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
/** \file server/drivers/i2c.c
|
||||
* OS agnostic functions to access i2c devices.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#ifdef HAVE_DEV_IICBUS_IIC_H
|
||||
#include <dev/iicbus/iic.h>
|
||||
#else /* HAVE_LINUX_I2C_DEV_H */
|
||||
#include <linux/i2c-dev.h>
|
||||
/* I2C_SLAVE is missing in linux/i2c-dev.h from kernel headers of 2.4.x kernels
|
||||
*/
|
||||
#ifndef I2C_SLAVE
|
||||
#define I2C_SLAVE 0x0703 /* ioctl to change slave address */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define I2C_DEFAULT_DEVICE "/dev/i2c-0"
|
||||
|
||||
/** data to access an i2c slave */
|
||||
typedef struct {
|
||||
int fd; /**< file descriptor of the i2c device */
|
||||
#ifdef HAVE_DEV_IICBUS_IIC_H
|
||||
unsigned int slave; /**< slave address */
|
||||
#endif
|
||||
} I2CHandle;
|
||||
|
||||
|
||||
/**
|
||||
* setup connection to i2c slave
|
||||
* \param device device file of the i2c bus
|
||||
* \param addr use this slave address
|
||||
* \retval NULL Error
|
||||
* \retval Pointer to handle of the connection
|
||||
*/
|
||||
I2CHandle *i2c_open(const char *device, unsigned int addr)
|
||||
{
|
||||
I2CHandle *h;
|
||||
#ifdef HAVE_DEV_IICBUS_IIC_H
|
||||
struct iiccmd cmd;
|
||||
bzero(&cmd, sizeof(cmd));
|
||||
#endif
|
||||
|
||||
|
||||
h = malloc(sizeof(*h));
|
||||
if(!h)
|
||||
return NULL;
|
||||
|
||||
h->fd = open(device, O_RDWR);
|
||||
if(h->fd < 0)
|
||||
goto free;
|
||||
|
||||
#ifdef HAVE_DEV_IICBUS_IIC_H
|
||||
cmd.slave = h->slave = addr << 1;
|
||||
cmd.last = 0;
|
||||
cmd.count = 0;
|
||||
if (ioctl(h->fd, I2CRSTCARD, &cmd) < 0)
|
||||
goto close;
|
||||
if (ioctl(h->fd, I2CSTART, &cmd) < 0)
|
||||
goto close;
|
||||
#else /* HAVE_LINUX_I2C_DEV_H */
|
||||
if (ioctl(h->fd, I2C_SLAVE, addr) < 0) {
|
||||
goto close;
|
||||
}
|
||||
#endif
|
||||
|
||||
return h;
|
||||
|
||||
close:
|
||||
close(h->fd);
|
||||
free:
|
||||
free(h);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* close connection to i2c slave
|
||||
*/
|
||||
void i2c_close(I2CHandle *h)
|
||||
{
|
||||
#ifdef HAVE_DEV_IICBUS_IIC_H
|
||||
ioctl(h->fd, I2CSTOP);
|
||||
#endif
|
||||
close(h->fd);
|
||||
free(h);
|
||||
}
|
||||
|
||||
/**
|
||||
* write data to an i2c slave
|
||||
* \param h Handle of i2c slave
|
||||
* \param buf Buffer to send to the device
|
||||
* \param count Number of bytes to write
|
||||
* \retval >=0 Success.
|
||||
* \retval <0 Error.
|
||||
*/
|
||||
int i2c_write(I2CHandle *h, void *buf, unsigned int count)
|
||||
{
|
||||
#ifdef HAVE_DEV_IICBUS_IIC_H
|
||||
struct iiccmd cmd;
|
||||
bzero(&cmd, sizeof(cmd));
|
||||
cmd.slave = h->slave;
|
||||
cmd.last = 1;
|
||||
cmd.count = count;
|
||||
cmd.buf = buf;
|
||||
|
||||
return ioctl(h->fd, I2CWRITE, &cmd);
|
||||
#else /* HAVE_LINUX_I2C_DEV_H */
|
||||
if (write(h->fd, buf, count) != count)
|
||||
return -1;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef I2C_H
|
||||
#define I2C_H
|
||||
|
||||
struct i2c_data;
|
||||
|
||||
typedef struct i2c_data I2CHandle;
|
||||
|
||||
#define I2C_DEFAULT_DEVICE "/dev/i2c-0"
|
||||
|
||||
extern I2CHandle *i2c_open(const char *device, unsigned int addr);
|
||||
extern void i2c_close(I2CHandle *h);
|
||||
extern int i2c_write(I2CHandle *h, void *buf, unsigned int count);
|
||||
|
||||
#endif /* I2C_H */
|
||||
@@ -34,9 +34,9 @@ lib_hbar_static (Driver *drvthis, int x, int y, int len, int promille, int optio
|
||||
|
||||
if ( pixels >= cellwidth ) {
|
||||
/* write a "full" block to the screen... */
|
||||
// #if defined(SEAMLESS_HBARS)
|
||||
// drvthis->chr (drvthis, x+pos, y, cellwidth + cc_offset);
|
||||
// #else
|
||||
#if defined(SEAMLESS_HBARS)
|
||||
drvthis->chr (drvthis, x+pos, y, cellwidth + cc_offset);
|
||||
#else
|
||||
drvthis->icon (drvthis, x+pos, y, ICON_BLOCK_FILLED);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,230 +0,0 @@
|
||||
/** \file server/drivers/linux_input.c
|
||||
* LCDd \c linux event device driver for inputting data from the input
|
||||
* subsystem of the linux kernel..
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/input.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "lcd.h"
|
||||
#include "linux_input.h"
|
||||
#include "report.h"
|
||||
#include "shared/LL.h"
|
||||
|
||||
#define LINUXINPUT_DEFAULT_DEVICE "/dev/input/event0"
|
||||
|
||||
/** describe the button of a keycode */
|
||||
struct keycode {
|
||||
unsigned short code;
|
||||
char *button;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse key definition from config file
|
||||
* \param configvalue value part of the config file entry
|
||||
* \retval NULL Error.
|
||||
* \retval else Pointer to newly allocated struct keycode.
|
||||
*/
|
||||
static struct keycode *
|
||||
keycode_create(const char *configvalue)
|
||||
{
|
||||
int code;
|
||||
char *button;
|
||||
struct keycode *ret;
|
||||
|
||||
code = atoi(configvalue);
|
||||
if (code < 0 || code > UINT16_MAX)
|
||||
return NULL;
|
||||
|
||||
button = strchr(configvalue,',');
|
||||
if (!button)
|
||||
return NULL;
|
||||
button = strdup(&button[1]);
|
||||
if (!button)
|
||||
return NULL;
|
||||
|
||||
ret = malloc(sizeof(*ret));
|
||||
if (ret) {
|
||||
ret->code = code;
|
||||
ret->button = button;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** private data for the linux event device driver */
|
||||
typedef struct linuxInput_private_data {
|
||||
int fd;
|
||||
LinkedList *buttonmap;
|
||||
} PrivateData;
|
||||
|
||||
|
||||
// Vars for the server core
|
||||
MODULE_EXPORT char *api_version = API_VERSION;
|
||||
MODULE_EXPORT int stay_in_foreground = 0;
|
||||
MODULE_EXPORT int supports_multiple = 1;
|
||||
MODULE_EXPORT char *symbol_prefix = "linuxInput_";
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the driver.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \retval 0 Success.
|
||||
* \retval <0 Error.
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
linuxInput_init (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p;
|
||||
const char *s;
|
||||
struct keycode *key;
|
||||
int i;
|
||||
|
||||
/* Allocate and store private data */
|
||||
p = (PrivateData *) calloc(1, sizeof(PrivateData));
|
||||
if (p == NULL)
|
||||
return -1;
|
||||
if (drvthis->store_private_ptr(drvthis, p))
|
||||
return -1;
|
||||
|
||||
/* initialize private data */
|
||||
p->fd = -1;
|
||||
if ((p->buttonmap = LL_new()) == NULL) {
|
||||
report(RPT_ERR, "%s: cannot allocate memory for buttons", drvthis->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Read config file */
|
||||
|
||||
/* What device should be used */
|
||||
s = drvthis->config_get_string(drvthis->name, "Device", 0,
|
||||
LINUXINPUT_DEFAULT_DEVICE);
|
||||
report(RPT_INFO, "%s: using Device %s", drvthis->name, s);
|
||||
|
||||
|
||||
if ((p->fd = open(s, O_RDONLY | O_NONBLOCK)) < 0) {
|
||||
report(RPT_ERR, "%s: open(%s) failed (%s)",
|
||||
drvthis->name, s, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; (s = drvthis->config_get_string(drvthis->name, "key", i, NULL)) != NULL; i++) {
|
||||
if ((key = keycode_create(s)) == NULL) {
|
||||
report(RPT_ERR, "%s: parsing configvalue '%s' failed",
|
||||
drvthis->name, s);
|
||||
continue;
|
||||
}
|
||||
LL_AddNode(p->buttonmap, key);
|
||||
}
|
||||
|
||||
report(RPT_DEBUG, "%s: init() done", drvthis->name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close the driver (do necessary clean-up).
|
||||
* \param drvthis Pointer to driver structure.
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
linuxInput_close (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
struct keycode *k;
|
||||
|
||||
if (p != NULL) {
|
||||
if (p->fd >= 0)
|
||||
close(p->fd);
|
||||
|
||||
if (p->buttonmap != NULL) {
|
||||
while ((k = LL_Pop(p->buttonmap)) != NULL) {
|
||||
free(k->button);
|
||||
free(k);
|
||||
}
|
||||
LL_Destroy(p->buttonmap);
|
||||
}
|
||||
|
||||
free(p);
|
||||
}
|
||||
drvthis->store_private_ptr(drvthis, NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function to check LL items against a given key code.
|
||||
* \param data Pointer to data of list item
|
||||
* \param codep Pointer to value holding the received key code
|
||||
* \retval 0 We found the right item.
|
||||
* \retval else We need to continue searching.
|
||||
*/
|
||||
static int
|
||||
compare_with_keycode (void *data, void *codep)
|
||||
{
|
||||
uint16_t code = *(uint16_t *)codep;
|
||||
struct keycode *k = data;
|
||||
|
||||
return k->code != code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the next input event.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \retval String representation of the key;
|
||||
* \c NULL for nothing available / error.
|
||||
*/
|
||||
MODULE_EXPORT const char *
|
||||
linuxInput_get_key (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
struct input_event event;
|
||||
struct keycode *k;
|
||||
|
||||
if (read(p->fd, &event, sizeof(event)) != sizeof(event))
|
||||
return NULL;
|
||||
|
||||
/* Ignore release events and not-key events */
|
||||
if (event.type != EV_KEY || event.value == 0)
|
||||
return NULL;
|
||||
|
||||
switch (event.code) {
|
||||
case KEY_ESC:
|
||||
return "Escape";
|
||||
|
||||
case KEY_UP:
|
||||
return "Up";
|
||||
|
||||
case KEY_LEFT:
|
||||
return "Left";
|
||||
|
||||
case KEY_RIGHT:
|
||||
return "Right";
|
||||
|
||||
case KEY_DOWN:
|
||||
return "Down";
|
||||
|
||||
case KEY_ENTER:
|
||||
case KEY_KPENTER:
|
||||
return "Enter";
|
||||
|
||||
default:
|
||||
LL_Rewind(p->buttonmap);
|
||||
k = LL_Find(p->buttonmap, compare_with_keycode, &event.code);
|
||||
if (k)
|
||||
return k->button;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef LINUX_INPUT_H
|
||||
#define LINUX_INPUT_H
|
||||
|
||||
#include "lcd.h"
|
||||
|
||||
MODULE_EXPORT int linuxInput_init (Driver *drvthis);
|
||||
MODULE_EXPORT void linuxInput_close (Driver *drvthis);
|
||||
|
||||
MODULE_EXPORT const char *linuxInput_get_key (Driver *drvthis);
|
||||
|
||||
#endif
|
||||
@@ -49,7 +49,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/file.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
|
||||
@@ -60,13 +60,13 @@ typedef struct rawserial_private_data {
|
||||
/** \name Event loop timing. refresh_time and refresh_delta form the
|
||||
* event loop timing mechanism for configurable update rates.
|
||||
*@{*/
|
||||
unsigned int refresh_time; /**< time at the last screen update */
|
||||
unsigned int refresh_delta; /**< time step to next screen update */
|
||||
uint refresh_time; /**< time at the last screen update */
|
||||
uint refresh_delta; /**< time step to next screen update */
|
||||
/**@}*/
|
||||
} PrivateData;
|
||||
|
||||
/* Local prototypes */
|
||||
static unsigned int get_millisecond_time(void);
|
||||
static uint get_millisecond_time(void);
|
||||
|
||||
|
||||
/* Vars for the server core */
|
||||
@@ -303,7 +303,7 @@ rawserial_flush(Driver *drvthis)
|
||||
PrivateData *p = drvthis->private_data;
|
||||
char out[LCD_MAX_WIDTH * LCD_MAX_HEIGHT];
|
||||
|
||||
unsigned int currentTime = get_millisecond_time();
|
||||
uint currentTime = get_millisecond_time();
|
||||
int t_delta = currentTime - p->refresh_time;
|
||||
|
||||
/*
|
||||
@@ -415,7 +415,7 @@ rawserial_get_info(Driver *drvthis)
|
||||
*
|
||||
* \return int with current millisecond time.
|
||||
*/
|
||||
static unsigned
|
||||
static uint
|
||||
get_millisecond_time(void)
|
||||
{
|
||||
struct timeval ts;
|
||||
|
||||
@@ -1,658 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by M. Feser *
|
||||
* Copyright (C) 2013 by R. Geigenberger (Update for YARD2) *
|
||||
* yard2lcdproc (.A.T.) yard2usb.de *
|
||||
* *
|
||||
* *
|
||||
* 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 of the License, 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., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "lcd.h"
|
||||
//#define DEBUG
|
||||
#include "report.h"
|
||||
#include "yard2LCD.h"
|
||||
#include "lcd_lib.h"
|
||||
|
||||
/*
|
||||
//Type of characters currently stored in CGRAM. from lcd.h as info
|
||||
typedef enum {
|
||||
standard, // one char is used for heartbeat
|
||||
vbar, // vertical bars
|
||||
hbar, // horizontal bars
|
||||
icons, // standard icons
|
||||
custom, // custom settings
|
||||
bignum, // big numbers
|
||||
} CGmode;
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
Dmode_standard,
|
||||
Dmode_graphical
|
||||
} Dmode;
|
||||
|
||||
|
||||
/* Driver private data */
|
||||
typedef struct driver_private_data {
|
||||
int fd;
|
||||
int width, height;
|
||||
int gwidth, gheight;
|
||||
int hspace, vspace;
|
||||
int cellwidth, cellheight;
|
||||
int bigcellwidth, bigcellheight;
|
||||
char *framebuf;
|
||||
int on_brightness;
|
||||
int off_brightness;
|
||||
char hw_brightness;
|
||||
CGmode ccmode;
|
||||
Dmode dispmode;
|
||||
char info[255];
|
||||
char LCDtype;
|
||||
} PrivateData;
|
||||
|
||||
/* Prototypes of internal functions */
|
||||
static int yard_hwWrite(Driver *drvthis, unsigned char *yardData, unsigned char Datalen);
|
||||
static int yard_hwClearLCD(Driver *drvthis);
|
||||
static int yard_hwEnterGmode(Driver *drvthis);
|
||||
static int yard_hwGotoXY(Driver *drvthis, unsigned char x, unsigned char y);
|
||||
static int yard_hwPrintChar(Driver *drvthis, char c);
|
||||
static int yard_hwPrintCharArray(Driver *drvthis, char *str, unsigned char len);
|
||||
static int yard_hwSetBrightness(Driver *drvthis, unsigned char brightVal);
|
||||
static int yard_hwWriteCGRam(Driver *drvthis, unsigned char numChar, unsigned char *data);
|
||||
|
||||
|
||||
/* Vars for the server core */
|
||||
MODULE_EXPORT char *api_version = API_VERSION;
|
||||
MODULE_EXPORT int stay_in_foreground = 0;
|
||||
MODULE_EXPORT int supports_multiple = 0;
|
||||
MODULE_EXPORT char *symbol_prefix = "yard_";
|
||||
|
||||
unsigned char yardCmd[64];
|
||||
|
||||
/*
|
||||
* Hardware function: Write YARD command to KeyLcd via socket
|
||||
*/
|
||||
static int
|
||||
yard_hwWrite(Driver *drvthis, unsigned char *yardData, unsigned char Datalen)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 01 - Enter yard_hwWrite: %d - %s",drvthis->name,Datalen,yardData);
|
||||
PrivateData *p = drvthis->private_data;
|
||||
unsigned char byteCnt;
|
||||
|
||||
// Send data to YARD server
|
||||
if ( (Datalen > 0) && (Datalen <= MAX_YARDDATA_SIZE))
|
||||
{
|
||||
byteCnt = write(p->fd, yardData, Datalen); //(char *)&yardCMD
|
||||
//byteCnt = write(p->fd, "WTEST",5);
|
||||
if (byteCnt < 0)
|
||||
{
|
||||
report(RPT_WARNING, "%s: Can't send data to YARD2 LCDserver !", drvthis->name);
|
||||
debug(RPT_DEBUG, "%s: Event 01.1 - Can't send data to YARD2 LCDserver !", drvthis->name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 01.1 - %s: Too much Data for YARD Server: %d !", drvthis->name,Datalen);
|
||||
report(RPT_WARNING, "%s: Too much Data for YARD Server: %d !", drvthis->name,Datalen);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// Just wait for YARD server response; No matter of Data received, but > 2 bytes, normally ROK is send
|
||||
byteCnt = read(p->fd, (char *)&yardData, sizeof(yardData) );
|
||||
if (byteCnt < 0)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Cannot receive ROK from YARD2 server !", drvthis->name);
|
||||
report(RPT_ERR, "%s: Cannot receive ROK from YARD2 server !", drvthis->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Hardware function: Clears screen
|
||||
*/
|
||||
static int
|
||||
yard_hwClearLCD(Driver *drvthis)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 02 - Enter yard_hwClearLCD",drvthis->name);
|
||||
unsigned char cmd;
|
||||
|
||||
cmd = 'C'; // = Clear cmd for YARD
|
||||
return yard_hwWrite(drvthis, &cmd, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Hardware function: Shifts cursor to position (x,y), left upper corner equals (1,1)
|
||||
*/
|
||||
static int
|
||||
yard_hwGotoXY(Driver *drvthis, unsigned char x, unsigned char y)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 03 - Enter yard_hwGotoXY: X.%d - Y.%d",drvthis->name,x,y);
|
||||
PrivateData *p = (PrivateData *)drvthis->private_data;
|
||||
unsigned char cmdBuf[5];
|
||||
|
||||
// Error check
|
||||
switch (p->dispmode)
|
||||
{
|
||||
case Dmode_standard:
|
||||
{
|
||||
if ( (x > p->width) || (x < 1) || (y > p->height) || (y < 1) )
|
||||
return -1;
|
||||
|
||||
// Setup and send YARD command
|
||||
cmdBuf[0] = 'G';
|
||||
cmdBuf[1] = x - 1; // Zero index start ! lcdproc starts with 1,1, YARD 0,0
|
||||
cmdBuf[2] = y - 1;
|
||||
return yard_hwWrite(drvthis, cmdBuf, 3);
|
||||
|
||||
}
|
||||
default: {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Hardware function: Prints a single character
|
||||
*/
|
||||
static int
|
||||
yard_hwPrintChar(Driver *drvthis, char c)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 04 - Enter yard_hwPrintChar: %s",drvthis->name,c);
|
||||
unsigned char cmdBuf[2];
|
||||
|
||||
// Setup YARD command
|
||||
cmdBuf[0] = 'W';
|
||||
cmdBuf[1] = c;
|
||||
|
||||
// Send command
|
||||
return yard_hwWrite(drvthis, cmdBuf, 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Hardware function: Prints a character array
|
||||
*/
|
||||
static int
|
||||
yard_hwPrintCharArray(Driver *drvthis, char *str, unsigned char len)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 05 - Enter yard_hwPrintCharArray: %d - %s",drvthis->name,len,str);
|
||||
unsigned char cmdBuf[MAX_YARDDATA_SIZE];
|
||||
|
||||
// Error check
|
||||
if (len > MAX_YARDDATA_SIZE)
|
||||
{
|
||||
report(RPT_WARNING, "%s: PrintCharArray parameter too large !", drvthis->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cmdBuf[0] = 'W';
|
||||
memcpy(&cmdBuf[1], str, len);
|
||||
|
||||
// Send command
|
||||
return yard_hwWrite(drvthis, cmdBuf, len + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Hardware function: Sets brightness of the backlight
|
||||
*/
|
||||
yard_hwSetBrightness(Driver *drvthis, unsigned char brightVal)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 06 - Enter yard_hwSetBrightness: %d",drvthis->name,brightVal);
|
||||
unsigned char cmdBuf[3];
|
||||
|
||||
// Setup YARD command
|
||||
cmdBuf[0] = 'B';
|
||||
cmdBuf[1] = brightVal;
|
||||
return yard_hwWrite(drvthis, cmdBuf, 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Hardware function: Writes a character into the CGRAM
|
||||
*/
|
||||
static int
|
||||
yard_hwWriteCGRam(Driver *drvthis, unsigned char numChar, unsigned char *data)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 07 - Enter yard_hwWriteCGRam: %d - %02X",drvthis->name,numChar,data);
|
||||
unsigned char cmdBuf[11];
|
||||
|
||||
// Setup YARD command
|
||||
cmdBuf[0] = 'I';
|
||||
cmdBuf[1] = numChar;
|
||||
memcpy(&cmdBuf[2], data, 8);
|
||||
return yard_hwWrite(drvthis, cmdBuf, 10);
|
||||
}
|
||||
|
||||
/*
|
||||
* Inits settings and connection
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
yard_init(Driver *drvthis)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 08 - Enter yard_init",drvthis->name);
|
||||
struct sockaddr_un srvAddr;
|
||||
int tmp, srvAddrLen;
|
||||
PrivateData *p;
|
||||
char sockpath[200] = DEFAULT_SOCK_PATH;
|
||||
unsigned char byteCnt;
|
||||
char Recbuffer[10];
|
||||
|
||||
|
||||
// Allocate and store private data
|
||||
p = (PrivateData *)malloc(sizeof(PrivateData));
|
||||
if (p == NULL)
|
||||
return -1;
|
||||
if (drvthis->store_private_ptr(drvthis, p) < 0)
|
||||
return -1;
|
||||
|
||||
// Initialize cellsize, character spacing and graphical offset
|
||||
p->fd = -1;
|
||||
p->cellwidth = DEFAULT_CELLWIDTH;
|
||||
p->cellheight = DEFAULT_CELLHEIGHT;
|
||||
p->bigcellwidth = DEFAULT_CELLWIDTH_BIG;
|
||||
p->bigcellheight = DEFAULT_CELLHEIGHT_BIG;
|
||||
p->hspace = DEFAULT_HSPACE;
|
||||
p->vspace = DEFAULT_VSPACE;
|
||||
p->ccmode = standard;
|
||||
p->dispmode = Dmode_standard;
|
||||
p->LCDtype = 0; //only use 0=HD44780; not supported now 1=KS0066;2=T6963c;3=KS0108
|
||||
p->width = DEFAULT_WIDTH;
|
||||
p->height = DEFAULT_HEIGHT;
|
||||
p->gwidth = DEFAULT_GWIDTH;
|
||||
p->gheight = DEFAULT_GHEIGHT;
|
||||
|
||||
// Establish connection to YARD server
|
||||
bzero( (char *)&srvAddr, sizeof(srvAddr));
|
||||
srvAddr.sun_family = AF_UNIX;
|
||||
strcpy(srvAddr.sun_path, sockpath);
|
||||
srvAddrLen = strlen(srvAddr.sun_path) + sizeof(srvAddr.sun_family);
|
||||
|
||||
p->fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (p->fd < 0) {
|
||||
report(RPT_ERR, "%s: Can't create socket !", drvthis->name);
|
||||
return -1;
|
||||
}
|
||||
if (connect(p->fd, (struct sockaddr *)&srvAddr, srvAddrLen) < 0) {
|
||||
report(RPT_ERR, "%s: Can't connect to yardsrv !", drvthis->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Get the config from yard2srvd. Config is not in LCDd.conf !
|
||||
sprintf(Recbuffer,"LCDPROC\0");
|
||||
byteCnt = write(p->fd,Recbuffer, strlen(Recbuffer));
|
||||
if (byteCnt < 0)
|
||||
{
|
||||
report(RPT_ERR, "%s: Can't send config request to YARD2 LCDserver !", drvthis->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Wait for YARD server response
|
||||
byteCnt = read(p->fd, Recbuffer, sizeof(Recbuffer) );
|
||||
if (byteCnt < 0)
|
||||
{
|
||||
report(RPT_ERR, "%s: Cannot receive config from YARD server !", drvthis->name);
|
||||
return -1;
|
||||
}
|
||||
else if (byteCnt == 1)
|
||||
{
|
||||
report(RPT_ERR, "%s: YARD communication timeout !", drvthis->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Receiveconfig format: 0='C';1=sizeX;2=sizeY;3=LCDType(0=HD44780,1=KS0066,2=T6963,3=KS0108)
|
||||
if(Recbuffer[0] == 'C') //C=Config
|
||||
{
|
||||
p->width = Recbuffer[1];
|
||||
p->height = Recbuffer[2];
|
||||
p->LCDtype = Recbuffer[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
report(RPT_ERR, "%s: YARD Config Receive error !", drvthis->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(p->LCDtype > 1) //only char LCDs are currently supported
|
||||
{
|
||||
report(RPT_ERR, "%s: YARD LCD type %d not supported by this version or the driver !", drvthis->name,p->LCDtype);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Allocate framebuf & Setup frame buffer x2 to be sure that the buffer is big enough
|
||||
p->framebuf = (unsigned char *) malloc((p->width * p->height)*2);
|
||||
if (p->framebuf == NULL)
|
||||
{
|
||||
report(RPT_ERR, "%s: Can't create framebuffer !", drvthis->name);
|
||||
return -1;
|
||||
}
|
||||
memset(p->framebuf, ' ', (p->width * p->height)*2);
|
||||
|
||||
/* not done yet
|
||||
// Init size and graphical size
|
||||
*/
|
||||
|
||||
/*
|
||||
// Init backlight-on brightness -> done by YARD2 normally in auto mode
|
||||
*/
|
||||
p->on_brightness = DEFAULT_ON_BRIGHTNESS;
|
||||
/*
|
||||
// Init backlight-off brightness -> done by YARD2 normally in auto mode
|
||||
*/
|
||||
tmp = DEFAULT_OFF_BRIGHTNESS;
|
||||
p->off_brightness = tmp;
|
||||
|
||||
|
||||
report(RPT_DEBUG, "%s: Init done", drvthis->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Closes down the driver
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
yard_close(Driver *drvthis)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 09 - Enter yard_close",drvthis->name);
|
||||
PrivateData *p = (PrivateData *)drvthis->private_data;
|
||||
|
||||
if (p != NULL) {
|
||||
close(p->fd);
|
||||
if (p->framebuf)
|
||||
free(p->framebuf);
|
||||
free(p);
|
||||
}
|
||||
|
||||
drvthis->store_private_ptr(drvthis, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the display width in characters
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
yard_width(Driver *drvthis)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 10 - Enter yard_width",drvthis->name);
|
||||
PrivateData *p = (PrivateData *)drvthis->private_data;
|
||||
|
||||
return p->width;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the display height in characters
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
yard_height(Driver *drvthis)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 11 - Enter yard_height",drvthis->name);
|
||||
PrivateData *p = (PrivateData *)drvthis->private_data;
|
||||
|
||||
return p->height;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clears the framebuffer
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
yard_clear(Driver *drvthis)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 12 - Enter yard_clear",drvthis->name);
|
||||
PrivateData *p = (PrivateData *)drvthis->private_data;
|
||||
|
||||
// Reset custom char mode and clear frambuffer
|
||||
p->ccmode = standard;
|
||||
memset(p->framebuf, ' ', p->width * p->height);
|
||||
}
|
||||
|
||||
/*
|
||||
* Flushes a single frame to the LCD
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
yard_flush(Driver *drvthis)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 13 - Enter yard_flush",drvthis->name);
|
||||
PrivateData *p = (PrivateData *)drvthis->private_data;
|
||||
int i;
|
||||
int width, height;
|
||||
|
||||
switch (p->dispmode) {
|
||||
case Dmode_standard:
|
||||
{
|
||||
// Set width and height
|
||||
width = p->width;
|
||||
height = p->height;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 24 - Only Char. Mode supported: %d",drvthis->name,p->dispmode);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Send framebuffer content to LCD
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
// Line feed
|
||||
yard_hwGotoXY(drvthis, 1, i+1);
|
||||
|
||||
// Write single line
|
||||
yard_hwPrintCharArray(drvthis, &(p->framebuf[i*width]), width);
|
||||
debug(RPT_DEBUG, "YARD2: flushed line %d - chars %d", i,width);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Prints a string on the LCD
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
yard_string(Driver *drvthis, int x, int y, const char string[])
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 14 - Enter yard_string: X.%d - Y.%d - %s",drvthis->name,x,y,string);
|
||||
|
||||
PrivateData *p = (PrivateData *)drvthis->private_data;
|
||||
int i;
|
||||
|
||||
// Change display mode if necessary; Only char mode 0 is supported right now
|
||||
if (p->dispmode == Dmode_graphical)
|
||||
{
|
||||
yard_hwClearLCD(drvthis);
|
||||
p->dispmode = Dmode_standard;
|
||||
}
|
||||
|
||||
x--; //start with 0,0
|
||||
y--;
|
||||
|
||||
if ((y < 0) || (y >= p->height)) return;
|
||||
|
||||
|
||||
|
||||
for (i = 0; (string[i] != '\0') && (x < p->width); i++) //, x++)
|
||||
{
|
||||
if (x >= 0) // no write left of left border
|
||||
p->framebuf[(y * p->width) + x + i] = string[i];
|
||||
}
|
||||
|
||||
/*
|
||||
for (i = 0; string[i] != '\0'; i++)
|
||||
{
|
||||
// Check for buffer overflow
|
||||
if ( (y * p->width + x + i) >= (p->width * p->height) )
|
||||
break;
|
||||
p->framebuf[(y * p->width) + x + i] = string[i];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* Prints a single character on the LCD
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
yard_chr(Driver *drvthis, int x, int y, char c)
|
||||
{
|
||||
PrivateData *p = (PrivateData *)drvthis->private_data;
|
||||
debug(RPT_DEBUG, "%s: Event 15 - Enter yard_chr",drvthis->name);
|
||||
|
||||
// Error check
|
||||
if ( (x > p->width) || (y > p->height) )
|
||||
return;
|
||||
|
||||
// Change display mode if necessary
|
||||
if (p->dispmode == Dmode_graphical)
|
||||
{
|
||||
yard_hwClearLCD(drvthis);
|
||||
p->dispmode = 0;
|
||||
}
|
||||
|
||||
y--; //start with 0,0
|
||||
x--;
|
||||
p->framebuf[(y * p->width) + x ] = c;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the number of custom characters
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
yard_get_free_chars(Driver *drvthis)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 16 - Enter yard_get_free_chars",drvthis->name);
|
||||
return NUM_CUSTOMCHARS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets a custom character
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
yard_set_char(Driver *drvthis, int n, unsigned char *dat)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 17 - Enter yard_set_char: Nr.%d - %02X",drvthis->name,n,dat);
|
||||
|
||||
if ( (n < 0) || (n >= NUM_CUSTOMCHARS) )
|
||||
return;
|
||||
if (!dat)
|
||||
return;
|
||||
|
||||
yard_hwWriteCGRam(drvthis, n, dat);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the width of a character in pixels
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
yard_cellwidth(Driver *drvthis)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 18 - Enter yard_cellwidth",drvthis->name);
|
||||
PrivateData *p = (PrivateData *)drvthis->private_data;
|
||||
|
||||
return p->cellwidth;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the height of a character in pixels
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
yard_cellheight(Driver *drvthis)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 19 - Enter yard_cellheight",drvthis->name);
|
||||
PrivateData *p = (PrivateData *)drvthis->private_data;
|
||||
|
||||
return p->cellheight;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reads brightness (in promille)
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
yard_get_brightness(Driver *drvthis, int state)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 20 - Enter yard_get_brightness: %d",drvthis->name,state);
|
||||
PrivateData *p = (PrivateData *)drvthis->private_data;
|
||||
|
||||
return (state == BACKLIGHT_ON) ? p->on_brightness : p->off_brightness;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets brightness (in promille)
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
yard_set_brightness(Driver *drvthis, int state, int promille)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 21 - Enter yard_set_brightness: %d - %d",drvthis->name,state,promille);
|
||||
PrivateData *p = (PrivateData *)drvthis->private_data;
|
||||
|
||||
// Error check
|
||||
if (promille < 0 || promille > 1000)
|
||||
return;
|
||||
|
||||
// Store values
|
||||
if (state == BACKLIGHT_ON) {
|
||||
p->on_brightness = promille;
|
||||
}
|
||||
else {
|
||||
p->off_brightness = promille;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the backlight on or off
|
||||
* The hardware supports any value between 0 and 255
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
yard_backlight(Driver *drvthis, int on)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 22 - Enter yard_backlight: %d",drvthis->name,on);
|
||||
PrivateData *p = (PrivateData *)drvthis->private_data;
|
||||
|
||||
int hardware_value = (on == BACKLIGHT_ON) ? p->on_brightness : p->off_brightness;
|
||||
|
||||
// Map range to hardware [0, 1000] -> [0, 255]
|
||||
hardware_value /= 4;
|
||||
if (hardware_value != p->hw_brightness)
|
||||
{
|
||||
// Send command and update private data
|
||||
yard_hwSetBrightness(drvthis, hardware_value);
|
||||
p->hw_brightness = (char)hardware_value;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Provides info about the driver
|
||||
*/
|
||||
MODULE_EXPORT const char *
|
||||
yard_get_info(Driver *drvthis)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Event 23 - Enter yard_get_info",drvthis->name);
|
||||
PrivateData *p = (PrivateData *)drvthis->private_data;
|
||||
|
||||
strcpy(p->info, "Socket-based driver for Y.A.R.D.2 USB LCD");
|
||||
return p->info;
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 by R. Geigenberger *
|
||||
* *
|
||||
* *
|
||||
* 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 of the License, 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., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#ifndef yard2LCD_H
|
||||
#define yard2LCD_H
|
||||
|
||||
#define MAX_YARDDATA_SIZE 40
|
||||
#define DEFAULT_SOCK_PATH "/tmp/lcdserver"
|
||||
#define DEFAULT_OFF_BRIGHTNESS 100
|
||||
#define DEFAULT_ON_BRIGHTNESS 1000
|
||||
#define DEFAULT_WIDTH 16
|
||||
#define DEFAULT_HEIGHT 4
|
||||
#define DEFAULT_GWIDTH 64
|
||||
#define DEFAULT_GHEIGHT 32
|
||||
#define DEFAULT_CELLWIDTH 5
|
||||
#define DEFAULT_CELLHEIGHT 8
|
||||
#define DEFAULT_CELLWIDTH_BIG 10
|
||||
#define DEFAULT_CELLHEIGHT_BIG 14
|
||||
#define DEFAULT_HSPACE 2
|
||||
#define DEFAULT_VSPACE 1
|
||||
#define NUM_CUSTOMCHARS 8
|
||||
|
||||
|
||||
MODULE_EXPORT int yard_init (Driver *drvthis);
|
||||
MODULE_EXPORT void yard_close (Driver *drvthis);
|
||||
MODULE_EXPORT int yard_width (Driver *drvthis);
|
||||
MODULE_EXPORT int yard_height (Driver *drvthis);
|
||||
MODULE_EXPORT void yard_clear (Driver *drvthis);
|
||||
MODULE_EXPORT void yard_flush (Driver *drvthis);
|
||||
MODULE_EXPORT void yard_string (Driver *drvthis, int x, int y, const char string[]);
|
||||
MODULE_EXPORT void yard_chr (Driver *drvthis, int x, int y, char c);
|
||||
MODULE_EXPORT void yard_num(Driver *drvthis, int x, int num);
|
||||
MODULE_EXPORT void yard_set_char(Driver *drvthis, int n, unsigned char *dat);
|
||||
MODULE_EXPORT int yard_get_free_chars(Driver *drvthis);
|
||||
MODULE_EXPORT int yard_cellwidth (Driver *drvthis);
|
||||
MODULE_EXPORT int yard_cellheight (Driver *drvthis);
|
||||
MODULE_EXPORT int yard_get_brightness (Driver *drvthis, int state);
|
||||
MODULE_EXPORT void yard_set_brightness (Driver *drvthis, int state, int promille);
|
||||
MODULE_EXPORT void yard_backlight (Driver *drvthis, int on);
|
||||
MODULE_EXPORT const char * yard_get_info( Driver *drvthis );
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user