- update drivers to use new API

(get rid of those pseudo options named 'Arguments' in the config file)
- replace printf / printf calls by debug / report calls in some drivers
- sort and extend LCDd.conf
This commit is contained in:
marschap
2005-01-29 18:49:29 +00:00
parent c82e37cd70
commit b3230cf90f
34 changed files with 550 additions and 946 deletions
+189 -192
View File
@@ -21,71 +21,58 @@
# If -d is specified on the command line, the Driver= options in the # If -d is specified on the command line, the Driver= options in the
# config file are ignored. # config file are ignored.
# #
# The drivers can read their own options from the config file, but some of # The drivers read their own options from the respective sections.
# them don't do this yet. They expect 'command-line'-format parameters that
# were previously placed on the command line. These parameters can be
# given to the driver in the following way:
#
# Arguments="place arguments here"
#
# The arguments between the quotes are passed to the driver.
# As said before these are the same arguments that the driver would have
# been passed under the old command line format of
#
# -d <driver> "<driverargs>"
#
# Note that the -d option still works, but not allows driverargs anymore.
## Server section with all kinds of settings for the LCDd server ##
[server] [server]
# Server section with all kinds of settings for the LCDd server
# Tells the server to load the given drivers. Multiple lines can be given.
# The name of the driver is exactly the same as the name of the driver
# module that is to be loaded, including the case of the letters !
# (That is: unless a file= option is given in the driver section)
Driver=curses Driver=curses
#Driver=hd44780 #Driver=hd44780
#Driver=IOWarrior #Driver=IOWarrior
#Driver=MtxOrb #Driver=MtxOrb
#Driver=CFontz633 #Driver=CFontz633
#Driver=CwLnx #Driver=CwLnx
#
# Tells the server to load the given drivers. Multiple lines can be given.
# The name of the driver is exactly the same as the name of the driver
# module that is to be loaded, including the case of the letters !
# (That is: unless a file= option is given in the driver section)
Bind=127.0.0.1
# Tells the driver to bind to the given interface # Tells the driver to bind to the given interface
Bind=127.0.0.1
Port=13666
# Listen on this specified port; defaults to 13666. # Listen on this specified port; defaults to 13666.
Port=13666
#ReportLevel=3
# Sets the reporting level; defaults to 2 (warnings and errors only). # Sets the reporting level; defaults to 2 (warnings and errors only).
#ReportLevel=3
#ReportToSyslog=yes
# Should we report to syslog instead of stderr ? Default: no # Should we report to syslog instead of stderr ? Default: no
#ReportToSyslog=yes
WaitTime=5
# Sets the default time in seconds to displays a screen. # Sets the default time in seconds to displays a screen.
WaitTime=5
User=nobody
# User to run as. LCDd will drop its root priviledges, # User to run as. LCDd will drop its root priviledges,
# if any, and run as this user instead. # if any, and run as this user instead.
User=nobody
#ServerScreen=no
# If yes, the the serverscreen will be rotated as a usual info screen. If no, # If yes, the the serverscreen will be rotated as a usual info screen. If no,
# it will be a background screen, only visible when no other screens are # it will be a background screen, only visible when no other screens are
# active. # active.
#ServerScreen=no
#Foreground=no
# The server will stay in the foreground if set to true. # The server will stay in the foreground if set to true.
#Foreground=no
DriverPath=server/drivers/
# Where can we find the driver modules ? # Where can we find the driver modules ?
# IMPORTANT: Make sure to change this setting to reflect your # IMPORTANT: Make sure to change this setting to reflect your
# specific setup! Otherwise LCDd won't be able to find # specific setup! Otherwise LCDd won't be able to find
# the driver modules and will thus not be able to # the driver modules and will thus not be able to
# function properly. # function properly.
# NOTE: Always place a slash as last character ! # NOTE: Always place a slash as last character !
DriverPath=server/drivers/
# The "...Key=" lines define what the server does with keypresses that # The "...Key=" lines define what the server does with keypresses that
# don't go to any client. # don't go to any client.
@@ -107,8 +94,8 @@ NextScreenKey=Right
## The menu section. The menu is an internal LCDproc client. ##
[menu] [menu]
# The menu section. The menu is an internal LCDproc client.
# You can configure what keys the menu should use. Note that only the menukey # You can configure what keys the menu should use. Note that only the menukey
# will be reserved exclusively, the others in shared mode. # will be reserved exclusively, the others in shared mode.
@@ -124,87 +111,83 @@ DownKey=Down
#DownKey=Down #DownKey=Down
# Driver sections are below this line, in alphabetical order
### Driver sections are below this line, in alphabetical order ###
## EMAC BayRAD driver ##
[bayrad] [bayrad]
# EMAC BayRAD driver
Arguments="fill in here" # Select the output device to use [default: /dev/lcd]
Device=/dev/lcd
# -d --device Select the output device to use [/dev/lcd] # Set the communication speed [default: 9600; legal: 1200, 2400, 9600, 19200]
# -t --type Select the LCD type (size) [20x2] Speed=9600
# -s --speed Set the communication speed [19200]
# -h --help Show this help information
## CrystalFontz driver (for CF632 & CF634) ##
[CFontz] [CFontz]
# CrystalFontz driver
# Use this driver for CF632 and CF634.
# Select the output device to use [/dev/lcd] # Select the output device to use [default: /dev/lcd]
Device=/dev/ttyS0 Device=/dev/ttyS0
# Select the LCD type (size) [20x4] # Select the LCD size [default: 20x4]
Size=20x4 Size=20x4
# Set the initial contrast [140] # Set the initial contrast [default: 140; legal: 0 - 1000]
Contrast=140 Contrast=140
# Set the initial brightness [255] # Set the initial brightness [default: 255; legal: 0 - 255]
Brightness=255 Brightness=255
# Set the initial off-brightness [0] # Set the initial off-brightness [default: 0; legal: 0 - 255]
# This value is used when the display is normally # This value is used when the display is normally
# switched off in case LCDd is inactive # switched off in case LCDd is inactive
OffBrightness=0 OffBrightness=0
# Set the communication speed [9600] # Set the communication speed [default: 9600; legal: 1200, 2400, 9600 or 19200]
# possible values: 1200, 2400, 9600
Speed=9600 Speed=9600
# Set the firmware version (New means >= 2.0) [no] # Set the firmware version (New means >= 2.0) [default: no; legal: yes, no]
NewFirmware=no NewFirmware=no
# Reinitialize the LCD's BIOS [no] # Reinitialize the LCD's BIOS [default: no; legal: yes, no]
# normally you shouldn't need this # normally you shouldn't need this
Reboot=no Reboot=no
[CFontz633]
# CrystalFontz633 driver
# Use this driver only for CF633.
# Select the output device to use [/dev/lcd] ## CrystalFontz633 driver (for CF633 only) ##
[CFontz633]
# Select the output device to use [default: /dev/lcd]
Device=/dev/ttyS0 Device=/dev/ttyS0
# Select the LCD type (size) [20x4] # Select the LCD type (size) [default: 20x4]
Size=16x2 Size=16x2
# Set the initial contrast [140] # Set the initial contrast [default: 140; legal: 0 - 1000]
Contrast=140 Contrast=140
# Set the initial brightness [100] # Set the initial brightness [default: 100; legal: 0 - 255]
# Brightness hardware value is between 0 and 100.
Brightness=100 Brightness=100
# Set the initial off-brightness [0] # Set the initial off-brightness [default: 0; legal: 0 - 255]
# This value is used when the display is normally # This value is used when the display is normally
# switched off in case LCDd is inactive # switched off in case LCDd is inactive
OffBrightness=50 OffBrightness=50
# Set the communication speed [9600] # Set the communication speed [default: 9600; legal: 1200, 2400, 9600, 19200, 115200]
# possible values: 19200
Speed=19200 Speed=19200
# Set the firmware version (New means >= 2.0) [no] # Set the firmware version (New means >= 2.0) [default: no; legal: yes, no]
# Currently this flag is not in use, there is no such thing as NewFirmware. ;=) # Currently this flag is not in use, there is no such thing as NewFirmware. ;=)
NewFirmware=no #NewFirmware=no
# Reinitialize the LCD's BIOS [no] # Reinitialize the LCD's BIOS [default: no; legal: yes, no]
# I want to reboot the LCD to make sure we start from a known state # I want to reboot the LCD to make sure we start from a known state
Reboot=yes Reboot=yes
## Curses driver ##
[curses] [curses]
# Curses driver
# color settings # color settings
# foreground color [blue] # foreground color [default: blue]
foreground=blue foreground=blue
# background color [cyan] # background color [default: cyan]
background=cyan background=cyan
# backlight color [red] # backlight color [default: red]
backlight=red backlight=red
# display size [20x4] # display size [default: 20x4]
size=20x4 size=20x4
# What position (X,Y) to start the left top corner at... # What position (X,Y) to start the left top corner at...
@@ -212,21 +195,22 @@ size=20x4
topleftx=7 topleftx=7
toplefty=7 toplefty=7
[CwLnx]
# Cwlinux driver
# Select the output device to use [/dev/lcd]
## Cwlinux driver ##
[CwLnx]
# Select the output device to use [default: /dev/lcd]
#Device=/dev/ttyS0 #Device=/dev/ttyS0
Device=/dev/ttyUSB0 Device=/dev/ttyUSB0
# Select the LCD type (size) [20x4] # Select the LCD size [default: 20x4]
Size=20x4 Size=20x4
# Set the communication speed [9600] # Set the communication speed [default: 19200; legal: 9600, 19200]
# possible values: 9600, 19200
Speed=19200 Speed=19200
# Reinitialize the LCD's BIOS [no] # Reinitialize the LCD's BIOS [default: no; legal: yes, no]
# normally you shouldn't need this # normally you shouldn't need this
Reboot=no Reboot=no
@@ -242,7 +226,6 @@ Keypad=yes
# You can leave those unchanged if you have a standard keypad. # You can leave those unchanged if you have a standard keypad.
# You can change it if you want to report other keystrings or have a non # You can change it if you want to report other keystrings or have a non
# standard keypad. # standard keypad.
# KeyMap_A=Up # KeyMap_A=Up
# KeyMap_B=Down # KeyMap_B=Down
# KeyMap_C=Left # KeyMap_C=Left
@@ -255,64 +238,67 @@ Keypad=yes
#keypad_test_mode=yes #keypad_test_mode=yes
## Matrix Orbital GLK driver ##
[glk] [glk]
# Matrix Orbital GLK driver
Arguments="-d /dev/ttyS0 -s 9600" # select the serial device to use [default: /dev/lcd]
Device=/dev/lcd
# -d, --device select the serial device to use [/dev/lcd] # set the initial contrast value [default: 560; legal: 0 - 1000]
# -c, --contrast set the initial contrast value [140] Contrast=560
# -s, --speed set the serial port speed [19200]
# -h, --help display this help text # set the serial port speed [default: 19200; legal: 9600, 19200, 38400]
Speed=19200
## Hitachi HD44780 driver ##
[hd44780] [hd44780]
# Hitachi HD44780 driver
Port=0x378
# Port where the LPT is. Usual values are 0x278, 0x378 and 0x3BC # Port where the LPT is. Usual values are 0x278, 0x378 and 0x3BC
Port=0x378
ConnectionType=4bit
# Select what type of connection. See documentation for types. # Select what type of connection. See documentation for types.
ConnectionType=4bit
Keypad=no
# If you have a keypad connected. # If you have a keypad connected.
# You may also need to configure the keypad layout further on in this file. # You may also need to configure the keypad layout further on in this file.
Keypad=no
Backlight=no
# If you have a switchable backlight. # If you have a switchable backlight.
Backlight=no
Outputport=no
# If you have the additional output port ("bargraph") and you want to # If you have the additional output port ("bargraph") and you want to
# be able to control it with the lcdproc OUTPUT command # be able to control it with the lcdproc OUTPUT command
Outputport=no
#Lastline=true
# Specifies if the last line is pixel addressable or it controls an # Specifies if the last line is pixel addressable or it controls an
# underline effect. Default: true (pixel addressable) # underline effect. [default: true (= pixel addressable); legal: yes, no]
#Lastline=true
Size=20x4
# Specifies the size of the LCD. # Specifies the size of the LCD.
# In case of multiple combined displays, this should be the total size. # In case of multiple combined displays, this should be the total size.
Size=20x4
#vspan=2,2
# For multiple combined displays: how many lines does each display have. # For multiple combined displays: how many lines does each display have.
# Vspan=2,2 means both displays have 2 lines. # Vspan=2,2 means both displays have 2 lines.
#vspan=2,2
#ExtendedMode=yes
# If you have a KS0073 or an other 'almost HD44780-compatible', set this # If you have a KS0073 or an other 'almost HD44780-compatible', set this
# flag to get into extended mode (4-line linear). # flag to get into extended mode (4-line linear).
# This flag is NOT the old obsolete Extended option. # This flag is NOT the old obsolete Extended option.
#ExtendedMode=yes
#DelayMult=2
# If your display is slow and cannot keep up with the flow of data from # If your display is slow and cannot keep up with the flow of data from
# LCDd, garbage can appear on the LCDd. Set this delay factor to 2 or 4 # LCDd, garbage can appear on the LCDd. Set this delay factor to 2 or 4
# to increase the delays. Default: 1. # to increase the delays. Default: 1.
#DelayMult=2
DelayBus=true
# You can reduce the inserted delays by setting this to false. # You can reduce the inserted delays by setting this to false.
# On fast PCs it is possible your LCD does not respond correctly. # On fast PCs it is possible your LCD does not respond correctly.
# Default: true. # Default: true.
DelayBus=true
# If you have a keypad you can assign keystrings to the keys. # If you have a keypad you can assign keystrings to the keys.
# See documentation for used terms and how to wire it. # See documentation for used terms and how to wire it.
@@ -320,7 +306,6 @@ DelayBus=true
# KeyDirect_4=Enter # KeyDirect_4=Enter
# For matrix keys use the X and Y coordinates of the key: # For matrix keys use the X and Y coordinates of the key:
# KeyMatrix_1_3=Enter # KeyMatrix_1_3=Enter
KeyMatrix_4_1=Enter KeyMatrix_4_1=Enter
KeyMatrix_4_2=Up KeyMatrix_4_2=Up
KeyMatrix_4_3=Down KeyMatrix_4_3=Down
@@ -328,7 +313,13 @@ KeyMatrix_4_4=Escape
# Code Mercenaries IO-Warrior drivr ## ICP A106 driver ##
[icp_a106]
Device=/dev/ttyS1
## Code Mercenaries IO-Warrior driver ##
[IOWarrior] [IOWarrior]
# display dimensions # display dimensions
@@ -339,61 +330,56 @@ Size=20x4
#SerialNumber=00000674 #SerialNumber=00000674
# Specifies if the last line is pixel addressable or it controls an # Specifies if the last line is pixel addressable or it controls an
# underline effect. Default: true (pixel addressable) # underline effect. [default: true (= pixel addressable); legal: yes, no]
#Lastline=true #Lastline=true
## IrMan driver ##
[IrMan] [IrMan]
#IrMan driver
#if in trouble with IrMan, try Lirc emulator for IrMan #if in trouble with IrMan, try Lirc emulator for IrMan
Arguments="fill in here" # Select the input device to use
#Device=/dev/irman
# -d --device Select the input device to use # Select the configuration file to use
# -c --config Select the configuration file to use #Config=/etc/irman.cfg
# -h --help Show this help information
## Joystick driver ##
[joy] [joy]
# Joystick driver
Arguments="-d /dev/js0" # Select the input device to use [default: /dev/js0]
Device=/dev/js0
# -d --device Select the input device to use [/dev/js0] # Modify the axis mapa [default: EFGHIJKLMNOPQRST]
# -a --axes Modify the axis map #AxisMap=EFGHIJKLMNOPQRST
# -b --buttons Modify the button map
# -h --help Show this help information # Modify the button map [default: BDACEFGHIJKLMNOP]
#ButtonMap=BDACEFGHIJKLMNOP
## LB216 driver ##
[lb216] [lb216]
# LB216 driver
Arguments="-d /dev/ttyS0 -s 9600" # Select the output device to use [default: /dev/lcd]
Device=/dev/lcd
# -d --device Select the output device to use [/dev/lcd] # Set the initial brightness [default: 255; legal: 0 - 255]
# -t --type Select the LCD type (size) [16x2] Brightness=255
# -b --brightness Set the initial brightness [255]
# -s --speed Set the communication speed [9600]
# -r --reboot Reinitialize the LCD's BIOS
# -h --help Show this help information;
# Set the communication speed [default: 19200; legal: 2400, 9600]
Speed=9600
# Reinitialize the LCD's BIOS [default: no; legal: yes, no]
[mtc_s16209x] Reboot=no
# MTC-S16209x driver
Arguments="-d /dev/ttyS0"
# -d --device Select the output device to use [/dev/lcd]
# -h --help Show this help information;
## LCDM001 driver ##
[lcdm001] [lcdm001]
# LCDM001 driver
Device=/dev/ttyS1 Device=/dev/ttyS1
@@ -406,7 +392,6 @@ Device=/dev/ttyS1
# BackKey Back(Go to previous screen) Up/Left # BackKey Back(Go to previous screen) Up/Left
# ForwardKey Forward(Go to next screen) Down/Right # ForwardKey Forward(Go to next screen) Down/Right
# MainMenuKey Open main menu Exit/Cancel # MainMenuKey Open main menu Exit/Cancel
PauseKey=LeftKey PauseKey=LeftKey
BackKey=UpKey BackKey=UpKey
ForwardKey=DownKey ForwardKey=DownKey
@@ -417,56 +402,72 @@ MainMenuKey=RightKey
## HNE LCTerm driver ##
[lcterm] [lcterm]
# HNE LCTerm driver
Device=/dev/ttyS1 Device=/dev/ttyS1
size=16x2 size=16x2
[icp_a106] ## LIRC input driver ##
# ICP A106 driver [lirc]
# Specify an alternative location of the lircrc file [default: ~/.lircrc]
#lircrc=/etc/lircrc.lcdproc
# Must be the same as in your lircrc
#prog=lcdd
## MSI MS-6931 driver for displays in 1HU servers ##
[ms6931]
# device to use [default: /dev/ttyS1]
Device=/dev/ttyS1 Device=/dev/ttyS1
# display size [default: 16x2]
#Size=16x2
[lirc]
# LIRC input driver
#lircrc=/etc/lircrc.lcdproc
# Specify an alternative location of the lircrc file, which is
# normally ~/.lircrc
#prog=lcdd
# Must be the same as in your lircrc
## MTC-S16209x driver ##
[mtc_s16209x]
# Select the output device to use [default: /dev/lcd]
Device=/dev/lcd
# Set the initial brightness [default: 255; legal: 0 - 255]
Brightness=255
# Reinitialize the LCD's BIOS [default: no; legal: yes, no]
Reboot=no
## Matrix Orbital driver ##
[MtxOrb] [MtxOrb]
# Matrix Orbital driver
# Select the output device to use [/dev/lcd] # Select the output device to use [default: /dev/lcd]
device=/dev/ttyS0 device=/dev/ttyS0
# Set the display size [20x4] # Set the display size [default: 20x4]
size=20x4 size=20x4
# Switch on the backlight? [yes] # Switch on the backlight? [default: yes]
# NOTE: The driver will ignore this if the display # NOTE: The driver will ignore this if the display is a vfd or vkd
# is a vfd or vfd as they crash if the backlight # as they crash if the backlight is turned off
# is turned off
enablebacklight=yes enablebacklight=yes
# Set the initial contrast [140] # Set the initial contrast [default: 140]
# NOTE: The driver will ignore this if the display # NOTE: The driver will ignore this if the display
# is a vfd or vfd as they don't have this feature # is a vfd or vkd as they don't have this feature
contrast=800 contrast=800
# Set the communication speed [19200] # Set the communication speed [default: 19200; legal: 1200, 2400, 9600, 19200]
speed=19200 speed=19200
# Set the display type [lcd] # Set the display type [default: lcd; legal: lcd, lkd, vfd, vkd]
# Possible settings: lcd, lkd, vfd, vkd
type=lkd type=lkd
# The following table translate from MtxOrb Key to Logical Key. # The following table translate from MtxOrb Key to Logical Key.
@@ -484,81 +485,77 @@ EscapeKey=F
# LCDd. LCDd will output all characters it receives. # LCDd. LCDd will output all characters it receives.
# Afterwards you can modify the settings above and set # Afterwards you can modify the settings above and set
# keypad_set_mode to no again. # keypad_set_mode to no again.
keypad_test_mode=no keypad_test_mode=no
## Seiko Epson 1330 driver ##
[sed1330] [sed1330]
# Seiko Epson 1330 driver
# Port where the LPT is. Common values are 0x278, 0x378 and 0x3BC
Port=0x378 Port=0x378
# Port where the LPT is. Usual values are 0x278, 0x378 and 0x3BC
# Type of LCD module (legal: G321D, G121C, G242C, G191D, G2446)
# Note: G321D is the only one that is tested currently.
Type=G321D Type=G321D
#Type=G121C
#Type=G242C
# Type of LCD module. G321D is the only one that is tested currently.
## Seiko Epson 1520 driver ##
[sed1520] [sed1520]
# Seiko Epson 1520 driver
Arguments="-p 0x278" # Port where the LPT is. Usual values are 0x278, 0x378 and 0x3BC
Port=0x378
# -p n --port n Select the output device to use port n
# -h --help Show this help information
## stv5730 driver ##
[stv5730] [stv5730]
# stv5730 driver
Arguments="fill in here" # Port the device is connectoed to [default: 0x378]
Port=0x378
# -p n --port n Select the output device to use port n
# -h --help Show this help information
## SVGAlib driver ##
[svgalib] [svgalib]
# SVGAlib driver
# No options. # No options.
# You should of course have your svgalib configured correctly. # You should of course have your svgalib configured correctly.
[T6963] ## Text driver ##
# Toshiba T6963 driver
#Port=0x378
#Size=20x6
#ECPlpt=on # use bidirectional mode or not
[text] [text]
# Text driver # Set the display size [default: 20x4]
# Set the display size [20x4]
size=20x4 size=20x4
## Toshiba T6963 driver ##
[t6963]
# set display size [default: 20x6]
Size=20x6
# port to use [default: 0x378; legal: 0x200 - 0x400]
Port=0x378
# Is ECP mode on? [default: yes; legal: yes, no]
#ECPlpt=yes
# Use graphic? [default: no; legal: yes, no]
#graphic=no
## Wirz SLI LCD driver ##
[Wirz-sli] [Wirz-sli]
# Wirz SLI LCD driver
Arguments="fill in here" # Select the output device to use [default: /dev/lcd]
Device=/dev/lcd
# -d --device Select the output device to use [/dev/lcd] # Set the communication speed [default: 19200; legal: 1200, 2400, 9600, 19200, 38400, 57600, 115200]
# -s --speed Set the communication speed [19200] Speed=19200
# -h --help Show this help information
# EOF
[ms6931]
# MSI MS-6931 driver for displays in 1HU servers
Device=/dev/ttyS1
#Size=16x2
+3 -20
View File
@@ -62,29 +62,12 @@ doing here.
</warning> </warning>
<para> <para>
The drivers can read their own options from the config file, but most of The drivers read their own options from the config file.
them don't do this yet. They expect 'command-line'-format parameters that For this purpose they use the config sections that are named like the driver.
were previously placed on the command line. These parameters can be
given to the driver in the following way:
</para>
<example>
<title><filename>LCDd.conf</filename>: Compatibility mode for drivers written for 0.4.1</title>
<programlisting>
Arguments="place arguments here"
</programlisting>
</example>
<para>
The arguments between the quotes are passed to the driver.
As said before these are the same arguments that would have
been passed to the driver using the old command line format of
</para> </para>
<para> <para>
<command>LCDd -d driver "driverargs"</command> <command>LCDd -d driver</command>
</para> </para>
<note> <note>
+3 -3
View File
@@ -123,21 +123,21 @@ CFontz_init (Driver * drvthis, char *args)
if (0<=drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST) && drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST) <= 1000) { if (0<=drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST) && drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST) <= 1000) {
contrast = drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST); contrast = drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST);
} else { } else {
report (RPT_WARNING, "CFontz_init: Contrast must between 0 and 1000. Using default value.\n"); report (RPT_WARNING, "CFontz_init: Contrast must be between 0 and 1000. Using default value.\n");
} }
/*Which backlight brightness*/ /*Which backlight brightness*/
if (0<=drvthis->config_get_int ( drvthis->name , "Brightness" , 0 , DEFAULT_BRIGHTNESS) && drvthis->config_get_int ( drvthis->name , "Brightness" , 0 , DEFAULT_BRIGHTNESS) <= 255) { if (0<=drvthis->config_get_int ( drvthis->name , "Brightness" , 0 , DEFAULT_BRIGHTNESS) && drvthis->config_get_int ( drvthis->name , "Brightness" , 0 , DEFAULT_BRIGHTNESS) <= 255) {
brightness = drvthis->config_get_int ( drvthis->name , "Brightness" , 0 , DEFAULT_BRIGHTNESS); brightness = drvthis->config_get_int ( drvthis->name , "Brightness" , 0 , DEFAULT_BRIGHTNESS);
} else { } else {
report (RPT_WARNING, "CFontz_init: Brightness must between 0 and 255. Using default value.\n"); report (RPT_WARNING, "CFontz_init: Brightness must be between 0 and 255. Using default value.\n");
} }
/*Which backlight-off "brightness"*/ /*Which backlight-off "brightness"*/
if (0<=drvthis->config_get_int ( drvthis->name , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS) && drvthis->config_get_int ( drvthis->name , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS) <= 255) { if (0<=drvthis->config_get_int ( drvthis->name , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS) && drvthis->config_get_int ( drvthis->name , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS) <= 255) {
offbrightness = drvthis->config_get_int ( drvthis->name , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS); offbrightness = drvthis->config_get_int ( drvthis->name , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS);
} else { } else {
report (RPT_WARNING, "CFontz_init: OffBrightness must between 0 and 255. Using default value.\n"); report (RPT_WARNING, "CFontz_init: OffBrightness must be between 0 and 255. Using default value.\n");
} }
+3 -3
View File
@@ -149,21 +149,21 @@ CFontz633_init (Driver * drvthis, char *args)
if (0<=drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST) && drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST) <= 1000) { if (0<=drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST) && drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST) <= 1000) {
contrast = drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST); contrast = drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST);
} else { } else {
report (RPT_WARNING, "CFontz633_init: Contrast must between 0 and 1000. Using default value.\n"); report (RPT_WARNING, "CFontz633_init: Contrast must be between 0 and 1000. Using default value.\n");
} }
/* Which backlight brightness */ /* Which backlight brightness */
if (0<=drvthis->config_get_int ( drvthis->name , "Brightness" , 0 , DEFAULT_BRIGHTNESS) && drvthis->config_get_int ( drvthis->name , "Brightness" , 0 , DEFAULT_BRIGHTNESS) <= 100) { if (0<=drvthis->config_get_int ( drvthis->name , "Brightness" , 0 , DEFAULT_BRIGHTNESS) && drvthis->config_get_int ( drvthis->name , "Brightness" , 0 , DEFAULT_BRIGHTNESS) <= 100) {
brightness = drvthis->config_get_int ( drvthis->name , "Brightness" , 0 , DEFAULT_BRIGHTNESS); brightness = drvthis->config_get_int ( drvthis->name , "Brightness" , 0 , DEFAULT_BRIGHTNESS);
} else { } else {
report (RPT_WARNING, "CFontz633_init: Brightness must between 0 and 100. Using default value.\n"); report (RPT_WARNING, "CFontz633_init: Brightness must be between 0 and 100. Using default value.\n");
} }
/* Which backlight-off "brightness" */ /* Which backlight-off "brightness" */
if (0<=drvthis->config_get_int ( drvthis->name , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS) && drvthis->config_get_int ( drvthis->name , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS) <= 100) { if (0<=drvthis->config_get_int ( drvthis->name , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS) && drvthis->config_get_int ( drvthis->name , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS) <= 100) {
offbrightness = drvthis->config_get_int ( drvthis->name , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS); offbrightness = drvthis->config_get_int ( drvthis->name , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS);
} else { } else {
report (RPT_WARNING, "CFontz633_init: OffBrightness must between 0 and 100. Using default value.\n"); report (RPT_WARNING, "CFontz633_init: OffBrightness must be between 0 and 100. Using default value.\n");
} }
+3 -3
View File
@@ -195,7 +195,7 @@ else
if ((0>=tmp) && (tmp<=1000)) { if ((0>=tmp) && (tmp<=1000)) {
contrast = tmp; contrast = tmp;
} else { } else {
report (RPT_WARNING, "CFontz633_init: Contrast must between 0 and 1000. Using default value.\n"); report (RPT_WARNING, "CFontz633_init: Contrast must be between 0 and 1000. Using default value.\n");
} }
/* Which backlight brightness */ /* Which backlight brightness */
@@ -204,7 +204,7 @@ else
if ((0>=tmp) && (tmp<=100)) { if ((0>=tmp) && (tmp<=100)) {
brightness = tmp; brightness = tmp;
} else { } else {
report (RPT_WARNING, "CFontz633_init: Brightness must between 0 and 100. Using default value.\n"); report (RPT_WARNING, "CFontz633_init: Brightness must be between 0 and 100. Using default value.\n");
} }
/* Which backlight-off "brightness" */ /* Which backlight-off "brightness" */
@@ -213,7 +213,7 @@ else
if ((0<=tmp) && (tmp<=100)) { if ((0<=tmp) && (tmp<=100)) {
offbrightness = tmp; offbrightness = tmp;
} else { } else {
report (RPT_WARNING, "CFontz633_init: OffBrightness must between 0 and 100. Using default value.\n"); report (RPT_WARNING, "CFontz633_init: OffBrightness must be between 0 and 100. Using default value.\n");
} }
+3 -3
View File
@@ -545,7 +545,7 @@ int CwLnx_init(Driver * drvthis, char *args)
/* Which size */ /* Which size */
strncpy(size, drvthis->config_get_string(drvthis->name, "Size", 0, DEFAULT_SIZE), sizeof(size)); strncpy(size, drvthis->config_get_string(drvthis->name, "Size", 0, DEFAULT_SIZE), sizeof(size));
size[sizeof(size) - 1] = 0; size[sizeof(size) - 1] = 0;
if (sscanf(size, "%dx%d", &w, &h) != 2 if ((sscanf(size, "%dx%d", &w, &h) != 2)
|| (w <= 0) || (w > LCD_MAX_WIDTH) || (w <= 0) || (w > LCD_MAX_WIDTH)
|| (h <= 0) || (h > LCD_MAX_HEIGHT)) { || (h <= 0) || (h > LCD_MAX_HEIGHT)) {
report(RPT_WARNING, "CwLnx: Cannot read size: %s. Using default value.\n", size); report(RPT_WARNING, "CwLnx: Cannot read size: %s. Using default value.\n", size);
@@ -586,13 +586,13 @@ int CwLnx_init(Driver * drvthis, char *args)
/* do we have a keypad? */ /* do we have a keypad? */
if (drvthis->config_get_bool( drvthis->name , "Keypad" , 0 , 0)) { if (drvthis->config_get_bool( drvthis->name , "Keypad", 0, 0)) {
report (RPT_INFO, "CwLnx: Config file tell us we have a keypad...\n"); report (RPT_INFO, "CwLnx: Config file tell us we have a keypad...\n");
p->have_keypad = 1; p->have_keypad = 1;
} }
/* keypad test mode? */ /* keypad test mode? */
if (drvthis->config_get_bool( drvthis->name , "keypad_test_mode" , 0 , 0)) { if (drvthis->config_get_bool( drvthis->name , "keypad_test_mode", 0, 0)) {
report (RPT_INFO, "CwLnx: Config tell us to test the keypad mapping...\n"); report (RPT_INFO, "CwLnx: Config tell us to test the keypad mapping...\n");
p->keypad_test_mode = 1; p->keypad_test_mode = 1;
stay_in_foreground = 1; stay_in_foreground = 1;
+1 -1
View File
@@ -58,7 +58,7 @@
static int iow_lcd_wcmd(usb_dev_handle *udh, unsigned char data[8]) static int iow_lcd_wcmd(usb_dev_handle *udh, unsigned char data[8])
{ {
return(usb_control_msg(udh, USB_DT_HID, USB_REQ_SET_REPORT, 0, 1, return(usb_control_msg(udh, USB_DT_HID, USB_REQ_SET_REPORT, 0, 1,
data, 8, iowTimeout) == 8) ? IOW_OK : IOW_ERROR; data, 8, iowTimeout) == 8) ? IOW_OK : IOW_ERROR;
} }
+1 -1
View File
@@ -56,7 +56,7 @@ typedef struct lcd_logical_driver {
char * (*getinfo) (); // get a string of info char * (*getinfo) (); // get a string of info
} lcd_logical_driver; } Driver;
------------------------------ lcd_logical_driver ------------------------------ ------------------------------ lcd_logical_driver ------------------------------
The first thing that is done is that lcd_init (lcd.c) is called. This function The first thing that is done is that lcd_init (lcd.c) is called. This function
+19 -67
View File
@@ -41,6 +41,8 @@
#define CCMODE_HBAR 2 #define CCMODE_HBAR 2
#define CCMODE_BIGNUM 3 #define CCMODE_BIGNUM 3
#define BAYRAD_DEFAULT_DEVICE "/dev/lcd"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////////////////////// Base "class" to derive from /////////////////////// ////////////////////// Base "class" to derive from ///////////////////////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@@ -321,16 +323,10 @@ MODULE_EXPORT int
bayrad_init(Driver *drvthis, char *args) bayrad_init(Driver *drvthis, char *args)
{ {
char device[256]; char device[256] = BAYRAD_DEFAULT_DEVICE;
int speed=B9600; int speed = B9600;
char *argv[64];
int argc;
int i;
struct termios portset; struct termios portset;
int tmp;
//debug(RPT_DEBUG,"bayrad_init()\n");
strcpy(device, "/dev/lcd");
width = 20; width = 20;
height = 2; height = 2;
@@ -348,68 +344,24 @@ bayrad_init(Driver *drvthis, char *args)
//cellheight = 5; //cellheight = 5;
//cellwidth = 8; //cellwidth = 8;
/*-----------------------------------------------------*/ /* Read config file */
//debug(RPT_DEBUG, "bayrad_init: Args(all): %s\n", args); /* What device should be used */
strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0,
BAYRAD_DEFAULT_DEVICE), sizeof(device));
device[sizeof(device)-1] = '\0';
argc = get_args(argv, args, 64); /* What speed to use */
speed = drvthis->config_get_int(drvthis->name, "Speed", 0, 9600);
/* if (speed == 1200) speed = B1200;
for(i=0; i<argc; i++) else if (speed == 2400) speed = B2400;
{ else if (speed == 9600) speed = B9600;
debug(RPT_DEBUG,"Arg(%i): %s\n", i, argv[i]); else if (speed == 19200) speed = B19200;
} else {
*/ report(RPT_WARNING, "bayrad_init: Illegal speed: %d. Must be one of 1200, 2400, 9600 or 19200. Using default.\n", speed);
speed = B9600;
for(i=0; i<argc; i++) }
{
//debug(RPT_DEBUG,"Arg(%i): %s\n", i, argv[i]);
if(0 == strcmp(argv[i], "-d") || 0 == strcmp(argv[i], "--device"))
{
if(i + 1 > argc) {
report(RPT_ERR, "bayrad_init: %s requires an argument",
argv[i]);
return -1;
}
strcpy(device, argv[++i]);
}
else if(0 == strcmp(argv[i], "-s") || 0 == strcmp(argv[i], "--speed"))
{
if(i + 1 > argc)
{
report(RPT_ERR, "bayrad_init: %s requires an argument", argv[i]);
return -1;
}
tmp = atoi(argv[++i]);
if(tmp==1200)
speed=B1200;
else if(tmp==2400)
speed=B2400;
else if(tmp==9600)
speed=B9600;
else if(tmp==19200)
speed=B19200;
else
{
report(RPT_ERR, "bayrad_init: %s argument must be 1200, 2400, 9600 or 19200. Using default value.",
argv[i]);
}
}
else if(0 == strcmp(argv[i], "-h") || 0 == strcmp(argv[i], "--help"))
{
report(RPT_ERR, "LCDproc EMAC BayRAD LCD driver\n"
"\t-d\t--device\tSelect the output device to use [/dev/lcd]\n"
/*"\t-t\t--type\t\tSelect the LCD type (size) [20x2]\n"*/
"\t-s\t--speed\t\tSet the communication speed [19200]\n"
"\t-h\t--help\t\tShow this help information\n");
return -1;
}
else
{
report(RPT_ERR, "bayrad_init: Invalid parameter: %s", argv[i]);
}
}
// Set up io port correctly, and open it... // Set up io port correctly, and open it...
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY); fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
+2 -2
View File
@@ -249,12 +249,12 @@ curses_drv_init (Driver *drvthis, char *args)
if (0<=drvthis->config_get_int ( drvthis->name , "topleftx" , 0 , CONF_DEF_TOP_LEFT_X) && drvthis->config_get_int ( drvthis->name , "topleftx" , 0 , CONF_DEF_TOP_LEFT_X) <= 255) { if (0<=drvthis->config_get_int ( drvthis->name , "topleftx" , 0 , CONF_DEF_TOP_LEFT_X) && drvthis->config_get_int ( drvthis->name , "topleftx" , 0 , CONF_DEF_TOP_LEFT_X) <= 255) {
screen_begx = drvthis->config_get_int ( drvthis->name , "topleftx" , 0 , CONF_DEF_TOP_LEFT_X); screen_begx = drvthis->config_get_int ( drvthis->name , "topleftx" , 0 , CONF_DEF_TOP_LEFT_X);
} else { } else {
report (RPT_WARNING, "CURSES: topleftx must between 0 and 255. Using default value %d.\n",CONF_DEF_TOP_LEFT_X); report (RPT_WARNING, "CURSES: topleftx must be between 0 and 255. Using default value %d.\n",CONF_DEF_TOP_LEFT_X);
} }
if (0<=drvthis->config_get_int ( drvthis->name , "toplefty" , 0 , CONF_DEF_TOP_LEFT_Y) && drvthis->config_get_int ( drvthis->name , "toplefty" , 0 , CONF_DEF_TOP_LEFT_Y) <= 255) { if (0<=drvthis->config_get_int ( drvthis->name , "toplefty" , 0 , CONF_DEF_TOP_LEFT_Y) && drvthis->config_get_int ( drvthis->name , "toplefty" , 0 , CONF_DEF_TOP_LEFT_Y) <= 255) {
screen_begy = drvthis->config_get_int ( drvthis->name , "toplefty" , 0 , CONF_DEF_TOP_LEFT_Y); screen_begy = drvthis->config_get_int ( drvthis->name , "toplefty" , 0 , CONF_DEF_TOP_LEFT_Y);
} else { } else {
report (RPT_WARNING, "CURSES: toplefty must between 0 and 255. Using default value %d.\n",CONF_DEF_TOP_LEFT_Y); report (RPT_WARNING, "CURSES: toplefty must be between 0 and 255. Using default value %d.\n",CONF_DEF_TOP_LEFT_Y);
} }
//debug: sleep(1); //debug: sleep(1);
+63 -97
View File
@@ -31,6 +31,12 @@
#include "shared/str.h" #include "shared/str.h"
#include "glk.h" #include "glk.h"
#include "glkproto.h" #include "glkproto.h"
#include "report.h"
#define GLK_DEFAULT_DEVICE "/dev/lcd"
#define GLK_DEFAULT_SPEED 19200
#define GLK_DEFAULT_CONTRAST 560
static GLKDisplay * PortFD ; static GLKDisplay * PortFD ;
/* Initialize pseudo-CGRAM to empty */ /* Initialize pseudo-CGRAM to empty */
@@ -65,77 +71,39 @@ MODULE_EXPORT char *symbol_prefix = "glk_";
MODULE_EXPORT int MODULE_EXPORT int
glk_init(Driver *drvthis, char *args) glk_init(Driver *drvthis, char *args)
{ {
char * argv[64]; char device[256] = GLK_DEFAULT_DEVICE;
int argc; speed_t speed = GLK_DEFAULT_SPEED;
char * device = "/dev/lcd" ; int contrast = GLK_DEFAULT_CONTRAST;
speed_t speed = B19200 ; int i;
int i ;
contrast = 560;
// printf("glk_init()\n"); /* Read config file */
argc = get_args( argv, args, 64 ); /* What device should be used */
for( i = 0 ; i < argc; ++i ) { strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0,
if( 0 == strcmp( argv[i], "-d") GLK_DEFAULT_DEVICE), sizeof(device));
|| 0 == strcmp( argv[i], "--device" ) device[sizeof(device)-1] = '\0';
) {
if( i+1 >= argc ) {
fprintf( stderr, "glk: %s requires an argument\n", argv[i]);
return( -1 );
};
device = argv[i+1] ;
++i ;
} else if( 0 == strcmp( argv[i], "-c" )
|| 0 == strcmp( argv[i], "--contrast" )
) {
int tmp ;
if( i+1 >= argc ) {
fprintf( stderr, "glk: %s requires an argument\n", argv[i]);
return( -1 );
};
tmp = atoi( argv[i+1] );
if( tmp < 0 || tmp > 255 ) {
fprintf( stderr, "glk: %s argument must be between 0 and 255\n", argv[i]);
} else {
contrast = tmp ;
};
++i ;
} else if( 0 == strcmp( argv[i], "-s" )
|| 0 == strcmp( argv[i], "--speed" )
) {
int tmp ;
if( i+1 >= argc ) {
fprintf( stderr, "glk: %s requires an argument\n", argv[i]);
return( -1 );
};
tmp = atoi( argv[i+1] );
if( tmp == 9600 ) {
speed = B9600 ;
} else if( tmp == 19200 ) {
speed = B19200 ;
} else if( tmp == 38400 ) {
speed = B38400 ;
} else {
fprintf( stderr, "glk: %s argument (%s) not a valid speed.\n", argv[i], argv[i+1] );
};
++i ;
} else if( 0 == strcmp( argv[i], "-h" )
|| 0 == strcmp( argv[i], "--help" )
) {
printf(
"LCDproc Matrix-Orbital GLK Graphical LCD driver\n"
"\n"
"-d, --device select the serial device to use [/dev/lcd]\n"
"-c, --contrast set the initial contrast value [560]\n"
"-s, --speed set the serial port speed [19200]\n"
"-h, --help display this help text\n"
);
return( -1 );
} else {
fprintf( stderr, "glk: Invalid parameter: %s\n", argv[i] );
};
};
/* What speed to use */
speed = drvthis->config_get_int(drvthis->name, "Speed", 0, 9600);
if (speed == 9600) speed = B9600;
else if (speed == 19200) speed = B19200;
else if (speed == 38400) speed = B38400;
else {
report(RPT_WARNING, "glk: Illegal speed: %d. Must be one of 9600, 19200 or 38400. Using default.\n", speed);
speed = B19200;
}
/* Which contrast */
contrast = drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , GLK_DEFAULT_CONTRAST);
if ((contrast < 0) || (contrast > 1000)) {
report (RPT_WARNING, "glk: Contrast must be between 0 and 1000. Using default value.\n");
contrast = GLK_DEFAULT_CONTRAST;
}
/* End of config file parsing */
/* open device */
PortFD = glkopen( device, speed ); PortFD = glkopen( device, speed );
if( PortFD == NULL ) { if( PortFD == NULL ) {
return -1 ; return -1 ;
@@ -145,7 +113,7 @@ glk_init(Driver *drvthis, char *args)
glkputl( PortFD, GLKCommand, 0x37, EOF ); glkputl( PortFD, GLKCommand, 0x37, EOF );
i = glkget( PortFD ); i = glkget( PortFD );
if( i < 0 ) { if( i < 0 ) {
fprintf( stderr, "glk: GLK did not respond to READ MODULE TYPE.\n" ); report(RPT_ERR, "glk: GLK did not respond to READ MODULE TYPE.\n" );
return -1 ; return -1 ;
} else { } else {
switch( i ) { switch( i ) {
@@ -170,7 +138,7 @@ glk_init(Driver *drvthis, char *args)
case 0x24 : // GLK12232-25SM-Penguin case 0x24 : // GLK12232-25SM-Penguin
width = 20 ; height = 4 ; gpo_count = 2 ; break ; width = 20 ; height = 4 ; gpo_count = 2 ; break ;
default : default :
fprintf( stderr, "glk: Unrecognized module type: 0x%02x\n", i ); report(RPT_ERR, "glk: Unrecognized module type: 0x%02x\n", i );
return( -1 ); return( -1 );
}; };
}; };
@@ -179,7 +147,7 @@ glk_init(Driver *drvthis, char *args)
screen_contents = malloc( width * height ); screen_contents = malloc( width * height );
if(framebuf == NULL || screen_contents == NULL ) { if(framebuf == NULL || screen_contents == NULL ) {
fprintf( stderr, "glk: Unable to allocate memory for screen buffers\n" ); report(RPT_ERR, "glk: Unable to allocate memory for screen buffers\n" );
glk_close(drvthis); glk_close(drvthis);
return -1; return -1;
} }
@@ -279,7 +247,7 @@ glk_flush(Driver *drvthis)
int xs ; int xs ;
char * ps = NULL ; char * ps = NULL ;
// printf( "flush()\n" ); debug(RPT_DEBUG, "flush()\n" );
p = framebuf ; p = framebuf ;
q = screen_contents ; q = screen_contents ;
@@ -291,7 +259,7 @@ glk_flush(Driver *drvthis)
/* Write accumulated string */ /* Write accumulated string */
glkputl( PortFD, GLKCommand, 0x79, xs*6+1, y*8, EOF ); glkputl( PortFD, GLKCommand, 0x79, xs*6+1, y*8, EOF );
glkputa( PortFD, x - xs, ps ); glkputa( PortFD, x - xs, ps );
// printf( "draw_frame: Writing at (%d,%d) for %d\n", xs, y, x-xs ); debug(RPT_DEBUG, "draw_frame: Writing at (%d,%d) for %d\n", xs, y, x-xs );
xs = -1 ; xs = -1 ;
} else if( *q != *p && xs < 0 ) { } else if( *q != *p && xs < 0 ) {
/* Start new string of changes */ /* Start new string of changes */
@@ -304,7 +272,7 @@ glk_flush(Driver *drvthis)
/* Write accumulated line */ /* Write accumulated line */
glkputl( PortFD, GLKCommand, 0x79, xs*6+1, y*8, EOF ); glkputl( PortFD, GLKCommand, 0x79, xs*6+1, y*8, EOF );
glkputa( PortFD, width - xs, ps ); glkputa( PortFD, width - xs, ps );
// printf( "draw_frame: Writing at (%d,%d) for %d\n", xs, y, width-xs ); debug(RPT_DEBUG, "draw_frame: Writing at (%d,%d) for %d\n", xs, y, width-xs );
}; };
}; /* For y */ }; /* For y */
@@ -322,7 +290,7 @@ glk_string(Driver *drvthis, int x, int y, char string[])
{ {
char * p ; char * p ;
// printf( "glk_string( %d, %d, \"%s\" )\n", x, y, string ); debug(RPT_DEBUG, "glk_string( %d, %d, \"%s\" )\n", x, y, string );
if( x > width || y > height ) { if( x > width || y > height ) {
return ; return ;
@@ -346,7 +314,7 @@ glk_chr(Driver *drvthis, int x, int y, char c)
y -= 1; y -= 1;
if( fontselected != 2 ) { if( fontselected != 2 ) {
// puts( "Switching to font 2" ); debug(RPT_DEBUG, "Switching to font 2" );
/* Select font 2 */ /* Select font 2 */
glkputl( PortFD, GLKCommand, 0x31, 2, EOF ); glkputl( PortFD, GLKCommand, 0x31, 2, EOF );
fontselected = 2 ; fontselected = 2 ;
@@ -358,15 +326,13 @@ glk_chr(Driver *drvthis, int x, int y, char c)
if( myc >= 0 && myc <= 15 ) { if( myc >= 0 && myc <= 15 ) {
/* CGRAM */ /* CGRAM */
// if( myc != 0 ) { debug(RPT_DEBUG, "CGRAM changing %d => %d\n", myc, CGRAM[myc&7] );
// printf( "CGRAM changing %d => %d\n", myc, CGRAM[myc&7] );
// };
myc = CGRAM[myc&7] ; myc = CGRAM[myc&7] ;
} else if( myc == 255 || myc == -1 ) { } else if( myc == 255 || myc == -1 ) {
/* Solid block */ /* Solid block */
myc = 133 ; myc = 133 ;
} else if( (myc > 15 && myc < 32) || myc > 143 ) { } else if( (myc > 15 && myc < 32) || myc > 143 ) {
fprintf( stderr, "Attempt to write %d to (%d,%d)\n", myc, x, y ); debug(RPT_DEBUG, "Attempt to write %d to (%d,%d)\n", myc, x, y );
myc = 133 ; myc = 133 ;
}; };
@@ -403,7 +369,7 @@ glk_set_contrast(Driver *drvthis, int promille)
contrast = promille; contrast = promille;
// Do it // Do it
// printf("Contrast: %i\n", contrast); debug(RPT_DEBUG, "Contrast: %i\n", contrast);
glkputl( PortFD, GLKCommand, 0x50, (int) ((long)promille * 255 / 1000), EOF ); glkputl( PortFD, GLKCommand, 0x50, (int) ((long)promille * 255 / 1000), EOF );
} }
@@ -414,10 +380,10 @@ MODULE_EXPORT void
glk_backlight(Driver *drvthis, int on) glk_backlight(Driver *drvthis, int on)
{ {
if(on) { if(on) {
// printf("Backlight ON\n"); debug(RPT_DEBUG, "Backlight ON\n");
glkputl( PortFD, GLKCommand, 0x42, 0, EOF ); glkputl( PortFD, GLKCommand, 0x42, 0, EOF );
} else { } else {
// printf("Backlight OFF\n"); debug(RPT_DEBUG, "Backlight OFF\n");
glkputl( PortFD, GLKCommand, 0x46, EOF ); glkputl( PortFD, GLKCommand, 0x46, EOF );
} }
} }
@@ -449,7 +415,7 @@ glk_output(Driver *drvthis, int on)
MODULE_EXPORT void MODULE_EXPORT void
glk_init_vbar(Driver *drvthis) glk_init_vbar(Driver *drvthis)
{ {
// printf("Vertical bars.\n"); debug(RPT_DEBUG, "glk_init_vbar()\n");
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@@ -458,7 +424,7 @@ glk_init_vbar(Driver *drvthis)
MODULE_EXPORT void MODULE_EXPORT void
glk_init_hbar(Driver *drvthis) glk_init_hbar(Driver *drvthis)
{ {
// printf("Horizontal bars.\n"); debug(RPT_DEBUG, "glk_init_hbar()\n");
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@@ -467,7 +433,7 @@ glk_init_hbar(Driver *drvthis)
MODULE_EXPORT void MODULE_EXPORT void
glk_init_num(Driver *drvthis) glk_init_num(Driver *drvthis)
{ {
// printf("Big Numbers.\n"); debug(RPT_DEBUG, "glk_init_num()\n");
if( fontselected != 3 ) { if( fontselected != 3 ) {
/* Select Big Numbers font */ /* Select Big Numbers font */
glkputl( PortFD, GLKCommand, 0x31, 3, EOF ); glkputl( PortFD, GLKCommand, 0x31, 3, EOF );
@@ -485,7 +451,7 @@ glk_init_num(Driver *drvthis)
MODULE_EXPORT void MODULE_EXPORT void
glk_num(Driver *drvthis, int x, int num) glk_num(Driver *drvthis, int x, int num)
{ {
// printf("BigNum(%i, %i)\n", x, num); debug(RPT_DEBUG, "glk_num(%i, %i)\n", x, num);
framebuf[x-1] = num + '0' ; framebuf[x-1] = num + '0' ;
} }
@@ -495,7 +461,7 @@ glk_num(Driver *drvthis, int x, int num)
MODULE_EXPORT void MODULE_EXPORT void
glk_set_char(Driver *drvthis, int n, char *dat) glk_set_char(Driver *drvthis, int n, char *dat)
{ {
printf("Set Character %i\n", n); debug(RPT_DEBUG, "glk_set_char( %i )\n", n);
} }
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
@@ -506,7 +472,7 @@ glk_old_vbar(Driver *drvthis, int x, int len)
{ {
int y = height ; int y = height ;
// printf( "glk_vbar( %d, %d )\n", x, len ); debug(RPT_DEBUG, "glk_old_vbar( %d, %d )\n", x, len );
while( len > cellheight ) { while( len > cellheight ) {
glk_chr( drvthis, x, y, 255 ); glk_chr( drvthis, x, y, 255 );
--y ; --y ;
@@ -535,7 +501,7 @@ glk_old_vbar(Driver *drvthis, int x, int len)
MODULE_EXPORT void MODULE_EXPORT void
glk_old_hbar(Driver *drvthis, int x, int y, int len) glk_old_hbar(Driver *drvthis, int x, int y, int len)
{ {
// printf( "glk_hbar( %d, %d, %d )\n", x, y, len ); debug(RPT_DEBUG, "glk_old_hbar( %d, %d, %d )\n", x, y, len );
while( len > cellwidth ) { while( len > cellwidth ) {
glk_chr( drvthis, x, y, 255 ); glk_chr( drvthis, x, y, 255 );
++x ; ++x ;
@@ -571,7 +537,7 @@ glk_old_icon(Driver *drvthis, int which, int dest)
unsigned char * q ; unsigned char * q ;
int count ; int count ;
// printf("Char %i set to icon %i\n", dest, which); debug(RPT_DEBUG, "glk_old_icon( %i, %i )\n", which, dest);
if( dest < 0 || dest > 7 ) { if( dest < 0 || dest > 7 ) {
/* Illegal custom character */ /* Illegal custom character */
@@ -597,7 +563,7 @@ glk_old_icon(Driver *drvthis, int which, int dest)
/* Replace all old icons with new icon in new frame */ /* Replace all old icons with new icon in new frame */
for( count = width * height ; count ; --count ) { for( count = width * height ; count ; --count ) {
if( *q == old ) { if( *q == old ) {
// printf( "icon %d to %d at %d\n", old, new, q - screen_contents ); debug(RPT_DEBUG, "icon %d to %d at %d\n", old, new, q - screen_contents );
*p = new ; *p = new ;
}; };
++q ; ++p ; ++q ; ++p ;
@@ -623,7 +589,7 @@ glk_old_getkey(Driver *drvthis)
static struct timeval lastkey ; static struct timeval lastkey ;
struct timeval now ; struct timeval now ;
// puts( "glk_getkey( )" ); debug(RPT_DEBUG, "glk_getkey()" );
c = glkgetc( PortFD ); c = glkgetc( PortFD );
@@ -631,10 +597,10 @@ glk_old_getkey(Driver *drvthis)
/* Key down event */ /* Key down event */
key = c ; key = c ;
gettimeofday( &lastkey, NULL ); gettimeofday( &lastkey, NULL );
// printf( "KEY %c at %ld.%06ld\n", c, lastkey.tv_sec, lastkey.tv_usec ); debug(RPT_DEBUG, "KEY %c at %ld.%06ld\n", c, lastkey.tv_sec, lastkey.tv_usec );
} else if( c >= 'a' && c <= 'z' ) { } else if( c >= 'a' && c <= 'z' ) {
/* Key up event */ /* Key up event */
// printf( "KEY %c UP\n", c ); debug(RPT_DEBUG, "KEY %c UP\n", c );
key = -1 ; key = -1 ;
c = 0 ; c = 0 ;
} else { } else {
@@ -646,12 +612,12 @@ glk_old_getkey(Driver *drvthis)
gettimeofday( &now, NULL ); gettimeofday( &now, NULL );
msec_diff = (now.tv_sec - lastkey.tv_sec) * 1000 ; msec_diff = (now.tv_sec - lastkey.tv_sec) * 1000 ;
msec_diff += (now.tv_usec - lastkey.tv_usec) / 1000 ; msec_diff += (now.tv_usec - lastkey.tv_usec) / 1000 ;
// printf( "KEY %c down for %d msec\n", key, msec_diff ); debug(RPT_DEBUG, "KEY %c down for %d msec\n", key, msec_diff );
if( msec_diff > 1000 ) { if( msec_diff > 1000 ) {
/* Generate repeat event */ /* Generate repeat event */
c = key | 0x20 ; /* Upper case to lower case */ c = key | 0x20 ; /* Upper case to lower case */
++lastkey.tv_sec ; /* HACK HACK. repeat at 1 sec intervals */ ++lastkey.tv_sec ; /* HACK HACK. repeat at 1 sec intervals */
// printf( "KEY %c REPEAT\n", c ); debug(RPT_DEBUG, "KEY %c REPEAT\n", c );
}; };
}; };
}; };
+1 -1
View File
@@ -4,6 +4,6 @@
#include "lcd.h" /* for Driver */ #include "lcd.h" /* for Driver */
// initialise this particular driver // initialise this particular driver
int hd_init_ext8bit (Driver *driver); int hd_init_ext8bit (Driver *drvthis);
#endif #endif
+3 -3
View File
@@ -124,8 +124,6 @@ HD44780_init (Driver * drvthis, char *args)
{ {
// TODO: remove the two magic numbers below // TODO: remove the two magic numbers below
// TODO: single point of return // TODO: single point of return
//char *argv[64];
//int i;
char buf[40]; char buf[40];
char *s; char *s;
int i; int i;
@@ -209,8 +207,10 @@ HD44780_init (Driver * drvthis, char *args)
report (RPT_ERR, "Error mallocing"); report (RPT_ERR, "Error mallocing");
} }
if (timing_init() == -1) if (timing_init() == -1) {
report(RPT_ERR, "timing_init: failed (%s)\n", strerror(errno));
return -1; return -1;
}
#if defined DELAY_NANOSLEEP #if defined DELAY_NANOSLEEP
// Change to Round-Robin scheduling for nanosleep // Change to Round-Robin scheduling for nanosleep
+1 -1
View File
@@ -18,7 +18,7 @@
#include "lcd.h" #include "lcd.h"
MODULE_EXPORT int HD44780_init (struct lcd_logical_driver *driver, char *args); MODULE_EXPORT int HD44780_init (Driver *drvthis, char *args);
MODULE_EXPORT void HD44780_close (Driver *drvthis); MODULE_EXPORT void HD44780_close (Driver *drvthis);
MODULE_EXPORT int HD44780_width (Driver *drvthis); MODULE_EXPORT int HD44780_width (Driver *drvthis);
MODULE_EXPORT int HD44780_height (Driver *drvthis); MODULE_EXPORT int HD44780_height (Driver *drvthis);
+1 -1
View File
@@ -32,7 +32,7 @@
#define ICP_A106_H #define ICP_A106_H
#include "lcd.h" #include "lcd.h"
MODULE_EXPORT int icp_a106_init (struct lcd_logical_driver *driver, char *args); MODULE_EXPORT int icp_a106_init (Driver *drvthis, char *args);
MODULE_EXPORT void icp_a106_close (Driver *drvthis); MODULE_EXPORT void icp_a106_close (Driver *drvthis);
MODULE_EXPORT int icp_a106_width (Driver *drvthis); MODULE_EXPORT int icp_a106_width (Driver *drvthis);
MODULE_EXPORT int icp_a106_height (Driver *drvthis); MODULE_EXPORT int icp_a106_height (Driver *drvthis);
+27 -37
View File
@@ -24,6 +24,7 @@
#include "lcd.h" #include "lcd.h"
#include "irmanin.h" #include "irmanin.h"
#include "report.h"
#include "../../../libirman-0.4.1b/irman.h" #include "../../../libirman-0.4.1b/irman.h"
char *progname = "irmanin"; char *progname = "irmanin";
@@ -76,7 +77,7 @@ lcd_logical_driver *irmanin;
// init() should set up any device-specific stuff, and // init() should set up any device-specific stuff, and
// point all the function pointers. // point all the function pointers.
MODULE_EXPORT int MODULE_EXPORT int
irmanin_init (struct lcd_logical_driver *driver, char *args) irmanin_init (Driver *drvthis, char *args)
{ {
char device[256]; char device[256];
char *ptrdevice; char *ptrdevice;
@@ -85,72 +86,61 @@ irmanin_init (struct lcd_logical_driver *driver, char *args)
char *portname; char *portname;
char *argv[64]; int i;
int argc, i, j;
char *filename; char *filename;
ptrconfig = NULL; ptrconfig = NULL;
ptrdevice = NULL; ptrdevice = NULL;
irmanin = driver; irmanin = drvthis;
argc = get_args (argv, args, 64); /* Read config file */
for (i = 0; i < argc; i++) { /* What device should be used */
//printf("Arg(%i): %s\n", i, argv[i]); strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0,
if (0 == strcmp (argv[i], "-d") || 0 == strcmp (argv[i], "--device")) { ""), sizeof(device));
if (i + 1 > argc) { device[sizeof(device)-1] = '\0';
fprintf (stderr, "irmanin_init: %s requires an argument\n", argv[i]); if (*device != '\0') ptrdevice = device;
return -1;
} /* What config file should be used */
strcpy (device, argv[++i]); strncpy(config, drvthis->config_get_string(drvthis->name, "Config", 0,
ptrdevice = device; ""), sizeof(config));
} else if (0 == strcmp (argv[i], "-c") || 0 == strcmp (argv[i], "--config")) { config[sizeof(config)-1] = '\0';
if (i + 1 > argc) { if (*config != '\0') ptrconfig = config;
fprintf (stderr, "irmanin_init: %s requires an argument\n", argv[i]);
return -1; /* End of config file parsing */
}
strcpy (config, argv[++i]);
ptrconfig = config;
} else if (0 == strcmp (argv[i], "-h") || 0 == strcmp (argv[i], "--help")) {
printf ("LCDproc IrMan input driver\n" "\t-d\t--device\tSelect the input device to use\n" "\t-d\t--config\tSelect the configuration file to use\n" "\t-h\t--help\t\tShow this help information\n");
return -1;
} else {
printf ("Invalid parameter: %s\n", argv[i]);
}
}
if (ir_init_commands (ptrconfig, 1) < 0) { if (ir_init_commands (ptrconfig, 1) < 0) {
fprintf (stderr, "error initialising commands: %s\n", strerror (errno)); report(RPT_ERR, "error initialising commands: %s\n", strerror (errno));
exit (1); exit (1);
} }
portname = ir_default_portname (); portname = ir_default_portname ();
if (portname == NULL) { if (portname == NULL) {
if (ptrdevice == NULL) { if (ptrdevice != NULL) {
portname = ptrdevice; portname = ptrdevice;
} else { } else {
fprintf (stderr, "error no device defined\n"); report(RPT_ERR, "error no device defined\n");
exit (1); exit (1);
} }
} }
driver->getkey = irmanin_getkey; drvthis->getkey = irmanin_getkey;
driver->close = irmanin_close; drvthis->close = irmanin_close;
for (i = 1; codes[i] != NULL; i++) { for (i = 1; codes[i] != NULL; i++) {
if (ir_register_command (codes[i], i) < 0) { if (ir_register_command (codes[i], i) < 0) {
if (errno == ENOENT) { if (errno == ENOENT) {
fprintf (stderr, "%s: no code set for `%s'\n", progname, codes[i]); report(RPT_WARNING, "%s: no code set for `%s'\n", progname, codes[i]);
} else { } else {
fprintf (stderr, "error registering `%s': `%s'\n", codes[i], strerror (errno)); report(RPT_WARNING, "error registering `%s': `%s'\n", codes[i], strerror (errno));
} }
} }
} }
errno = 0; errno = 0;
if (ir_init (portname) < 0) { if (ir_init (portname) < 0) {
fprintf (stderr, "%s: error initialising Irman: `%s'\n", strerror (errno), portname); report(RPT_ERR, "%s: error initialising Irman: `%s'\n", strerror (errno), portname);
exit (1); exit (1);
} }
@@ -184,7 +174,7 @@ irmanin_getkey ()
key = (char) 0; key = (char) 0;
switch (cmd = ir_poll_command ()) { switch (cmd = ir_poll_command ()) {
case IR_CMD_ERROR: case IR_CMD_ERROR:
fprintf (stderr, "%s: error reading command: %s\n", progname, strerror (errno)); report(RPT_WARNING, "%s: error reading command: %s\n", progname, strerror (errno));
break; break;
case IR_CMD_UNKNOWN: case IR_CMD_UNKNOWN:
break; break;
+1 -1
View File
@@ -3,7 +3,7 @@
extern lcd_logical_driver *joy; extern lcd_logical_driver *joy;
MODULE_EXPORT int irmanin_init (struct lcd_logical_driver *driver, char *args); MODULE_EXPORT int irmanin_init (Driver *drvthis, char *args);
MODULE_EXPORT void irmanin_close (); MODULE_EXPORT void irmanin_close ();
MODULE_EXPORT char irmanin_getkey (); MODULE_EXPORT char irmanin_getkey ();
+25 -38
View File
@@ -36,8 +36,11 @@
#include "report.h" #include "report.h"
#include "shared/str.h" #include "shared/str.h"
#define NAME_LENGTH 128 #define JOY_NAMELENGTH 128
#define JOY_DEFAULT_DEVICE "/dev/js0" #define JOY_DEFAULT_DEVICE "/dev/js0"
#define JOY_MAPSIZE 16
#define JOY_DEFAULT_AXISMAP "EFGHIJKLMNOPQRST"
#define JOY_DEFAULT_BUTTONMAP "BDACEFGHIJKLMNOP"
int fd; int fd;
@@ -45,15 +48,15 @@ struct js_event js;
char axes = 2; char axes = 2;
char buttons = 2; char buttons = 2;
int jsversion = 0x000800; int jsversion = 0x000801;
char jsname[NAME_LENGTH] = "Unknown"; char jsname[JOY_NAMELENGTH] = "Unknown";
int *axis = NULL; int *axis = NULL;
int *button = NULL; int *button = NULL;
// Configured for a Gravis Gamepad (2 axis, 4 button) // Configured for a Gravis Gamepad (2 axis, 4 button)
char *axismap = "EFGHIJKLMNOPQRST"; char axismap[JOY_MAPSIZE+1] = JOY_DEFAULT_AXISMAP;
char *buttonmap = "BDACEFGHIJKLMNOP"; char buttonmap[JOY_MAPSIZE+1] = JOY_DEFAULT_BUTTONMAP;
// Vars for the server core // Vars for the server core
MODULE_EXPORT char *api_version = API_VERSION; MODULE_EXPORT char *api_version = API_VERSION;
@@ -69,41 +72,25 @@ MODULE_EXPORT int
joy_init (Driver *drvthis, char *args) joy_init (Driver *drvthis, char *args)
{ {
char device[256]; char device[256];
char *argv[64];
int argc, i;
strcpy (device, JOY_DEFAULT_DEVICE); /* Read config file */
argc = get_args (argv, args, 64); /* What device should be used */
strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0,
JOY_DEFAULT_DEVICE), sizeof(device));
device[sizeof(device)-1] = '\0';
for (i = 0; i < argc; i++) { /* How does the axis map look like */
//printf("Arg(%i): %s\n", i, argv[i]); strncpy(axismap, drvthis->config_get_string(drvthis->name, "AxisMap", 0,
if (0 == strcmp (argv[i], "-d") || 0 == strcmp (argv[i], "--device")) { JOY_DEFAULT_AXISMAP), sizeof(axismap));
if (i + 1 > argc) { axismap[sizeof(axismap)-1] = '\0';
fprintf (stderr, "joy_init: %s requires an argument\n", argv[i]);
return -1;
}
strcpy (device, argv[++i]);
} else if (0 == strcmp (argv[i], "-a") || 0 == strcmp (argv[i], "--axes")) {
if (i + 1 > argc) {
fprintf (stderr, "joy_init: %s requires an argument\n", argv[i]);
return -1;
}
strncpy (axismap, argv[++i], 16);
} else if (0 == strcmp (argv[i], "-b") || 0 == strcmp (argv[i], "--buttons")) {
if (i + 1 > argc) {
fprintf (stderr, "joy_init: %s requires an argument\n", argv[i]);
return -1;
}
strncpy (buttonmap, argv[++i], 16);
} else if (0 == strcmp (argv[i], "-h") || 0 == strcmp (argv[i], "--help")) {
printf ("LCDproc Joystick input driver\n" "\t-d\t--device\tSelect the input device to use [/dev/js0]\n" "\t-a\t--axes\t\tModify the axis map [%s]\n" "\t-b\t--buttons\tModify the button map [%s]\n" "\t-h\t--help\t\tShow this help information\n", axismap, buttonmap);
return -1;
} else {
printf ("Invalid parameter: %s\n", argv[i]);
}
} /* How does the button map look like */
strncpy(buttonmap, drvthis->config_get_string(drvthis->name, "ButtonMap", 0,
JOY_DEFAULT_BUTTONMAP), sizeof(buttonmap));
buttonmap[sizeof(buttonmap)-1] = '\0';
/* End of config file parsing */
if ((fd = open (device, O_RDONLY)) < 0) if ((fd = open (device, O_RDONLY)) < 0)
return -1; return -1;
@@ -112,7 +99,7 @@ joy_init (Driver *drvthis, char *args)
ioctl (fd, JSIOCGVERSION, &jsversion); ioctl (fd, JSIOCGVERSION, &jsversion);
ioctl (fd, JSIOCGAXES, &axes); ioctl (fd, JSIOCGAXES, &axes);
ioctl (fd, JSIOCGBUTTONS, &buttons); ioctl (fd, JSIOCGBUTTONS, &buttons);
ioctl (fd, JSIOCGNAME (NAME_LENGTH), jsname); ioctl (fd, JSIOCGNAME (JOY_NAMELENGTH), jsname);
report (RPT_NOTICE, "Joystick (%s) has %d axes and %d buttons. Driver version is %d.%d.%d.\n", report (RPT_NOTICE, "Joystick (%s) has %d axes and %d buttons. Driver version is %d.%d.%d.\n",
jsname, axes, buttons, jsname, axes, buttons,
+43 -89
View File
@@ -38,6 +38,10 @@
#include "report.h" #include "report.h"
//#include "drv_base.h" //#include "drv_base.h"
#define LB216_DEFAULT_DEVICE "/dev/lcd"
#define LB216_DEFAULT_SPEED 9600
#define LB216_DEFAULT_BRIGHTNESS 255
static int custom=0; static int custom=0;
typedef enum { typedef enum {
hbar = 1, hbar = 1,
@@ -71,106 +75,53 @@ MODULE_EXPORT char *symbol_prefix = "LB216_";
MODULE_EXPORT int MODULE_EXPORT int
LB216_init(Driver * drvthis, char *args) LB216_init(Driver * drvthis, char *args)
{ {
char *argv[64];
int argc;
struct termios portset; struct termios portset;
int i;
int tmp;
int reboot=0; int reboot=0;
char device[256] = LB216_DEFAULT_DEVICE;
char device[256] = "/dev/lcd"; int speed = LB216_DEFAULT_SPEED;
int speed=B9600; int backlight_brightness = LB216_DEFAULT_BRIGHTNESS;
int backlight_brightness = 255;
//debug("LB216_init: Args(all): %s\n", args); /* Read config file */
argc = get_args(argv, args, 64); /* What device should be used */
strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0,
LB216_DEFAULT_DEVICE), sizeof(device));
device[sizeof(device)-1] = '\0';
/* /* What speed to use */
for(i=0; i<argc; i++) speed = drvthis->config_get_int(drvthis->name, "Speed", 0, LB216_DEFAULT_SPEED);
{
printf("Arg(%i): %s\n", i, argv[i]);
}
*/
for(i=0; i<argc; i++) if (speed == 2400) speed = B2400;
{ else if (speed == 9600) speed = B9600;
//printf("Arg(%i): %s\n", i, argv[i]); else {
if(0 == strcmp(argv[i], "-d") || report(RPT_WARNING, "lb216_init: Illegal speed: %d. Must be 2400 or 9600. Using default.\n", speed);
0 == strcmp(argv[i], "--device")) speed = B9600;
{ }
if(i + 1 > argc) {
fprintf(stderr, "LB216_init: %s requires an argument\n",
argv[i]);
return -1;
}
strcpy(device, argv[++i]);
}
else if(0 == strcmp(argv[i], "-b") ||
0 == strcmp(argv[i], "--brightness"))
{
if(i + 1 > argc) {
fprintf(stderr, "LB216_init: %s requires an argument\n",
argv[i]);
return -1;
}
tmp = atoi(argv[++i]);
if((tmp < 0) || (tmp > 255)){
fprintf(stderr, "LB216_init: %s argument must between 0 and 255. Using default value.\n",
argv[i]);
} else backlight_brightness = tmp;
}
else if(0 == strcmp(argv[i], "-s") ||
0 == strcmp(argv[i], "--speed"))
{
if(i + 1 > argc) {
fprintf(stderr, "LB216_init: %s requires an argument\n",
argv[i]);
return -1;
}
tmp = atoi(argv[++i]);
if(tmp==2400) speed=B2400;
else if(tmp==9600) speed=B9600;
else {
fprintf(stderr, "LB216_init: %s argument must be 2400, or 9600. Using default value.\n",
argv[i]);
}
}
else if(0 == strcmp(argv[i], "-h") ||
0 == strcmp(argv[i], "--help"))
{
printf("LCDproc LB216 LCD driver\n"
"\t-d\t--device\tSelect the output device to use [/dev/lcd]\n"
"\t-t\t--type\t\tSelect the LCD type (size) [16x2]\n"
"\t-b\t--brightness\tSet the initial brightness [255]\n"
"\t-s\t--speed\t\tSet the communication speed [9600]\n"
"\t-r\t--reboot\tReinitialize the LCD's BIOS\n"
"\t-h\t--help\t\tShow this help information\n");
return -1;
}
else if(0 == strcmp(argv[i], "-r") ||
0 == strcmp(argv[i], "--reboot"))
{
printf("LCDd: rebooting LB216 LCD...\n");
reboot=1;
}
else
{
printf("Invalid parameter: %s\n", argv[i]);
}
} /* Which backlight brightness */
backlight_brightness = drvthis->config_get_int ( drvthis->name , "Brightness" , 0 , LB216_DEFAULT_BRIGHTNESS);
if ((backlight_brightness < 0) || (backlight_brightness > 255)) {
report (RPT_WARNING, "lb216_init: Brightness must be between 0 and 255. Using default value.\n");
backlight_brightness = LB216_DEFAULT_BRIGHTNESS;
}
/* Reboot display? */
reboot = drvthis->config_get_bool( drvthis->name , "Reboot", 0, 0);
if (reboot)
report (RPT_INFO, "LCDd: rebooting LB216 LCD...\n");
/* End of config file parsing */
// Set up io port correctly, and open it... // Set up io port correctly, and open it...
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY); fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1) if (fd == -1)
{ {
fprintf(stderr, "LB216_init: failed (%s)\n", strerror(errno)); report(RPT_ERR, "lb216_init: open(%s) failed (%s)\n", device, strerror(errno));
return -1; return -1;
} }
//else fprintf(stderr, "LB216_init: opened device %s\n", device); report(RPT_DEBUG, "lb216_init: opened device %s\n", device);
tcgetattr(fd, &portset); tcgetattr(fd, &portset);
// We use RAW mode // We use RAW mode
@@ -195,13 +146,15 @@ LB216_init(Driver * drvthis, char *args)
tcsetattr(fd, TCSANOW, &portset); tcsetattr(fd, TCSANOW, &portset);
// Make sure the frame buffer is there... // Make sure the frame buffer is there...
if (framebuf) framebuf = (unsigned char *) malloc (width * height);
framebuf = (unsigned char *) if (framebuf == NULL) {
malloc (width * height); report(RPT_ERR, "lb216_init: unable to create framebuffer.\n");
return -1;
}
memset (framebuf, ' ', width * height); memset (framebuf, ' ', width * height);
// Set display-specific stuff.. // Set display-specific stuff..
if(reboot) if (reboot)
{ {
LB216_reboot(); LB216_reboot();
sleep(4); sleep(4);
@@ -224,7 +177,8 @@ LB216_close(Driver * drvthis)
{ {
close (fd); close (fd);
if(framebuf) free(framebuf); if (framebuf)
free(framebuf);
framebuf = NULL; framebuf = NULL;
} }
+5 -5
View File
@@ -19,7 +19,7 @@
ANY DRIVER SHOULD SIMPLY FREE ITS FRAMEBUFFER AT CLOSE() ANY DRIVER SHOULD SIMPLY FREE ITS FRAMEBUFFER AT CLOSE()
NO CHECKING FOR NULL NEEDED NO CHECKING FOR NULL NEEDED
void void
free_framebuf (struct lcd_logical_driver *driver) { free_framebuf (Driver *driver) {
if (!driver) if (!driver)
return; return;
@@ -33,7 +33,7 @@ free_framebuf (struct lcd_logical_driver *driver) {
/* /*
NEED TO BE ADAPTED TO NEW SITUATION NEED TO BE ADAPTED TO NEW SITUATION
void void
clear_framebuf (struct lcd_logical_driver *driver) { clear_framebuf (Driver *driver) {
int framebuf_size; int framebuf_size;
if (!driver) if (!driver)
@@ -47,7 +47,7 @@ clear_framebuf (struct lcd_logical_driver *driver) {
/* /*
NEED TO BE ADAPTED TO NEW SITUATION NEED TO BE ADAPTED TO NEW SITUATION
int int
new_framebuf (struct lcd_logical_driver *driver, char *oldbuf) { new_framebuf (Driver *driver, char *oldbuf) {
int i; int i;
if (driver->framebuf == NULL) if (driver->framebuf == NULL)
@@ -68,7 +68,7 @@ new_framebuf (struct lcd_logical_driver *driver, char *oldbuf) {
/* /*
NEED TO BE ADAPTED TO NEW SITUATION NEED TO BE ADAPTED TO NEW SITUATION
void void
insert_str_framebuf (struct lcd_logical_driver *driver, int x, int y, char *string) { insert_str_framebuf (Driver *driver, int x, int y, char *string) {
//int i; //int i;
char buf[64]; char buf[64];
char *pos; char *pos;
@@ -97,7 +97,7 @@ insert_str_framebuf (struct lcd_logical_driver *driver, int x, int y, char *stri
/* /*
NEED TO BE ADAPTED TO NEW SITUATION NEED TO BE ADAPTED TO NEW SITUATION
void void
insert_chr_framebuf (struct lcd_logical_driver *driver, int x, int y, char c) { insert_chr_framebuf (Driver *driver, int x, int y, char c) {
if (!driver) if (!driver)
return; return;
+1 -1
View File
@@ -5,7 +5,7 @@
#include "lcd.h" #include "lcd.h"
#endif #endif
int new_framebuf (struct lcd_logical_driver *driver, char *oldbuf); int new_framebuf (Driver *driver, char *oldbuf);
void lib_hbar_static (Driver *drvthis, int x, int y, int len, int promille, int options, int cellwidth, int cc_offset); void lib_hbar_static (Driver *drvthis, int x, int y, int len, int promille, int options, int cellwidth, int cc_offset);
void lib_vbar_static (Driver *drvthis, int x, int y, int len, int promille, int options, int cellheight, int cc_offset); void lib_vbar_static (Driver *drvthis, int x, int y, int len, int promille, int options, int cellheight, int cc_offset);
+1 -1
View File
@@ -33,7 +33,7 @@
/* REMOVE: I don't thing this is actualy needed. */ /* REMOVE: I don't thing this is actualy needed. */
/* extern lcd_logical_driver *lcdm001; */ /* extern lcd_logical_driver *lcdm001; */
MODULE_EXPORT int lcdm001_init (struct lcd_logical_driver *driver, char *args); MODULE_EXPORT int lcdm001_init (Driver *drvthis, char *args);
MODULE_EXPORT void lcdm001_close (Driver *drvthis); MODULE_EXPORT void lcdm001_close (Driver *drvthis);
MODULE_EXPORT int lcdm001_width (Driver *drvthis); MODULE_EXPORT int lcdm001_width (Driver *drvthis);
MODULE_EXPORT int lcdm001_height (Driver *drvthis); MODULE_EXPORT int lcdm001_height (Driver *drvthis);
+13 -14
View File
@@ -96,33 +96,32 @@ lcterm_init (Driver *drvthis, char *args)
// which serial device should be used // which serial device should be used
strncpy(device, drvthis->config_get_string ( drvthis->name , "Device" , 0 , DEFAULT_DEVICE), strncpy(device, drvthis->config_get_string ( drvthis->name , "Device" , 0 , DEFAULT_DEVICE),
sizeof(device)); sizeof(device));
device[sizeof(device)-1]=0; device[sizeof(device)-1] = '\0';
report (RPT_INFO,"LCTERM: Using device: %s", device); report (RPT_INFO,"LCTERM: Using device: %s", device);
/* Get and parse size */
{ {
char *s;
int w,h; int w,h;
char *s = drvthis->config_get_string( drvthis->name, "size", 0, "16x2" );
// Get and parse size debug(RPT_DEBUG, "lcterm_init: reading size: %s\n", s );
s = drvthis->config_get_string( drvthis->name, "size", 0, "16x2" );
fprintf( stderr, "lcterm_init: size: %s\n", s );
if( sscanf( s, "%dx%d", &w, &h) == 2 if((sscanf( s, "%dx%d", &w, &h) != 2)
&& (w > 0) && (w <= LCD_MAX_WIDTH) || (w <= 0) || (w > LCD_MAX_WIDTH)
&& (h > 0) && (h <= LCD_MAX_HEIGHT)) || (h <= 0) || (h > LCD_MAX_HEIGHT))
{ {
p->width = w; report(RPT_WARNING, "LCDTERM: Cannot read size: %s. Using default value.\n", s);
p->height = h; sscanf( "16x2", "%dx%d", &w, &h);
} }
else p->width = w;
fprintf( stderr, "lcterm_init: Cannot parse size: %s\n", s ); p->height = h;
} }
fprintf(stderr,"size: %dx%d\n",p->width, p->height); report (RPT_INFO,"LCTERM: Using size: %dx%d\n",p->width, p->height);
p->framebuf = malloc (p->width * p->height); p->framebuf = malloc (p->width * p->height);
p->last_framebuf = malloc (p->width * p->height); p->last_framebuf = malloc (p->width * p->height);
if (!p->framebuf || !p->last_framebuf) { if (!p->framebuf || !p->last_framebuf) {
report(RPT_ERR, "\nError: unable to create LCTERM framebuffer.\n"); report(RPT_ERR, "Error: unable to create LCTERM framebuffer.\n");
return -1; return -1;
} }
memset (p->framebuf, ' ', p->width * p->height); memset (p->framebuf, ' ', p->width * p->height);
+1 -1
View File
@@ -27,7 +27,7 @@
#define LCTERM_H #define LCTERM_H
#include "lcd.h" #include "lcd.h"
MODULE_EXPORT int lcterm_init (struct lcd_logical_driver *driver, char *args); MODULE_EXPORT int lcterm_init (Driver *drvthis, char *args);
MODULE_EXPORT void lcterm_close (Driver *drvthis); MODULE_EXPORT void lcterm_close (Driver *drvthis);
MODULE_EXPORT int lcterm_width (Driver *drvthis); MODULE_EXPORT int lcterm_width (Driver *drvthis);
MODULE_EXPORT int lcterm_height (Driver *drvthis); MODULE_EXPORT int lcterm_height (Driver *drvthis);
+13 -13
View File
@@ -143,7 +143,7 @@ ms6931_draw_frame (char *dat)
// Opens com port and sets baud correctly... // Opens com port and sets baud correctly...
// //
MODULE_EXPORT int MODULE_EXPORT int
ms6931_init (struct lcd_logical_driver *drvthis, char *args) ms6931_init (Driver *drvthis, char *args)
{ {
struct termios portset; struct termios portset;
int w, h; int w, h;
@@ -228,7 +228,7 @@ ms6931_init (struct lcd_logical_driver *drvthis, char *args)
// Clean-up // Clean-up
// //
MODULE_EXPORT void MODULE_EXPORT void
ms6931_close (struct lcd_logical_driver *drvthis) ms6931_close (Driver *drvthis)
{ {
ms6931_clear(drvthis); ms6931_clear(drvthis);
ms6931_flush(drvthis); ms6931_flush(drvthis);
@@ -247,7 +247,7 @@ ms6931_close (struct lcd_logical_driver *drvthis)
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// //
MODULE_EXPORT void MODULE_EXPORT void
ms6931_flush (struct lcd_logical_driver *drvthis) ms6931_flush (Driver *drvthis)
{ {
ms6931_draw_frame (framebuf); ms6931_draw_frame (framebuf);
} }
@@ -256,13 +256,13 @@ ms6931_flush (struct lcd_logical_driver *drvthis)
// Returns the display width/height // Returns the display width/height
// //
MODULE_EXPORT int MODULE_EXPORT int
ms6931_width (struct lcd_logical_driver *drvthis) ms6931_width (Driver *drvthis)
{ {
return width; return width;
} }
MODULE_EXPORT int MODULE_EXPORT int
ms6931_height (struct lcd_logical_driver *drvthis) ms6931_height (Driver *drvthis)
{ {
return height; return height;
} }
@@ -272,7 +272,7 @@ ms6931_height (struct lcd_logical_driver *drvthis)
// upper-left is (1,1), and the lower right should be (16,2). // upper-left is (1,1), and the lower right should be (16,2).
// //
MODULE_EXPORT void MODULE_EXPORT void
ms6931_chr (struct lcd_logical_driver *drvthis, int x, int y, char c) ms6931_chr (Driver *drvthis, int x, int y, char c)
{ {
if (x>width || y>height) if (x>width || y>height)
return; return;
@@ -285,7 +285,7 @@ ms6931_chr (struct lcd_logical_driver *drvthis, int x, int y, char c)
// switches the backlight on/off // switches the backlight on/off
// //
MODULE_EXPORT void MODULE_EXPORT void
ms6931_backlight (struct lcd_logical_driver *drvthis, int on) ms6931_backlight (Driver *drvthis, int on)
{ {
static int saved_state = -1; static int saved_state = -1;
static char out[3] = { '~', 0x01, 0 }; static char out[3] = { '~', 0x01, 0 };
@@ -309,7 +309,7 @@ ms6931_backlight (struct lcd_logical_driver *drvthis, int on)
// sets the cursor // sets the cursor
// //
MODULE_EXPORT void MODULE_EXPORT void
ms6931_cursor (struct lcd_logical_driver *drvthis, int x, int y, int state) ms6931_cursor (Driver *drvthis, int x, int y, int state)
{ {
static int saved_state = -1; static int saved_state = -1;
static char out[3] = { '~', 0x23, 0 }; static char out[3] = { '~', 0x23, 0 };
@@ -339,7 +339,7 @@ ms6931_cursor (struct lcd_logical_driver *drvthis, int x, int y, int state)
// Clears the framebuffer and the display // Clears the framebuffer and the display
// //
MODULE_EXPORT void MODULE_EXPORT void
ms6931_clear (struct lcd_logical_driver *drvthis) ms6931_clear (Driver *drvthis)
{ {
// ms6931_write("~\042", 2); // ms6931_write("~\042", 2);
memset (framebuf, ' ', width * height); memset (framebuf, ' ', width * height);
@@ -350,7 +350,7 @@ ms6931_clear (struct lcd_logical_driver *drvthis)
// upper-left is (1,1), and the lower right should be (16,2). // upper-left is (1,1), and the lower right should be (16,2).
// //
MODULE_EXPORT void MODULE_EXPORT void
ms6931_string (struct lcd_logical_driver *drvthis, int x, int y, char string[]) ms6931_string (Driver *drvthis, int x, int y, char string[])
{ {
int i; int i;
@@ -371,7 +371,7 @@ ms6931_string (struct lcd_logical_driver *drvthis, int x, int y, char string[])
// draw a horizontal bar (vertical makes no sense on ms-6931 // draw a horizontal bar (vertical makes no sense on ms-6931
// //
MODULE_EXPORT void MODULE_EXPORT void
ms6931_hbar (struct lcd_logical_driver *drvthis, int x, int y, int len, int promille, int pattern) ms6931_hbar (Driver *drvthis, int x, int y, int len, int promille, int pattern)
{ {
char bar[17]; char bar[17];
int max = width - x; int max = width - x;
@@ -399,7 +399,7 @@ report(RPT_DEBUG, "ms6931_hbar: len=%d, size=%d, promile=%d", len, size, promill
// Does the heartbeat... // Does the heartbeat...
// //
MODULE_EXPORT void MODULE_EXPORT void
ms6931_heartbeat (struct lcd_logical_driver *drvthis, int state) ms6931_heartbeat (Driver *drvthis, int state)
{ {
static int timer = 0; static int timer = 0;
char whichChar; char whichChar;
@@ -423,7 +423,7 @@ ms6931_heartbeat (struct lcd_logical_driver *drvthis, int state)
// //
MODULE_EXPORT char MODULE_EXPORT char
ms6931_get_key (struct lcd_logical_driver *drvthis) ms6931_get_key (Driver *drvthis)
{ {
int ret; int ret;
char buf; char buf;
+14 -14
View File
@@ -33,21 +33,21 @@
#define MS6931_DEF_CELL_HEIGHT 8 #define MS6931_DEF_CELL_HEIGHT 8
MODULE_EXPORT int ms6931_init (struct lcd_logical_driver *drvthis, char *args); MODULE_EXPORT int ms6931_init (Driver *drvthis, char *args);
MODULE_EXPORT void ms6931_close (struct lcd_logical_driver *drvthis); MODULE_EXPORT void ms6931_close (Driver *drvthis);
MODULE_EXPORT int ms6931_width (struct lcd_logical_driver *drvthis); MODULE_EXPORT int ms6931_width (Driver *drvthis);
MODULE_EXPORT int ms6931_height(struct lcd_logical_driver *drvthis); MODULE_EXPORT int ms6931_height(Driver *drvthis);
MODULE_EXPORT void ms6931_flush (struct lcd_logical_driver *drvthis); MODULE_EXPORT void ms6931_flush (Driver *drvthis);
MODULE_EXPORT int ms6931_get_contrast (struct lcd_logical_driver *drvthis); MODULE_EXPORT int ms6931_get_contrast (Driver *drvthis);
MODULE_EXPORT void ms6931_set_contrast (struct lcd_logical_driver *drvthis, int promille); MODULE_EXPORT void ms6931_set_contrast (Driver *drvthis, int promille);
MODULE_EXPORT void ms6931_backlight (struct lcd_logical_driver *drvthis, int on); MODULE_EXPORT void ms6931_backlight (Driver *drvthis, int on);
MODULE_EXPORT void ms6931_chr (struct lcd_logical_driver *drvthis, int x, int y, char c); MODULE_EXPORT void ms6931_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void ms6931_clear (struct lcd_logical_driver *drvthis); MODULE_EXPORT void ms6931_clear (Driver *drvthis);
MODULE_EXPORT void ms6931_string (struct lcd_logical_driver *drvthis, int x, int y, char string[]); MODULE_EXPORT void ms6931_string (Driver *drvthis, int x, int y, char string[]);
MODULE_EXPORT char ms6931_get_key (struct lcd_logical_driver *drvthis); MODULE_EXPORT char ms6931_get_key (Driver *drvthis);
MODULE_EXPORT void ms6931_hbar (struct lcd_logical_driver *drvthis, int x, int y, int len, int promille, int pattern); MODULE_EXPORT void ms6931_hbar (Driver *drvthis, int x, int y, int len, int promille, int pattern);
MODULE_EXPORT void ms6931_heartbeat (struct lcd_logical_driver *drvthis, int state); MODULE_EXPORT void ms6931_heartbeat (Driver *drvthis, int state);
#endif /* ndef MS6931_H */ #endif /* ndef MS6931_H */
+37 -135
View File
@@ -57,6 +57,9 @@
//#include "shared/str.h" //#include "shared/str.h"
#include "report.h" #include "report.h"
#define MTC_DEFAULT_DEVICE "/dev/lcd"
#define MTC_DEFAULT_BRIGHTNESS 255
int my_error_handle; int my_error_handle;
char lcd_open[] = "\xFE\x28"; // From OpenCommPort() char lcd_open[] = "\xFE\x28"; // From OpenCommPort()
@@ -80,39 +83,6 @@ char lcd_showunderline[] = "\xFE\x0E"; // From Show_UnderLine()
char lcd_hideunderline[] = "\xFE\x0B"; // From Hide_UnderLine() char lcd_hideunderline[] = "\xFE\x0B"; // From Hide_UnderLine()
int
get_args (char **argv, char *str, int max_args)
{
char *delimiters = " \n\0";
char *item;
int i = 0;
if (!argv)
return -1;
if (!str)
return 0;
if (max_args < 1)
return 0;
//debug("get_args(%i): string=%s\n", max_args, str);
// Parse the command line...
for (item = strtok (str, delimiters); item;
item = strtok (NULL, delimiters))
{
//debug("get_args: item=%s\n", item);
if (i < max_args)
{
argv[i] = item;
i++;
}
else
return i;
}
return i;
}
static int custom = 0; static int custom = 0;
typedef enum typedef enum
@@ -147,113 +117,50 @@ MODULE_EXPORT char *symbol_prefix = "MTC_S16209X_";
MODULE_EXPORT int MODULE_EXPORT int
MTC_S16209X_init (Driver * drvthis, char *args) MTC_S16209X_init (Driver * drvthis, char *args)
{ {
char *argv[64];
int argc;
struct termios portset; struct termios portset;
int i; char device[256] = MTC_DEFAULT_DEVICE;
#ifdef CAN_REBOOT_LCD #ifdef CAN_REBOOT_LCD
int reboot = 0; int reboot = 0;
#endif // CAN_REBOOT_LCD #endif // CAN_REBOOT_LCD
char device[256] = "/dev/lcd";
#ifdef CAN_CONTROL_BACKLIGHT #ifdef CAN_CONTROL_BACKLIGHT
int tmp; int tmp;
int backlight_brightness = 255; int backlight_brightness = 255;
#endif // CAN_CONTROL_BACKLIGHT #endif // CAN_CONTROL_BACKLIGHT
//debug("MTC_S16209X_init: Args(all): %s\n", args); /* Read config file */
argc = get_args (argv, args, 64); /* What device should be used */
strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0,
/* MTC_DEFAULT_DEVICE), sizeof(device));
device[sizeof(device)-1] = '\0';
for(i=0; i<argc; i++)
{
printf("Arg(%i): %s\n", i, argv[i]);
}
*/
for (i = 0; i < argc; i++)
{
//printf("Arg(%i): %s\n", i, argv[i]);
if (0 == strcmp (argv[i], "-d") || 0 == strcmp (argv[i], "--device"))
{
if (i + 1 > argc)
{
fprintf (stderr, "MTC_S16209X_init: %s requires an argument\n",
argv[i]);
return -1;
}
strcpy (device, argv[++i]);
}
#ifdef CAN_CONTROL_BACKLIGHT #ifdef CAN_CONTROL_BACKLIGHT
else if (0 == strcmp (argv[i], "-b") || /* Which backlight brightness */
0 == strcmp (argv[i], "--brightness")) backlight_brightness = drvthis->config_get_int ( drvthis->name , "Brightness" , 0 , MTC_DEFAULT_BRIGHTNESS);
{ if ((backlight_brightness < 0) || (backlight_brightness > 255)) {
if (i + 1 > argc) report (RPT_WARNING, "MTC_S16209X_init: Brightness must be between 0 and 255. Using default value.\n");
{ backlight_brightness = MTC_DEFAULT_BRIGHTNESS;
fprintf (stderr, "MTC_S16209X_init: %s requires an argument\n", }
argv[i]);
return -1;
}
tmp = atoi (argv[++i]);
if ((tmp < 0) || (tmp > 255))
{
fprintf (stderr,
"MTC_S16209X_init: %s argument must between 0 and 255. Using default value.\n",
argv[i]);
}
else
backlight_brightness = tmp;
}
#endif // CAN_CONTROL_BACKLIGHT #endif // CAN_CONTROL_BACKLIGHT
else if (0 == strcmp (argv[i], "-h") || 0 == strcmp (argv[i], "--help"))
{
printf ("LCDproc MTC_S16209X LCD driver\n"
"\t-d\t--device\tSelect the output device to use [/dev/lcd]\n"
"\t-t\t--type\t\tSelect the LCD type (size) [16x2]\n"
#ifdef CAN_CONTROL_BACKLIGHT
"\t-b\t--brightness\tSet the initial brightness [255]\n"
#endif // CAN_CONTROL_BACKLIGHT
"\t-r\t--reboot\tReinitialize the LCD's BIOS\n"
"\t-h\t--help\t\tShow this help information\n");
return -1;
}
#ifdef CAN_REBOOT_LCD #ifdef CAN_REBOOT_LCD
else if (0 == strcmp (argv[i], "-r") || /* Reboot display? */
0 == strcmp (argv[i], "--reboot")) reboot = drvthis->config_get_bool( drvthis->name , "Reboot", 0, 0);
{ if (reboot)
printf ("LCDd: rebooting MTC_S16209X LCD...\n"); report (RPT_INFO, "LCDd: rebooting MTC_S16209x LCD...\n");
reboot = 1;
}
#endif // CAN_REBOOT_LCD #endif // CAN_REBOOT_LCD
else /* End of config file parsing */
{
printf ("Invalid parameter: %s\n", argv[i]);
}
}
// Set up io port correctly, and open it... // Set up io port correctly, and open it...
fd = open (device, O_RDWR | O_NOCTTY | O_NDELAY); fd = open (device, O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1) if (fd == -1) {
{ report(RPT_ERR, "MTC_S16209X_init: open(%s) failed (%s)\n", device, strerror(errno));
fprintf (stderr, "MTC_S16209X_init: failed (%s)\n", strerror (errno)); return -1;
return -1; }
} report(RPT_DEBUG, "MTC_S16209X_init: opened device %s\n", device);
/*
else
fprintf (stderr, "MTC_S16209X_init: opened device %s\n", device);
*/
fcntl (fd, F_SETFL, 0); // Set port for reading fcntl (fd, F_SETFL, 0); // Set port for reading
tcgetattr (fd, &portset); // Get current port attributes tcgetattr (fd, &portset); // Get current port attributes
@@ -277,19 +184,14 @@ MTC_S16209X_init (Driver * drvthis, char *args)
my_error_handle = write (fd, lcd_open, sizeof (lcd_open)); // Send the init string to the LCD my_error_handle = write (fd, lcd_open, sizeof (lcd_open)); // Send the init string to the LCD
if (my_error_handle < 0) if (my_error_handle < 0)
{ report(RPT_WARNING, "MTC_S16209X_init(): write(lcd_open) failed (%s)\n",
fprintf (stderr, "MTC_S16209X_init(): write(lcd_open) failed (%s)\n", strerror(errno));
strerror (errno));
}
my_error_handle = write (fd, lcd_clearscreen, sizeof (lcd_clearscreen)); // Clear the LCD, unbuffered my_error_handle = write (fd, lcd_clearscreen, sizeof (lcd_clearscreen)); // Clear the LCD, unbuffered
if (my_error_handle < 0) if (my_error_handle < 0)
{ report(RPT_WARNING, "MTC_S16209X_init(): write(lcd_clearscreen) failed (%s)\n",
fprintf (stderr, strerror(errno));
"MTC_S16209X_init(): write(lcd_clearscreen) failed (%s)\n",
strerror (errno));
}
return 0; return 0;
} }
@@ -308,8 +210,8 @@ MTC_S16209X_close (Driver * drvthis)
flock (fd, LOCK_UN); flock (fd, LOCK_UN);
if (my_error_handle < 0) if (my_error_handle < 0)
fprintf (stderr, report(RPT_WARNING, "MTC_S16209X_close(): Write() failed! (%s)\n",
"MTC_S16209X_close(): Write() failed! (%s)\n", strerror (errno)); strerror(errno));
usleep (10); usleep (10);
@@ -362,8 +264,8 @@ MTC_S16209X_flush (Driver * drvthis)
flock (fd, LOCK_UN); flock (fd, LOCK_UN);
if (my_error_handle < 0) if (my_error_handle < 0)
fprintf (stderr, "MTC_S16209X_flush(): Couldn't write 1st line (%s)\n", report(RPT_WARNING, "MTC_S16209X_flush(): Couldn't write 1st line (%s)\n",
strerror (errno)); strerror(errno));
// 2nd step: flush 2nd line: // 2nd step: flush 2nd line:
flock (fd, LOCK_EX); flock (fd, LOCK_EX);
@@ -372,8 +274,8 @@ MTC_S16209X_flush (Driver * drvthis)
flock (fd, LOCK_UN); flock (fd, LOCK_UN);
if (my_error_handle < 0) if (my_error_handle < 0)
fprintf (stderr, "MTC_S16209X_flush(): Couldn't write 2nd line (%s)\n", report(RPT_WARNING, "MTC_S16209X_flush(): Couldn't write 2nd line (%s)\n",
strerror (errno)); strerror(errno));
// Wait until serial port cache has been emptied (else clients gets // Wait until serial port cache has been emptied (else clients gets
// the message to bugger off after a while) // the message to bugger off after a while)
@@ -422,8 +324,8 @@ MTC_S16209X_hidecursor ()
flock (fd, LOCK_UN); flock (fd, LOCK_UN);
if (my_error_handle < 0) if (my_error_handle < 0)
fprintf (stderr, "MTC_S16209X_hidecursor(): Write failed: %s\n", report(RPT_WARNING, "MTC_S16209X_hidecursor(): Write failed: %s\n",
strerror (errno)); strerror(errno));
} }
#endif // THIS_PART_SHOULD_BE_REMOVED #endif // THIS_PART_SHOULD_BE_REMOVED
+3 -1
View File
@@ -466,8 +466,10 @@ sed1330_init( Driver * drvthis, char *args )
port_access(p->port+1); port_access(p->port+1);
port_access(p->port+2); port_access(p->port+2);
if (timing_init() == -1) if (timing_init() == -1) {
report(RPT_ERR, "timing_init: failed (%s)\n", strerror(errno));
return -1; return -1;
}
// INITIALIZE THE LCD // INITIALIZE THE LCD
// End reset-state // End reset-state
+9 -58
View File
@@ -51,6 +51,7 @@
#include "shared/str.h" #include "shared/str.h"
#include "lcd.h" #include "lcd.h"
#include "sed1520.h" #include "sed1520.h"
#include "report.h"
unsigned int sed1520_lptport = LPTPORT; unsigned int sed1520_lptport = LPTPORT;
@@ -148,67 +149,17 @@ drawchar2fb (int x, int y, unsigned char z)
MODULE_EXPORT int MODULE_EXPORT int
sed1520_init (Driver *drvthis, char *args) sed1520_init (Driver *drvthis, char *args)
{ {
char *argv[64], *str; /* Read config file */
int argc, i;
if (args) /* What port to use */
if ((str = (char *) malloc (strlen (args) + 1))) sed1520_lptport = drvthis->config_get_int(drvthis->name, "Port", 0, LPTPORT);
strcpy (str, args);
else
{
fprintf (stderr, "Error mallocing\n");
return -1;
}
else
str = NULL;
argc = get_args (argv, args, 64); /* End of config file parsing */
for (i = 0; i < argc; i++)
{
if (0 == strcmp (argv[i], "-p")
|| 0 == strcmp (argv[i], "--port\0"))
{
if (i + 1 >= argc)
{
fprintf (stderr,
"sed1520_init: %s requires an argument\n",
argv[i]);
return -1;
}
else
{
int myport;
if (sscanf (argv[i + 1], "%i", &myport) != 1)
{
fprintf (stderr,
"sed1520_init: Couldn't read port address -"
" using default value 0x%x\n", sed1520_lptport);
return -1;
}
else
{
sed1520_lptport = myport;
++i;
}
}
}
else if (0 == strcmp (argv[i], "-h")
|| 0 == strcmp (argv[i], "--help"))
{
//int i;
printf
("LCDproc sed1520 driver\n\t-p n\t--port n\tSelect the output device to use port n\n");
printf ("put the options in quotes like this: '-p 0x278'\n");
printf ("\t-h\t--help\t\tShow this help information\n");
return -1;
}
}
// driver->wid = 20; if (timing_init() == -1) {
// driver->hgt = 4; report(RPT_ERR, "timing_init: failed (%s)\n", strerror(errno));
return -1;
if (timing_init() == -1) }
return -1;
// Allocate our framebuffer // Allocate our framebuffer
framebuf = malloc (122 * 4); framebuf = malloc (122 * 4);
+20 -65
View File
@@ -36,6 +36,7 @@
#include "shared/str.h" #include "shared/str.h"
#include "lcd.h" #include "lcd.h"
#include "stv5730.h" #include "stv5730.h"
#include "report.h"
#ifndef LPTPORT #ifndef LPTPORT
@@ -282,77 +283,32 @@ stv5730_drawchar2fb (int x, int y, unsigned char z)
MODULE_EXPORT int MODULE_EXPORT int
stv5730_init (Driver *drvthis, char *args) stv5730_init (Driver *drvthis, char *args)
{ {
char *argv[64], *str; int i;
int argc, i;
if (args) /* Read config file */
if ((str = (char *) malloc (strlen (args) + 1)))
strcpy (str, args);
else
{
fprintf (stderr, "Error mallocing\n");
return -1;
}
else
str = NULL;
argc = get_args (argv, args, 64); /* What port to use */
for (i = 0; i < argc; i++) stv5730_lptport = drvthis->config_get_int(drvthis->name, "Port", 0, LPTPORT);
{
if (0 == strcmp (argv[i], "-p")
|| 0 == strcmp (argv[i], "--port\0"))
{
if (i + 1 >= argc)
{
fprintf (stderr,
"stv5730_init: %s requires an argument\n",
argv[i]);
return -1;
}
else
{
int myport;
if (sscanf (argv[i + 1], "%i", &myport) != 1)
{
fprintf (stderr,
"stv5730_init: Couldn't read port address -"
" using default value 0x%x\n",
stv5730_lptport);
return -1;
}
else
{
stv5730_lptport = myport;
++i;
}
}
}
else if (0 == strcmp (argv[i], "-h")
|| 0 == strcmp (argv[i], "--help"))
{
//int i;
printf
("LCDproc stv5730 driver\n\t-p n\t--port n\tSelect the output device to use port n\n");
printf ("put the options in quotes like this: '-p 0x278'\n");
printf ("\t-h\t--help\t\tShow this help information\n");
return -1;
}
}
if (timing_init() == -1) /* End of config file parsing */
return -1;
if (timing_init() == -1) {
report(RPT_ERR, "timing_init: failed (%s)\n", strerror(errno));
return -1;
}
// Initialize the Port and the stv5730 // Initialize the Port and the stv5730
if (port_access (stv5730_lptport) || port_access (stv5730_lptport + 1)) if (port_access (stv5730_lptport) || port_access (stv5730_lptport + 1))
{ {
printf report(RPT_ERR,
("Couldn't get IO-permission for 0x%X ! Are we running as root ?\n ", "Couldn't get IO-permission for 0x%X ! Are we running as root ?\n ",
stv5730_lptport); return -1; stv5730_lptport);
return -1;
}; };
if (stv5730_detect ()) if (stv5730_detect ())
{ {
printf ("No STV5730 hardware found at 0x%X !\n ", stv5730_lptport); report(RPT_ERR, "No STV5730 hardware found at 0x%X !\n ", stv5730_lptport);
return -1; return -1;
}; };
@@ -371,12 +327,12 @@ stv5730_init (Driver *drvthis, char *args)
stv5730_write16bit (STV5730_REG_CONTROL); stv5730_write16bit (STV5730_REG_CONTROL);
stv5730_write16bit (0x1FF4); stv5730_write16bit (0x1FF4);
printf ("Detecting Video Signal: "); report(RPT_INFO, "Detecting Video Signal: ");
usleep (50000); usleep (50000);
if (stv5730_is_mute ()) if (stv5730_is_mute ())
{ {
printf ("No Video Signal found, using full page mode.\n"); report(RPT_INFO, "No Video Signal found, using full page mode.\n");
// Setup Mode + Control for full page mode // Setup Mode + Control for full page mode
stv5730_charattrib = STV5730_ATTRIB; stv5730_charattrib = STV5730_ATTRIB;
stv5730_write16bit (STV5730_REG_MODE); stv5730_write16bit (STV5730_REG_MODE);
@@ -390,11 +346,10 @@ stv5730_init (Driver *drvthis, char *args)
stv5730_write16bit (0x1ED4); stv5730_write16bit (0x1ED4);
#endif #endif
} }
else else
{ {
printf ("Video Signal found, using mixed mode (B&W).\n"); report(RPT_INFO, "Video Signal found, using mixed mode (B&W).\n");
// Setup Mode + Control for mixed mode, disable color // Setup Mode + Control for mixed mode, disable color
stv5730_charattrib = 0; stv5730_charattrib = 0;
stv5730_write16bit (STV5730_REG_MODE); stv5730_write16bit (STV5730_REG_MODE);
@@ -429,7 +384,7 @@ stv5730_init (Driver *drvthis, char *args)
stv5730_write16bit (0x10C0); stv5730_write16bit (0x10C0);
} }
// Alocate our own framebuffer // Allocate our own framebuffer
stv5730_framebuf = malloc (STV5730_WID * STV5730_HGT); stv5730_framebuf = malloc (STV5730_WID * STV5730_HGT);
if (!stv5730_framebuf) if (!stv5730_framebuf)
{ {
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef LCD_SVGALIB_H #ifndef LCD_SVGALIB_H
#define LCD_SVGALIB_H #define LCD_SVGALIB_H
MODULE_EXPORT int svgalib_drv_init (Driver *driver, char *args); MODULE_EXPORT int svgalib_drv_init (Driver *drvthis, char *args);
MODULE_EXPORT void svgalib_drv_close (Driver *drvthis); MODULE_EXPORT void svgalib_drv_close (Driver *drvthis);
MODULE_EXPORT int svgalib_drv_width (Driver *drvthis); MODULE_EXPORT int svgalib_drv_width (Driver *drvthis);
MODULE_EXPORT int svgalib_drv_height (Driver *drvthis); MODULE_EXPORT int svgalib_drv_height (Driver *drvthis);
+5 -11
View File
@@ -190,9 +190,7 @@ text_chr (Driver *drvthis, int x, int y, char c)
MODULE_EXPORT void MODULE_EXPORT void
text_set_contrast (Driver *drvthis, int promille) text_set_contrast (Driver *drvthis, int promille)
{ {
/* debug(RPT_DEBUG, "Contrast: %d\n", promille);
printf("Contrast: %d\n", promille);
*/
} }
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
@@ -203,15 +201,11 @@ text_backlight (Driver *drvthis, int on)
{ {
//PrivateData * p = (PrivateData*) drvthis->private_data; //PrivateData * p = (PrivateData*) drvthis->private_data;
/* if(on) {
if(on) debug(RPT_DEBUG, "Backlight ON\n");
{
printf("Backlight ON\n");
} }
else else {
{ debug(RPT_DEBUG, "Backlight OFF\n");
printf("Backlight OFF\n");
} }
*/
} }
-1
View File
@@ -125,7 +125,6 @@ static inline int timing_init() {
struct sched_param param; struct sched_param param;
param.sched_priority=1; param.sched_priority=1;
if (( sched_setscheduler(0, SCHED_RR, &param)) == -1) { if (( sched_setscheduler(0, SCHED_RR, &param)) == -1) {
fprintf (stderr, "timing_init: failed (%s)\n", strerror (errno));
return -1; return -1;
} }
} }
+29 -56
View File
@@ -19,10 +19,13 @@
#include "lcd.h" #include "lcd.h"
#include "wirz-sli.h" #include "wirz-sli.h"
//#include "drv_base.h" //#include "drv_base.h"
#include "report.h"
#include "shared/debug.h" #include "shared/debug.h"
#include "shared/str.h" #include "shared/str.h"
#define SLI_DEFAULT_DEVICE "/dev/lcd"
static int custom = 0; static int custom = 0;
typedef enum { typedef enum {
hbar = 1, hbar = 1,
@@ -49,74 +52,44 @@ MODULE_EXPORT char *symbol_prefix = "sli_";
MODULE_EXPORT int MODULE_EXPORT int
sli_init (Driver *drvthis, char *args) sli_init (Driver *drvthis, char *args)
{ {
char *argv[64];
int argc;
struct termios portset; struct termios portset;
int i;
int tmp;
char out[2]; char out[2];
char device[256] = "/dev/lcd"; char device[256] = WIRZ_DEFAULT_DEVICE;
int speed = B19200; int speed = B19200;
//debug("sli_init: Args(all): %s\n", args); /* Read config file */
argc = get_args (argv, args, 64); /* What device should be used */
strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0,
SLI_DEFAULT_DEVICE), sizeof(device));
device[sizeof(device)-1] = '\0';
/* /* What speed to use */
for(i=0; i<argc; i++) speed = drvthis->config_get_int(drvthis->name, "Speed", 0, 19200);
{
printf("Arg(%i): %s\n", i, argv[i]);
}
*/
for (i = 0; i < argc; i++) {
//printf("Arg(%i): %s\n", i, argv[i]);
if (0 == strcmp (argv[i], "-d") || 0 == strcmp (argv[i], "--device")) {
if (i + 1 > argc) {
fprintf (stderr, "sli_init: %s requires an argument\n", argv[i]);
return -1;
}
strcpy (device, argv[++i]);
} else if (0 == strcmp (argv[i], "-s") || 0 == strcmp (argv[i], "--speed")) {
if (i + 1 > argc) {
fprintf (stderr, "sli_init: %s requires an argument\n", argv[i]);
return -1;
}
tmp = atoi (argv[++i]);
if (tmp == 1200)
speed = B1200;
else if (tmp == 2400)
speed = B2400;
else if (tmp == 9600)
speed = B9600;
else if (tmp == 19200)
speed = B19200;
else if (tmp == 38400)
speed = B38400;
else if (tmp == 57600)
speed = B57600;
else if (tmp == 115200)
speed = B115200;
else {
fprintf (stderr, "sli_init: %s argument must be 1200, 2400, 9600, 19200, 38400, 57600, or 115200. Using default value (19200).\n", argv[i]);
}
} else if (0 == strcmp (argv[i], "-h") || 0 == strcmp (argv[i], "--help")) {
printf ("LCDproc Wirz SLI LCD driver\n" "\t-d\t--device\tSelect the output device to use [/dev/lcd]\n" "\t-s\t--speed\t\tSet the communication speed [19200]\n" "\t-h\t--help\t\tShow this help information\n");
return -1;
} else {
printf ("Invalid parameter: %s\n", argv[i]);
}
if (speed == 1200) speed = B1200;
else if (speed == 2400) speed = B2400;
else if (speed == 9600) speed = B9600;
else if (speed == 19200) speed = B19200;
else if (speed == 38400) speed = B38400;
else if (speed == 57600) speed = B57600;
else if (speed == 115200) speed = B115200;
else {
report(RPT_WARNING, "sli: Illegal speed: %d. Must be one of 1200, 2400, 9600, 19200, 38400, 57600, or 115200. Using default.\n", speed);
speed = B19200;
} }
/* End of config file parsing */
// Set up io port correctly, and open it... // Set up io port correctly, and open it...
fd = open (device, O_RDWR | O_NOCTTY | O_NDELAY); fd = open (device, O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1) { if (fd == -1) {
fprintf (stderr, "sli_init: failed (%s)\n", strerror (errno)); report(RPT_ERR, "sli_init: open(%s) failed (%s)\n", device, strerror (errno));
return -1; return -1;
} }
//else fprintf(stderr, "sli_init: opened device %s\n", device); report(RPT_DEBUG, "sli_init: opened device %s\n", device);
tcgetattr (fd, &portset); tcgetattr (fd, &portset);
// We use RAW mode // We use RAW mode
@@ -142,10 +115,10 @@ sli_init (Driver *drvthis, char *args)
/* Initialize SLI using autobaud detection, and then turn off cursor /* Initialize SLI using autobaud detection, and then turn off cursor
and clear screen */ and clear screen */
usleep (150000); /* 150ms delay to allow SLI to power on */ usleep (150000); /* 150ms delay to allow SLI to power on */
out[0] = 13; /* CR for SLI autobaud */ out[0] = 13; /* CR for SLI autobaud */
write (fd, out, 1); write (fd, out, 1);
usleep (3000); /* 3ms delay.. wait for it to autobaud */ usleep (3000); /* 3ms delay.. wait for it to autobaud */
out[0] = 0x0FE; out[0] = 0x0FE;
out[1] = 0x00C; /* No cursor */ out[1] = 0x00C; /* No cursor */
write (fd, out, 2); write (fd, out, 2);