[Lcdproc] Zalman HD135/VlSys MPlay Blast driver
Sean Meiners
sean.lcdproc@ssttr.com
Mon Oct 8 16:11:02 2007
--Apple-Mail-4-951694002
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed
D'OH! A little too quick I guess. To make up for it I'm also adding
an updated version of my python script (I cleaned out some personal
notes and added some useful ones).
--Apple-Mail-4-951694002
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
x-unix-mode=0644;
name=mplay.cvs.patch
Content-Disposition: attachment;
filename=mplay.cvs.patch
? server/drivers/hd44780-mplay.c
? server/drivers/hd44780-mplay.h
Index: LCDd.conf
===================================================================
RCS file: /cvsroot/lcdproc/lcdproc/LCDd.conf,v
retrieving revision 1.113
diff -u -r1.113 LCDd.conf
--- LCDd.conf 25 Sep 2007 16:19:42 -0000 1.113
+++ LCDd.conf 8 Oct 2007 15:25:50 -0000
@@ -501,6 +501,37 @@
KeyMatrix_4_3=Down
KeyMatrix_4_4=Escape
+# Does the display have a fan controller?
+HaveFans=n
+
+# 'f' for Farenheit or 'c' for Celcius
+TemperatureScale=f
+
+# You can change the parameters for the fan controller below
+# The first set of parameters will use the first temperature sensor
+# and the first fan, the second set will use the second temperature
+# sensor and second fan, etc.
+# Note: only 2 fans & 2 sensors are currently supported in the mplay driver
+
+# Fan 1 & Sensor 1
+# The minimum temperature before the fan will turn on.
+# [default: 120f/50c]
+FanOn=120
+# The temperature the sensor must read before turning the fan off.
+# It is recommended that this be lower than FanOn to prevent the
+# fan from constantly cycling between on and off.
+# [default: 110f/45c]
+FanOff=110
+# The minimum allowable speed for the fan (range: 0-255).
+# Many fans will not spin at all if this value is too low.
+# [default: 140, this seems to work with most fans]
+FanMinSpeed=140
+
+# Fan 2 & Sensor 2
+# See above for explinations
+FanOn=120
+FanOff=110
+FanMinSpeed=140
## ICP A106 driver ##
Index: acinclude.m4
===================================================================
RCS file: /cvsroot/lcdproc/lcdproc/acinclude.m4,v
retrieving revision 1.87
diff -u -r1.87 acinclude.m4
--- acinclude.m4 5 Aug 2007 14:31:10 -0000 1.87
+++ acinclude.m4 8 Oct 2007 15:25:50 -0000
@@ -185,7 +185,7 @@
actdrivers=["$actdrivers glk"]
;;
hd44780)
- HD44780_DRIVERS="hd44780-hd44780-serial.o hd44780-hd44780-lis2.o"
+ HD44780_DRIVERS="hd44780-hd44780-serial.o hd44780-hd44780-lis2.o hd44780-hd44780-mplay.o"
if test "$ac_cv_port_have_lpt" = yes ; then
HD44780_DRIVERS="$HD44780_DRIVERS hd44780-hd44780-4bit.o hd44780-hd44780-ext8bit.o hd44780-lcd_sem.o hd44780-hd44780-winamp.o hd44780-hd44780-serialLpt.o"
fi
Index: docs/LCDd.8.in
===================================================================
RCS file: /cvsroot/lcdproc/lcdproc/docs/LCDd.8.in,v
retrieving revision 1.13
diff -u -r1.13 LCDd.8.in
--- docs/LCDd.8.in 5 Aug 2007 14:31:11 -0000 1.13
+++ docs/LCDd.8.in 8 Oct 2007 15:25:52 -0000
@@ -152,6 +152,9 @@
.B lis2
LIS2 from VLSystem (http://www.vlsys.co.kr), connected to USB
.TP
+.B mplay
+MPlay Blast from VLSystem (http://www.vlsys.co.kr), connected to USB
+.TP
.B bwctusb
USB-to-HD44780 converter by BWCT (http://www.bwct.de)
.TP
Index: docs/lcdproc-user/drivers/hd44780.docbook
===================================================================
RCS file: /cvsroot/lcdproc/lcdproc/docs/lcdproc-user/drivers/hd44780.docbook,v
retrieving revision 1.33
diff -u -r1.33 hd44780.docbook
--- docs/lcdproc-user/drivers/hd44780.docbook 8 Oct 2007 14:06:42 -0000 1.33
+++ docs/lcdproc-user/drivers/hd44780.docbook 8 Oct 2007 15:25:53 -0000
@@ -1561,6 +1561,18 @@
</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 modules <filename>ftdi_sio.ko</filename> that map the USB port to a serial port
+(<filename class="devicefile">/dev/ttyUSB<replaceable>x</replaceable></filename>).
+</para>
+
+</sect3>
+
<sect3 id="hd44780-los-panel">
<title>LCD on Serial panel device "los-panel"</title>
@@ -2104,6 +2116,7 @@
<arg choice="plain"><literal>bwctusb</literal></arg>
<arg choice="plain"><literal>lcd2usb</literal></arg>
<arg choice="plain"><literal>lis2</literal></arg>
+ <arg choice="plain"><literal>mplay</literal></arg>
<arg choice="plain"><literal>i2c</literal></arg>
</group>
</arg>
@@ -2174,6 +2187,10 @@
<entry>LIS2 from VLSystem (<ulink url="http://www.vlsys.co.kr"></ulink>)</entry>
</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>
<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>
</row>
Index: server/drivers/Makefile.am
===================================================================
RCS file: /cvsroot/lcdproc/lcdproc/server/drivers/Makefile.am,v
retrieving revision 1.74
diff -u -r1.74 Makefile.am
--- server/drivers/Makefile.am 25 Sep 2007 16:19:42 -0000 1.74
+++ server/drivers/Makefile.am 8 Oct 2007 15:25:54 -0000
@@ -75,7 +75,7 @@
glcdlib_SOURCES = lcd.h lcd_lib.h glcdlib.h glcdlib.c report.h
glk_SOURCES = lcd.h glk.c glk.h glkproto.c glkproto.h report.h
hd44780_SOURCES = lcd.h lcd_lib.h hd44780.h hd44780.c hd44780-drivers.h hd44780-low.h hd44780-charmap.h report.h adv_bignum.h
-EXTRA_hd44780_SOURCES = hd44780-4bit.c hd44780-4bit.h hd44780-ext8bit.c hd44780-ext8bit.h lcd_sem.c lcd_sem.h hd44780-serialLpt.c hd44780-serialLpt.h hd44780-serial.c hd44780-serial.h hd44780-winamp.c hd44780-winamp.h hd44780-bwct-usb.c hd44780-bwct-usb.h hd44780-lcd2usb.c hd44780-lcd2usb.h hd44780-lis2.c hd44780-lis2.h hd44780-i2c.c hd44780-i2c.h port.h lpt-port.h timing.h
+EXTRA_hd44780_SOURCES = hd44780-4bit.c hd44780-4bit.h hd44780-ext8bit.c hd44780-ext8bit.h lcd_sem.c lcd_sem.h hd44780-serialLpt.c hd44780-serialLpt.h hd44780-serial.c hd44780-serial.h hd44780-winamp.c hd44780-winamp.h hd44780-bwct-usb.c hd44780-bwct-usb.h hd44780-lcd2usb.c hd44780-lcd2usb.h hd44780-lis2.c hd44780-lis2.h hd44780-i2c.c hd44780-i2c.h port.h lpt-port.h timing.h hd44780-mplay.c hd44780-mplay.h
icp_a106_SOURCES = lcd.h lcd_lib.h icp_a106.c icp_a106.h report.h
imon_SOURCES = lcd.h lcd_lib.h imon.h imon.c report.h
Index: server/drivers/hd44780-drivers.h
===================================================================
RCS file: /cvsroot/lcdproc/lcdproc/server/drivers/hd44780-drivers.h,v
retrieving revision 1.16
diff -u -r1.16 hd44780-drivers.h
--- server/drivers/hd44780-drivers.h 4 Oct 2007 16:30:20 -0000 1.16
+++ server/drivers/hd44780-drivers.h 8 Oct 2007 15:25:54 -0000
@@ -19,6 +19,7 @@
#endif
#include "hd44780-serial.h"
#include "hd44780-lis2.h"
+#include "hd44780-mplay.h"
#ifdef HAVE_LIBUSB
# include "hd44780-bwct-usb.h"
# include "hd44780-lcd2usb.h"
@@ -49,6 +50,7 @@
{ "pertelian", hd_init_serial, "\tnone\n" },
/* End serial connectiontypes */
{ "lis2", hd_init_lis2, "\tnone\n" },
+ { "mplay", hd_init_mplay, "\tnone\n" },
#ifdef HAVE_LIBUSB
{ "bwctusb", hd_init_bwct_usb, "\tnone\n" },
{ "lcd2usb", hd_init_lcd2usb, "\tnone\n" },
Index: server/drivers/hd44780-low.h
===================================================================
RCS file: /cvsroot/lcdproc/lcdproc/server/drivers/hd44780-low.h,v
retrieving revision 1.22
diff -u -r1.22 hd44780-low.h
--- server/drivers/hd44780-low.h 4 Oct 2007 16:30:20 -0000 1.22
+++ server/drivers/hd44780-low.h 8 Oct 2007 15:25:54 -0000
@@ -31,6 +31,7 @@
/* Constants for userdefchar_mode */
#define NUM_CCs 8 /* number of custom characters */
+#define NUM_FANs 2
typedef enum {
standard, /* only char 0 is used for heartbeat */
@@ -51,6 +52,13 @@
const char *helpMsg;
} ConnectionMapping;
+typedef struct Fan {
+ int ontemp;
+ int offtemp;
+ int lowspeed;
+ int currentspeed;
+} Fan;
+
typedef struct driver_private_data {
unsigned int port;
@@ -119,6 +127,12 @@
int backlight_bit;
+ // Fan control
+ char have_fans;
+ char fan_temp_scale;
+ int fan_update_interval;
+ Fan fans[NUM_FANs];
+
// force full refresh of display
time_t nextrefresh;
int refreshdisplay; // When >0 make a full display update every <refreshdisplay> seconds
--Apple-Mail-4-951694002
Content-Transfer-Encoding: 7bit
Content-Type: text/x-python-script;
x-unix-mode=0755;
x-mac-creator=454D4178;
name=hd135.py
Content-Disposition: attachment;
filename=hd135.py
#!/usr/bin/python
import os
import sys
import termios
import tty
import time
from select import select
keymap = {
0x41: 'PwrOff',
0x55: 'PwrOn',
0x40: 'Movies',
0x46: 'Television',
0x45: 'Photos',
0x56: 'Music',
0x4d: '1',
0x4e: '2',
0x4f: '3',
0x50: '4',
0x51: '5',
0x52: '6',
0x53: '7',
0x03: '8',
0x07: '9',
0x4c: '0',
0x0a: 'Vol+',
0x0e: 'Vol-',
0x12: 'Ch+/Lang',
0x16: 'Ch-/Page',
0x0f: 'Guide',
0x0b: 'Back',
0x13: 'TV',
0x42: 'OK',
0x19: 'Up',
0x54: 'Left',
0x43: 'Right',
0x1d: 'Down',
0x1f: 'Exit/Click',
0x17: 'Task/Quick',
0x1b: 'Run/D.Click',
0x0d: 'Rew',
0x09: 'Play',
0x15: 'FFwd',
0x1a: 'Prev',
0x01: 'Stop',
0x1e: 'Next',
0x05: 'Pause',
0x4a: 'Mute',
0x47: 'Warp/Mouse',
0x11: 'Rec',
0x14: 'DVD/Zoom',
0x4b: 'Detail',
0x7e: '<repeat>',
}
b_______ = 0x00
b______X = 0x01
b_____X_ = 0x02
b_____XX = 0x03
b____X__ = 0x04
b____X_X = 0x05
b____XX_ = 0x06
b____XXX = 0x07
b___X___ = 0x08
b___X__X = 0x09
b___X_X_ = 0x0A
b___X_XX = 0x0B
b___XX__ = 0x0C
b___XX_X = 0x0D
b___XXX_ = 0x0E
b___XXXX = 0x0F
b__X____ = 0x10
b__X___X = 0x11
b__X__X_ = 0x12
b__X__XX = 0x13
b__X_X__ = 0x14
b__X_X_X = 0x15
b__X_XX_ = 0x16
b__X_XXX = 0x17
b__XX___ = 0x18
b__XX__X = 0x19
b__XX_X_ = 0x1A
b__XX_XX = 0x1B
b__XXX__ = 0x1C
b__XXX_X = 0x1D
b__XXXX_ = 0x1E
b__XXXXX = 0x1F
b_XXX___ = 0x38
b_XXXXXX = 0x3F
block1 = [ b_______,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b_______ ]
block2 = [ b__XXXXX,
b_______,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b_______ ]
block3 = [ b__XXXXX,
b__XXXXX,
b_______,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b_______ ]
block4 = [ b__XXXXX,
b__XXXXX,
b__XXXXX,
b_______,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b_______ ]
block5 = [ b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b_______,
b__XXXXX,
b__XXXXX,
b_______ ]
block6 = [ b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b_______,
b__XXXXX,
b_______ ]
block7 = [ b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b_______,
b_______ ]
block8 = [ b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b_______ ]
fd = os.open("/dev/ttyUSB0", os.O_RDWR)
attrs = [0, 1, 2, 3, 4, 5, [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ] ]
attrs = termios.tcgetattr(fd)
#c_iflag = 0
#c_oflag = 1
#c_cflag = 2
#c_lflag = 3
#ispeed = 4
#ospeed = 5
#cc = 6
# iflag
attrs[0] = attrs[0] & ~(termios.IGNBRK | termios.BRKINT | termios.PARMRK |
termios.ISTRIP | termios.INLCR | termios.IGNCR |
termios.ICRNL | termios.IXON)
# oflag
attrs[1] = attrs[1] & ~termios.OPOST
# lflag
attrs[3] = attrs[3] & ~(termios.ECHO | termios.ECHONL | termios.ICANON |
termios.ISIG | termios.IEXTEN)
# cflag
attrs[2] = attrs[2] & ~(termios.CSIZE | termios.PARENB | termios.CRTSCTS)
attrs[2] = attrs[2] | termios.CS8 | termios.CREAD | termios.CLOCAL
# control chars
attrs[6][termios.VMIN] = 1
attrs[6][termios.VTIME] = 3
# ispeed
attrs[4] = termios.B38400
# ospeed
attrs[5] = termios.B38400
termios.tcsetattr(fd, termios.TCSANOW, attrs)
def write(fd, v):
os.write(fd, chr(v))
def writeChr(fd, c):
os.write(fd, c)
def writeLn(fd, ln):
for i in range(0, min(len(ln), 20)):
writeChr(fd, ln[i])
time.sleep(0.000040)
def clear(fd):
write(fd, 0xA0)
time.sleep(0.000040)
def gotoXY(fd, x, y):
write(fd, 0)
write(fd, 0xA1+y)
write(fd, x)
write(fd, 0xA7)
time.sleep(0.000040)
def initFans(fd):
write(fd, 0)
write(fd, 0xA4)
write(fd, 0x7D)
def setFans(fd, fan1, fan2):
write(fd, 0)
write(fd, 0xAC)
write(fd, fan1)
write(fd, fan2)
time.sleep(0.000040)
def setChars(fd, chars):
write(fd, 0)
write(fd, 0xAD)
for char in chars:
for row in char:
write(fd, row)
time.sleep(0.000040)
def readTemp(fd):
# request the current temp
write(fd, 0)
write(fd, 0xAF)
time.sleep(0.000040)
res = select([fd], [], [])
if len(res[0]):
temp1 = -1
temp2 = -1
while temp2 == -1:
str = os.read(fd, 2)
if len(str) == 1:
if temp1 == -1:
temp1 = ord(str[0])
else:
temp2 = ord(str[0])
elif len(str) == 2:
temp1 = ord(str[0])
temp2 = ord(str[1])
else:
sys.stdout.write("Unexpected data during remp read: ")
for c in str:
sys.stdout.write( "0x%02x " % ord(c) )
sys.stdout.write("\n")
break
if temp2 != -1:
if 1: # farenheit
temp1 = (temp1 - 150) * 9 / 5 + 32
temp2 = (temp2 - 150) * 9 / 5 + 32
else: # celcius
temp1 = temp1 - 150
temp2 = temp2 - 150
return (temp1, temp2)
return None
# initialize the fan controller
initFans(fd)
# setup our custom chars
chars = [ block1, block2, block3, block4,
block5, block6, block7, block8 ]
setChars(fd, chars)
# clear the screen
clear(fd)
# display some test data
gotoXY(fd, 0, 0)
for i in range(8, 16):
write(fd, i)
writeLn(fd, "012345678901")
gotoXY(fd, 0, 1)
# 01234567890123456789
writeLn(fd, "ABCDEFGHIJKLMNOPQRST")
# let them see the test data
time.sleep(5)
lastTime = 0.0
FAN_ON = [120, 120]
FAN_OFF = [110, 110]
FAN_LOW = [140, 140]
fans = [FAN_LOW[0], FAN_LOW[1]]
# This is my config, yours is probably different
fanNames = ['CPU ', 'Case ']
tempNames = ['CPU ', 'Video ']
# useful if temp1 != fan1
fanTempMap = [0, 1]
while 1:
res = select([fd], [], [], 0.1)
if len(res[0]):
str = os.read(fd, 20)
if len(str) == 1:
val = ord(str[0])
if val in keymap:
print "%s (0x%02x)" % (keymap[val], val)
else:
print "<unknown> (0x%02x)" % (val)
else:
sys.stdout.write("Read: ")
for c in str:
sys.stdout.write( "0x%02x " % ord(c) )
sys.stdout.write("\n")
if lastTime + 1 < time.time():
lastTime = time.time()
# temp0 = cpu
# fan1 = case
# temp1 = video
# fan2 = top/cpu
temps = readTemp(fd)
if temps:
gotoXY(fd, 0, 0)
writeLn(fd, "%s%3d %s%3d" % ( tempNames[0], temps[0], tempNames[1], temps[1] ) )
for i in range(0, 2):
if fans[i] > 0 and temps[fanTempMap[i]] < FAN_OFF[i]:
fans[i] = 0
elif temps[fanTempMap[i]] >= FAN_ON[i]:
fans[i] = (temps[fanTempMap[i]] - FAN_ON[i]) * (255 - FAN_LOW[i]) / 100 + FAN_LOW[i]
gotoXY(fd, 0, 1)
writeLn(fd, "%s%3d %s%3d" % (fanNames[fanTempMap[0]],
fans[fanTempMap[0]],
fanNames[fanTempMap[1]],
fans[fanTempMap[1]]) )
setFans(fd, fans[0], fans[1])
time.sleep(0.010)
fd.close()
--Apple-Mail-4-951694002
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed
On Oct 8, 2007, at 8:43 AM, Peter Marschall wrote:
> Hi,
>
> Wow that was quick !
> But did you forget to attach the patch ?
>
> Peter
>
>
> On Monday, 8. October 2007, you wrote:
>> Attached is a patch against current CVS. Fortunately for me my
>> previous patch applied with very little difficulty. I've also added
>> entries to the LCDd man page & docbook as requested. However, I would
>> like to see the fan controller code left in. I intentionally put it
>> behind a config flag ('HaveFans') in LCDd.conf so it could be
>> disabled if either a) the user didn't want to use the fan controller
>> or b) their device didn't support it. I understand that there is no
>> simple way to add fan control to the client language, that's why I
>> made it a set of config directives so people (like me) who wanted to
>> use all the capabilities of their device could get a little closer to
>> that goal (you still can't use the remote control feature, but the
>> python script I sent previous shows how).
>>
>> On Oct 8, 2007, at 2:20 AM, Peter Marschall wrote:
>>> Hi Sean,
>>>
>>> On Monday, 8. October 2007, Sean Meiners wrote:
>>>> In case anyone is interested, I've written a hd44780 driver for the
>>>> display that comes with the Zalman HD135 case (which appears to
>>>> be a
>>>> VlSystem MPlay Blast without the 'keys'). It's very similar to the
>>>> lis2 driver with 2 important differences. Its preferred port
>>>> speed is
>>>> 38400 and it uses a rather different method for setting up custom
>>>> characters. This display also has two thermal sensors and fan
>>>> controllers which I've also enabled via config directives in
>>>> LCDd.conf. I haven't tried to get LCDd to publish the
>>>> temperature or
>>>> fan speed data, but you can configure it to do sensible things. The
>>>> patch (against 0.5.2) is attached below as well as a python
>>>> script I
>>>> used to help debug the protocol.
>>>
>>> Although patch looks quite interesting, I currently have a few
>>> issues
>>> with it that prevent me from adding it to the CVS immediately.
>>>
>>> 1) It is based against 0.5.2
>>> Would you mind to rebase it against current CVS ?
>>> Should not be too hard I think.
>>>
>>> 2) It misses documentation.
>>> Would you mind to update the files
>>> - docs/LCDd.8.in
>>> - docs/lcdproc-user/drivers/hd44780.docbook
>>> to tell about the new connection type.
>>> Please see
>>> http://lcdproc.sourceforge.net/docs/current-
>>> dev.html#documentation
>>> for a general guideline about docs for new drivers in LCDproc
>>> (since your patch is "only" a ConnectionType for HD44780,
>>> changing the two files above is sufficient.)
>>>
>>> 3) With the fan control it contains a feature that is very specific
>>> to exactly this hardware and that currently cannot be used with
>>> LCDproc's client language.
>>> In order to keep the driver slim, I suggest having the fan
>>> control part
>>> as a separate patch that goes into contrib.
>>>
>>> With these issues cleared, I think the driver can go int CVS.
>>> Thanks in advance for fixing them.
>>>
>>> Thanks for supporting LCDproc
>>> Peter
>>>
>>> --
>>> Peter Marschall
>>> peter@adpm.de
>>> _______________________________________________
>>> LCDproc mailing list
>>> LCDproc@lists.omnipotent.net
>>> http://lists.omnipotent.net/mailman/listinfo/lcdproc
>>
>> The person who said it can't be done is always interrupted by the one
>> who just did it.
>
>
>
> --
> Peter Marschall
> peter@adpm.de
> _______________________________________________
> LCDproc mailing list
> LCDproc@lists.omnipotent.net
> http://lists.omnipotent.net/mailman/listinfo/lcdproc
The person who said it can't be done is always interrupted by the one
who just did it.
--Apple-Mail-4-951694002--