hd44780 driver: new ConnectionType mplay
This commit is contained in:
@@ -35,6 +35,8 @@ v.0.5dev (ongoing development)
|
|||||||
* avoid sending duplicate "success" messages in response to menu_add_item
|
* avoid sending duplicate "success" messages in response to menu_add_item
|
||||||
+ lcdexec: parameter support using widgets
|
+ lcdexec: parameter support using widgets
|
||||||
* server core: display values in menu for all input MenuEntry types
|
* server core: display values in menu for all input MenuEntry types
|
||||||
|
* hd44780 driver: reorganize ConnectionType recognition
|
||||||
|
+ hd44780 driver: new ConnectionType mplay
|
||||||
|
|
||||||
v.0.5.2
|
v.0.5.2
|
||||||
* fix switching on/off the Load screen in lcdproc client using the menu
|
* fix switching on/off the Load screen in lcdproc client using the menu
|
||||||
|
|||||||
@@ -152,6 +152,9 @@ Pertelian X2040 module (http://pertelian.com/)
|
|||||||
.B lis2
|
.B lis2
|
||||||
LIS2 from VLSystem (http://www.vlsys.co.kr), connected to USB
|
LIS2 from VLSystem (http://www.vlsys.co.kr), connected to USB
|
||||||
.TP
|
.TP
|
||||||
|
.B mplay
|
||||||
|
MPlay Blast from VLSystem (http://www.vlsys.co.kr), connected to USB
|
||||||
|
.TP
|
||||||
.B bwctusb
|
.B bwctusb
|
||||||
USB-to-HD44780 converter by BWCT (http://www.bwct.de)
|
USB-to-HD44780 converter by BWCT (http://www.bwct.de)
|
||||||
.TP
|
.TP
|
||||||
|
|||||||
@@ -1553,10 +1553,25 @@ that. The BL output below should be connected to the BL input in the
|
|||||||
<title>LIS2 USB device "lis2"</title>
|
<title>LIS2 USB device "lis2"</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
LIS2 from VLSystem (<ulink url="http://www.vlsys.co.kr"></ulink>) is a full featured USB VFD module
|
LIS2 from VLSystem (<ulink url="http://www.vlsys.co.kr"></ulink>)
|
||||||
with four channel fan controls. This device can be accessed as a serial device with the
|
is a full featured USB VFD module with four channel fan controls.
|
||||||
help of the kernel modules <filename>ftdi_sio.ko</filename> that map the USB port to a serial port
|
This device can be accessed as a serial device with the help of the kernel
|
||||||
(<filename class="devicefile">/dev/ttyUSB<replaceable>x</replaceable></filename>).
|
module <filename>ftdi_sio.ko</filename> that maps the USB port to a serial port
|
||||||
|
(e.g. <filename class="devicefile">/dev/ttyUSB<replaceable>x</replaceable></filename>).
|
||||||
|
</para>
|
||||||
|
|
||||||
|
</sect3>
|
||||||
|
|
||||||
|
<sect3 id="hd44780-mplay">
|
||||||
|
<title>MPlay Blast USB device "mplay"</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
MPlay Blast from VLSystem (<ulink url="http://www.vlsys.co.kr"></ulink>)
|
||||||
|
is a full featured USB VFD module with two channel fan controls and
|
||||||
|
two channel temperature sensors.
|
||||||
|
This device can be accessed as a serial device with the help of the kernel
|
||||||
|
module <filename>ftdi_sio.ko</filename> that maps the USB port to a serial port
|
||||||
|
(e.g. <filename class="devicefile">/dev/ttyUSB<replaceable>x</replaceable></filename>).
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
</sect3>
|
</sect3>
|
||||||
@@ -2104,6 +2119,7 @@ This can be done by specifying <option>--enable-drivers=all</option> or by inclu
|
|||||||
<arg choice="plain"><literal>bwctusb</literal></arg>
|
<arg choice="plain"><literal>bwctusb</literal></arg>
|
||||||
<arg choice="plain"><literal>lcd2usb</literal></arg>
|
<arg choice="plain"><literal>lcd2usb</literal></arg>
|
||||||
<arg choice="plain"><literal>lis2</literal></arg>
|
<arg choice="plain"><literal>lis2</literal></arg>
|
||||||
|
<arg choice="plain"><literal>mplay</literal></arg>
|
||||||
<arg choice="plain"><literal>i2c</literal></arg>
|
<arg choice="plain"><literal>i2c</literal></arg>
|
||||||
</group>
|
</group>
|
||||||
</arg>
|
</arg>
|
||||||
@@ -2173,6 +2189,10 @@ This can be done by specifying <option>--enable-drivers=all</option> or by inclu
|
|||||||
<entry><literal><link linkend="hd44780-lis2">lis2</link></literal></entry>
|
<entry><literal><link linkend="hd44780-lis2">lis2</link></literal></entry>
|
||||||
<entry>LIS2 from VLSystem (<ulink url="http://www.vlsys.co.kr"></ulink>)</entry>
|
<entry>LIS2 from VLSystem (<ulink url="http://www.vlsys.co.kr"></ulink>)</entry>
|
||||||
</row>
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><literal><link linkend="hd44780-mplay">mplay</link></literal></entry>
|
||||||
|
<entry>MPlay Blast from VLSystem (<ulink url="http://www.vlsys.co.kr"></ulink>)</entry>
|
||||||
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry><literal><link linkend="hd44780-i2c">i2c</link></literal></entry>
|
<entry><literal><link linkend="hd44780-i2c">i2c</link></literal></entry>
|
||||||
<entry>LCD driven by PCF8574(A)/PCA9554(A) connected via I<superscript>2</superscript>C</entry>
|
<entry>LCD driven by PCF8574(A)/PCA9554(A) connected via I<superscript>2</superscript>C</entry>
|
||||||
|
|||||||
@@ -36,26 +36,27 @@
|
|||||||
// - initialisation function
|
// - initialisation function
|
||||||
static const ConnectionMapping connectionMapping[] = {
|
static const ConnectionMapping connectionMapping[] = {
|
||||||
#ifdef HAVE_PCSTYLE_LPT_CONTROL
|
#ifdef HAVE_PCSTYLE_LPT_CONTROL
|
||||||
{ "4bit", HD44780_CT_4BIT, IF_TYPE_PARPORT, hd_init_4bit },
|
{ "4bit", HD44780_CT_4BIT, IF_TYPE_PARPORT, hd_init_4bit },
|
||||||
{ "8bit", HD44780_CT_8BIT, IF_TYPE_PARPORT, hd_init_ext8bit },
|
{ "8bit", HD44780_CT_8BIT, IF_TYPE_PARPORT, hd_init_ext8bit },
|
||||||
{ "serialLpt", HD44780_CT_SERIALLPT, IF_TYPE_PARPORT, hd_init_serialLpt },
|
{ "serialLpt", HD44780_CT_SERIALLPT, IF_TYPE_PARPORT, hd_init_serialLpt },
|
||||||
{ "winamp", HD44780_CT_WINAMP, IF_TYPE_PARPORT, hd_init_winamp },
|
{ "winamp", HD44780_CT_WINAMP, IF_TYPE_PARPORT, hd_init_winamp },
|
||||||
#endif
|
#endif
|
||||||
/* Serial connectiontypes */
|
/* Serial connectiontypes */
|
||||||
{ "picanlcd", HD44780_CT_PICANLCD, IF_TYPE_SERIAL, hd_init_serial },
|
{ "picanlcd", HD44780_CT_PICANLCD, IF_TYPE_SERIAL, hd_init_serial },
|
||||||
{ "lcdserializer", HD44780_CT_LCDSERIALIZER, IF_TYPE_SERIAL, hd_init_serial },
|
{ "lcdserializer", HD44780_CT_LCDSERIALIZER, IF_TYPE_SERIAL, hd_init_serial },
|
||||||
{ "los-panel", HD44780_CT_LOS_PANEL, IF_TYPE_SERIAL, hd_init_serial },
|
{ "los-panel", HD44780_CT_LOS_PANEL, IF_TYPE_SERIAL, hd_init_serial },
|
||||||
{ "vdr-lcd", HD44780_CT_VDR_LCD, IF_TYPE_SERIAL, hd_init_serial },
|
{ "vdr-lcd", HD44780_CT_VDR_LCD, IF_TYPE_SERIAL, hd_init_serial },
|
||||||
{ "vdr-wakeup", HD44780_CT_VDR_WAKEUP, IF_TYPE_SERIAL, hd_init_serial },
|
{ "vdr-wakeup", HD44780_CT_VDR_WAKEUP, IF_TYPE_SERIAL, hd_init_serial },
|
||||||
{ "pertelian", HD44780_CT_PERTELIAN, IF_TYPE_SERIAL, hd_init_serial },
|
{ "pertelian", HD44780_CT_PERTELIAN, IF_TYPE_SERIAL, hd_init_serial },
|
||||||
/* End serial connectiontypes */
|
/* End serial connectiontypes */
|
||||||
{ "lis2", HD44780_CT_LIS2, IF_TYPE_SERIAL, hd_init_lis2 },
|
{ "lis2", HD44780_CT_LIS2, IF_TYPE_USB, hd_init_lis2 },
|
||||||
|
{ "mplay", HD44780_CT_MPLAY, IF_TYPE_USB, hd_init_lis2 },
|
||||||
#ifdef HAVE_LIBUSB
|
#ifdef HAVE_LIBUSB
|
||||||
{ "bwctusb", HD44780_CT_BWCTUSB, IF_TYPE_USB, hd_init_bwct_usb },
|
{ "bwctusb", HD44780_CT_BWCTUSB, IF_TYPE_USB, hd_init_bwct_usb },
|
||||||
{ "lcd2usb", HD44780_CT_I2C, IF_TYPE_USB, hd_init_lcd2usb },
|
{ "lcd2usb", HD44780_CT_I2C, IF_TYPE_USB, hd_init_lcd2usb },
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_I2C
|
#ifdef HAVE_I2C
|
||||||
{ "i2c", HD44780_CT_I2C, IF_TYPE_I2C, hd_init_i2c },
|
{ "i2c", HD44780_CT_I2C, IF_TYPE_I2C, hd_init_i2c },
|
||||||
#endif
|
#endif
|
||||||
// add new connection types and their string specifier here
|
// add new connection types and their string specifier here
|
||||||
// default, end of structure element (do not delete)
|
// default, end of structure element (do not delete)
|
||||||
|
|||||||
+244
-98
@@ -1,10 +1,9 @@
|
|||||||
/** \file hd44780-lis2.c
|
/** \file hd44780-lis2.c
|
||||||
* \c lis2 connection type of \c hd44780 driver for Hitachi HD44780 based LCD displays.
|
* \c lis2 and \c mplay connection types of \c hd44780 driver for Hitachi HD44780 based LCD displays.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* VLSystems LIS2 driver
|
* Driver for VLsystems LIS2 and MPlay displays.
|
||||||
* Modification of the code of the LCDSerializer driver
|
|
||||||
*
|
*
|
||||||
* Copyright (c) 1997, Matthias Prinke <m.prinke@trashcan.mcnet.de>
|
* Copyright (c) 1997, Matthias Prinke <m.prinke@trashcan.mcnet.de>
|
||||||
* 1998, Richard Rognlie <rrognlie@gamerz.net>
|
* 1998, Richard Rognlie <rrognlie@gamerz.net>
|
||||||
@@ -15,6 +14,7 @@
|
|||||||
* 2005, Pillon Matteo <matteo.pillon@email.it>
|
* 2005, Pillon Matteo <matteo.pillon@email.it>
|
||||||
* 2005, Laurent ARNAL <laurent@clae.net>
|
* 2005, Laurent ARNAL <laurent@clae.net>
|
||||||
* 2007, Peter Marschall <peter@adpm.de>
|
* 2007, Peter Marschall <peter@adpm.de>
|
||||||
|
* 2007, Sean Meiners <sean.lcdproc@ssttr.com>
|
||||||
*
|
*
|
||||||
* This file is released under the GNU General Public License. Refer to the
|
* This file is released under the GNU General Public License. Refer to the
|
||||||
* COPYING file distributed with this package.
|
* COPYING file distributed with this package.
|
||||||
@@ -40,17 +40,25 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEFAULT_DEVICE "/dev/ttyUSB0"
|
#define DEFAULT_DEVICE "/dev/ttyUSB0"
|
||||||
|
|
||||||
|
|
||||||
|
/* bitrate conversion */
|
||||||
|
extern unsigned int **bitrate_conversion;
|
||||||
|
extern int convert_bitrate(unsigned int conf_bitrate, size_t *bitrate);
|
||||||
|
|
||||||
void lis2_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
void lis2_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||||
void lis2_HD44780_backlight(PrivateData *p, unsigned char state);
|
void lis2_HD44780_backlight(PrivateData *p, unsigned char state);
|
||||||
unsigned char lis2_HD44780_scankeypad(PrivateData *p);
|
unsigned char lis2_HD44780_scankeypad(PrivateData *p);
|
||||||
|
|
||||||
static void setLIS2CustomCharRow(int fd, unsigned char custom, unsigned char row, unsigned char data);
|
static void clearScreen(int fd);
|
||||||
static void setLIS2Fan(int fd, int fan1, int fan2, int fan3, int fan4);
|
|
||||||
static void gotoXY(int fd, unsigned char x, unsigned char y);
|
static void gotoXY(int fd, unsigned char x, unsigned char y);
|
||||||
|
static void setMPlayCustomChars(int fd, CGram *chars);
|
||||||
|
static void setLIS2CustomCharRow(int fd, unsigned char custom, unsigned char row, unsigned char data);
|
||||||
|
static char readMPlayTemps(int fd, int *temps, int num);
|
||||||
|
static void initMPlayFans(int fd);
|
||||||
|
static void setMPlayFans(int fd, unsigned char *fans, int num);
|
||||||
|
static void setLIS2Fans(int fd, int fan1, int fan2, int fan3, int fan4);
|
||||||
static void writeChar(int fd, unsigned char code);
|
static void writeChar(int fd, unsigned char code);
|
||||||
|
|
||||||
|
|
||||||
@@ -89,9 +97,26 @@ int hd_init_lis2(Driver *drvthis)
|
|||||||
portset.c_cc[VMIN] = 1;
|
portset.c_cc[VMIN] = 1;
|
||||||
portset.c_cc[VTIME] = 3;
|
portset.c_cc[VTIME] = 3;
|
||||||
|
|
||||||
/* Set port speed to 19200 baud */
|
if (p->connectiontype == HD44780_CT_LIS2) {
|
||||||
cfsetospeed(&portset, B19200);
|
/* Set port speed to 19200 baud */
|
||||||
cfsetispeed(&portset, B0);
|
cfsetospeed(&portset, B19200);
|
||||||
|
cfsetispeed(&portset, B0);
|
||||||
|
}
|
||||||
|
else { // p->connectiontype == HD44780_CT_MPLAY
|
||||||
|
/* Get bitrate */
|
||||||
|
unsigned int conf_bitrate;
|
||||||
|
size_t bitrate;
|
||||||
|
|
||||||
|
conf_bitrate = drvthis->config_get_int(drvthis->name, "Speed", 0, 38400);
|
||||||
|
if (convert_bitrate(conf_bitrate, &bitrate)) {
|
||||||
|
report(RPT_ERR, "HD44780: lis2: invalid configured bitrate speed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
report(RPT_INFO, "HD44780: lis2: using speed: %d", conf_bitrate);
|
||||||
|
|
||||||
|
cfsetospeed(&portset, bitrate);
|
||||||
|
cfsetispeed(&portset, bitrate);
|
||||||
|
}
|
||||||
|
|
||||||
/* Set TCSANOW mode of serial device */
|
/* Set TCSANOW mode of serial device */
|
||||||
tcsetattr(p->fd, TCSANOW, &portset);
|
tcsetattr(p->fd, TCSANOW, &portset);
|
||||||
@@ -106,74 +131,6 @@ int hd_init_lis2(Driver *drvthis)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set one pixel row of a custom character, valid on LIS2 devices only.
|
|
||||||
* \param fd File handle to write to.
|
|
||||||
* \param custom Custom character to set (from 0 to 7).
|
|
||||||
* \param row Index of pixel row to set (from (0 [=top] to 7 [=bottom]).
|
|
||||||
* \param data Pixel data: 5 bit coding from 0 to 31 from right to left (16/8/4/2/1).
|
|
||||||
*/
|
|
||||||
static void setLIS2CustomCharRow(int fd, unsigned char custom, unsigned char row, unsigned char data)
|
|
||||||
{
|
|
||||||
writeChar(fd, 0);
|
|
||||||
writeChar(fd, 171);
|
|
||||||
writeChar(fd, custom);
|
|
||||||
writeChar(fd, row);
|
|
||||||
writeChar(fd, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ??? Set fans, valid on LIS2 devices only. ???
|
|
||||||
* \param fd File handle to write to.
|
|
||||||
* \param fan1 Data for 1st fan.
|
|
||||||
* \param fan2 Data for 2nd fan.
|
|
||||||
* \param fan3 Data for 3rd fan.
|
|
||||||
* \param fan4 Data for 4th fan.
|
|
||||||
*/
|
|
||||||
static void setLIS2Fan(int fd, int fan1, int fan2, int fan3, int fan4)
|
|
||||||
{
|
|
||||||
writeChar(fd, 0);
|
|
||||||
writeChar(fd, 174);
|
|
||||||
writeChar(fd, 0);
|
|
||||||
writeChar(fd, 0);
|
|
||||||
writeChar(fd, fan1);
|
|
||||||
writeChar(fd, 0);
|
|
||||||
writeChar(fd, fan2);
|
|
||||||
writeChar(fd, 0);
|
|
||||||
writeChar(fd, fan3);
|
|
||||||
writeChar(fd, 0);
|
|
||||||
writeChar(fd, fan4);
|
|
||||||
writeChar(fd, 0);
|
|
||||||
writeChar(fd, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** Move cursor to given character coordinates.
|
|
||||||
* \param fd File handle to write to.
|
|
||||||
* \param x Character column to set cursor to.
|
|
||||||
* \param y Character row to set cursor to.
|
|
||||||
*/
|
|
||||||
static void gotoXY(int fd, unsigned char x, unsigned char y)
|
|
||||||
{
|
|
||||||
writeChar(fd, 0);
|
|
||||||
writeChar(fd, 161 + y);
|
|
||||||
writeChar(fd, x);
|
|
||||||
writeChar(fd, 167);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write a character.
|
|
||||||
* \param fd File handle to write to.
|
|
||||||
* \param ch Character to write.
|
|
||||||
*/
|
|
||||||
static void writeChar(int fd, unsigned char code)
|
|
||||||
{
|
|
||||||
write(fd, &code, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void lis2_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
void lis2_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||||
{
|
{
|
||||||
static int mode = 0;
|
static int mode = 0;
|
||||||
@@ -182,22 +139,45 @@ static unsigned char rowNum = 0;
|
|||||||
|
|
||||||
if (flags == RS_DATA) { // RS_DATA: we have data
|
if (flags == RS_DATA) { // RS_DATA: we have data
|
||||||
if (mode == SETCHAR) {
|
if (mode == SETCHAR) {
|
||||||
// define row for custom char (reset mode to normal if illegal row)
|
if (p->connectiontype == HD44780_CT_LIS2) {
|
||||||
if (rowNum < p->cellheight)
|
if (rowNum < p->cellheight)
|
||||||
setLIS2CustomCharRow(p->fd, charNum, rowNum, ch);
|
// define row for custom char
|
||||||
else
|
setLIS2CustomCharRow(p->fd, charNum, rowNum, ch);
|
||||||
mode = 0;
|
else
|
||||||
|
mode = 0; // reset mode
|
||||||
|
}
|
||||||
|
|
||||||
// increase row counter
|
// increase row counter
|
||||||
rowNum++;
|
rowNum++;
|
||||||
|
|
||||||
|
if (p->connectiontype == HD44780_CT_MPLAY) {
|
||||||
|
if (rowNum == p->cellheight) {
|
||||||
|
// set all custom chars
|
||||||
|
setMPlayCustomChars(p->fd, p->cc);
|
||||||
|
// give enough time for the commands to exec
|
||||||
|
p->hd44780_functions->uPause(p, 40);
|
||||||
|
|
||||||
|
mode = 0; // reset mode
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// offset given char by one to avoid collisions with command prefix
|
if (p->connectiontype == HD44780_CT_LIS2) {
|
||||||
// TODO: check if this is correct
|
// offset given char by one to avoid collisions with command prefix
|
||||||
if (ch < 7)
|
// TODO: check if this is correct
|
||||||
ch++;
|
if (ch < 7)
|
||||||
|
ch++;
|
||||||
|
}
|
||||||
|
else { // p->connectiontype == HD44780_CT_MPLAY
|
||||||
|
// 0x00 is the command prefix so we can't use it.
|
||||||
|
// Luckily, there are 16 custom char positions & the
|
||||||
|
// second 8 are identical to the first 8 so we can
|
||||||
|
// just offset it
|
||||||
|
if (ch < NUM_CCs)
|
||||||
|
ch += NUM_CCs;
|
||||||
|
}
|
||||||
|
|
||||||
// simply write character byte
|
// simply write data/character byte
|
||||||
write(p->fd, &ch, 1);
|
write(p->fd, &ch, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -214,23 +194,27 @@ static unsigned char rowNum = 0;
|
|||||||
else if ((ch & SETCHAR) != 0) {
|
else if ((ch & SETCHAR) != 0) {
|
||||||
mode = SETCHAR;
|
mode = SETCHAR;
|
||||||
|
|
||||||
// extract character to set from given info
|
if (p->connectiontype == HD44780_CT_LIS2) {
|
||||||
charNum = (ch & ~SETCHAR) / 8;
|
// extract character to set from given info
|
||||||
|
charNum = (ch & ~SETCHAR) / 8;
|
||||||
|
|
||||||
// offset it by one to avoid collisions with command prefix
|
// offset it by one to avoid collisions with command prefix
|
||||||
// TODO: check if this is correct
|
// TODO: check if this is correct
|
||||||
charNum++;
|
charNum++;
|
||||||
|
|
||||||
// restrict it to range [1, 7]
|
// restrict it to range [1, 7]
|
||||||
// TODO: check if this is correct
|
// TODO: check if this is correct
|
||||||
if (charNum == 8)
|
if (charNum == 8)
|
||||||
charNum = 7;
|
charNum = 7;
|
||||||
|
}
|
||||||
|
// MPlay devices don't need the char num;
|
||||||
|
// they always set all custom characters
|
||||||
|
|
||||||
// reset row number
|
// reset row number
|
||||||
rowNum = 0;
|
rowNum = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// simply write through instruction byte
|
// simply write instruction byte
|
||||||
write(p->fd, &ch, 1);
|
write(p->fd, &ch, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,3 +232,165 @@ unsigned char lis2_HD44780_scankeypad(PrivateData *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// hardware specific functions common to all device types
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear device screen.
|
||||||
|
* \param fd File handle to write to.
|
||||||
|
*/
|
||||||
|
static void clearScreen(int fd)
|
||||||
|
{
|
||||||
|
writeChar(fd, 0);
|
||||||
|
writeChar(fd, 0xA0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Move cursor to given character coordinates.
|
||||||
|
* \param fd File handle to write to.
|
||||||
|
* \param x Character column to set cursor to.
|
||||||
|
* \param y Character row to set cursor to.
|
||||||
|
*/
|
||||||
|
static void gotoXY(int fd, unsigned char x, unsigned char y)
|
||||||
|
{
|
||||||
|
writeChar(fd, 0);
|
||||||
|
writeChar(fd, 0xA1 + y);
|
||||||
|
writeChar(fd, x);
|
||||||
|
writeChar(fd, 0xA7);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// hardware specific functions specific for a special device type
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a custom character, valid on MPlay devices only.
|
||||||
|
* \param fd File handle to write to.
|
||||||
|
* \param chars Pixel definition of all custom chars.
|
||||||
|
*/
|
||||||
|
static void setMPlayCustomChars(int fd, CGram *chars)
|
||||||
|
{
|
||||||
|
// chars *must* be 8x8
|
||||||
|
int i, row;
|
||||||
|
|
||||||
|
writeChar(fd, 0);
|
||||||
|
writeChar(fd, 0xAD);
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_CCs; i++) {
|
||||||
|
for (row = 0; row < 8; row++) { // 8 == p->cellheight
|
||||||
|
writeChar(fd, chars[i].cache[row]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set one pixel row of a custom character, valid on LIS2 devices only.
|
||||||
|
* \param fd File handle to write to.
|
||||||
|
* \param custom Custom character to set (from 0 to 7).
|
||||||
|
* \param row Index of pixel row to set (from (0 [=top] to 7 [=bottom]).
|
||||||
|
* \param data Pixel data: 5 bit coding from 0 to 31 from right to left (16/8/4/2/1).
|
||||||
|
*/
|
||||||
|
static void setLIS2CustomCharRow(int fd, unsigned char custom, unsigned char row, unsigned char data)
|
||||||
|
{
|
||||||
|
writeChar(fd, 0);
|
||||||
|
writeChar(fd, 0xAB);
|
||||||
|
writeChar(fd, custom);
|
||||||
|
writeChar(fd, row);
|
||||||
|
writeChar(fd, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read temperatures, valid only on MPlay devices.
|
||||||
|
* \param fd File handle to read from.
|
||||||
|
* \param temps Pointer to pre-allocated array to store the temperatures.
|
||||||
|
* \param num Length of temperature array.
|
||||||
|
* \retval 0 Error.
|
||||||
|
* \retval 1 Temperatures read successfully.
|
||||||
|
*/
|
||||||
|
static char readMPlayTemps(int fd, int *temps, int num)
|
||||||
|
{
|
||||||
|
unsigned char raw[num];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
writeChar(fd, 0);
|
||||||
|
writeChar(fd, 0xAF);
|
||||||
|
|
||||||
|
if (read(fd, raw, num) == num) {
|
||||||
|
for (i = 0; i < num; i++)
|
||||||
|
temps[i] = (int) raw[i] - 150;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* initialize fans, valid only on MPlay devices.
|
||||||
|
* \param fd File handle to write to.
|
||||||
|
*/
|
||||||
|
static void initMPlayFans(int fd)
|
||||||
|
{
|
||||||
|
writeChar(fd, 0);
|
||||||
|
writeChar(fd, 0xA4);
|
||||||
|
writeChar(fd, 0x7D);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set fans, valid on MPlay devices only.
|
||||||
|
* \param fd File handle to write to.
|
||||||
|
* \param fans Array holding fan information
|
||||||
|
* \param num Length of fan array.
|
||||||
|
*/
|
||||||
|
static void setMPlayFans(int fd, unsigned char *fans, int num)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
writeChar(fd, 0);
|
||||||
|
writeChar(fd, 0xAC);
|
||||||
|
|
||||||
|
for (i = 0; i < num; i++)
|
||||||
|
writeChar(fd, fans[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set fans, valid on LIS2 devices only. ???
|
||||||
|
* \param fd File handle to write to.
|
||||||
|
* \param fan1 Data for 1st fan.
|
||||||
|
* \param fan2 Data for 2nd fan.
|
||||||
|
* \param fan3 Data for 3rd fan.
|
||||||
|
* \param fan4 Data for 4th fan.
|
||||||
|
*/
|
||||||
|
static void setLIS2Fans(int fd, int fan1, int fan2, int fan3, int fan4)
|
||||||
|
{
|
||||||
|
writeChar(fd, 0);
|
||||||
|
writeChar(fd, 0xAE);
|
||||||
|
writeChar(fd, 0);
|
||||||
|
writeChar(fd, 0);
|
||||||
|
writeChar(fd, fan1);
|
||||||
|
writeChar(fd, 0);
|
||||||
|
writeChar(fd, fan2);
|
||||||
|
writeChar(fd, 0);
|
||||||
|
writeChar(fd, fan3);
|
||||||
|
writeChar(fd, 0);
|
||||||
|
writeChar(fd, fan4);
|
||||||
|
writeChar(fd, 0);
|
||||||
|
writeChar(fd, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// basic functions
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a character.
|
||||||
|
* \param fd File handle to write to.
|
||||||
|
* \param ch Character to write.
|
||||||
|
*/
|
||||||
|
static void writeChar(int fd, unsigned char code)
|
||||||
|
{
|
||||||
|
write(fd, &code, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|||||||
@@ -35,9 +35,10 @@
|
|||||||
#define HD44780_CT_VDR_WAKEUP 9
|
#define HD44780_CT_VDR_WAKEUP 9
|
||||||
#define HD44780_CT_PERTELIAN 10
|
#define HD44780_CT_PERTELIAN 10
|
||||||
#define HD44780_CT_LIS2 11
|
#define HD44780_CT_LIS2 11
|
||||||
#define HD44780_CT_BWCTUSB 12
|
#define HD44780_CT_MPLAY 12
|
||||||
#define HD44780_CT_LCDUSB 13
|
#define HD44780_CT_BWCTUSB 13
|
||||||
#define HD44780_CT_I2C 14
|
#define HD44780_CT_LCDUSB 14
|
||||||
|
#define HD44780_CT_I2C 15
|
||||||
|
|
||||||
// symbolic names for interface types
|
// symbolic names for interface types
|
||||||
#define IF_TYPE_UNKNOWN 0
|
#define IF_TYPE_UNKNOWN 0
|
||||||
|
|||||||
Reference in New Issue
Block a user