add support for the glcdlib meta driver by Lucian Muresan

This commit is contained in:
marschap
2005-05-16 10:57:28 +00:00
parent 8a5458fda6
commit 3caefc4e87
8 changed files with 557 additions and 5 deletions
+50
View File
@@ -38,6 +38,7 @@ Driver=curses
#Driver=MtxOrb
#Driver=CFontz633
#Driver=CwLnx
#Driver=glcdlib
# Tells the driver to bind to the given interface
Bind=127.0.0.1
@@ -561,4 +562,53 @@ Device=/dev/lcd
Speed=19200
## glcdlib meta driver for graphical LCDs ##
[glcdlib]
## mandatory:
# which graphical display supported by graphlcd-base to use
# (see /etc/graphlcd.conf for possible drivers)
Driver=noritake800
# no=use graphlcd bitmap fonts (they have only one size / font file)
# yes=use fonts supported by FreeType2 (needs Freetype2 support in libglcdprocdriver and its dependants)
UseFT2=yes
# text resolution in fixed width characters (if it won't fit according
# to available physical pixel resolution and the minimum available font
# face size in pixels, 'DebugBorder' will automatically be turned on)
TextResolution=20x4
# path to font file to use
FontFile=/usr/share/fonts/corefonts/courbd.ttf # path to font file to use
#FontFile=/fonts/f8b.fnt # path to font file to use
## these only apply if UseFT2=yes:
# character encoding to use
CharEncoding=iso8859-2
# minumum size in pixels in which fonts should be rendered
MinFontFaceSize=7x12
## optional:
Brightness=50 # Brightness (in %) if applicable
Contrast=50 # Contrast (in %) if applicable
Backlight=no # Backlight if applicable
UpsideDown=no # flip image upside down
Invert=no # invert light/dark pixels
ShowDebugFrame=no # turns on/off 1 pixel thick debugging
# border whithin the usable text area,
# for setting up TextResolution and
# MinFontFaceSize (if unsing FT2);
ShowBigBorder=no # border around the unused area
ShowThinBorder=yes # border around the unused area
PixelShiftX=0
PixelshiftY=2
# EOF
+8
View File
@@ -0,0 +1,8 @@
The so-called "meta-driver" glcdlib extends LCDproc's supported drivers by
all the drivers supported by graphlcd-base, which you can get from
http://graphlcd.berlios.de.
In order to be able to use it, you have to get and install the glcdprocdriver
from http://www.muresan.de/graphlcd/lcdproc before configuring the LCDproc
build process --enable-drivers=glcdlib.
Lucian Muresan
+14 -3
View File
@@ -8,13 +8,13 @@ AC_ARG_ENABLE(drivers,
[ mtxorb,cfontz,cfontz633,curses,cwlnx,text,lb216,]
[ hd44780,joy,irman,lirc,bayrad,glk,,mtc_s16209x]
[ stv5730,sed1330,sed1520,svga,lcdm001,t6963]
[ lcterm,icp_a106,ms6931,iowarrior]
[ lcterm,icp_a106,ms6931,iowarrior,glcdlib]
[ \"all\" compiles all drivers],
drivers="$enableval",
drivers=[lcdm001,mtxorb,cfontz,cfontz633,curses,cwlnx,text,lb216,bayrad,glk])
if test "$drivers" = "all"; then
drivers=[mtxorb,cfontz,cfontz633,curses,cwlnx,text,lb216,mtc_s16209x,hd44780,joy,irman,lirc,bayrad,glk,stv5730,sed1330,sed1520,svga,lcdm001,t6963,lcterm,icp_a106,ms6931,iowarrior]
drivers=[mtxorb,cfontz,cfontz633,curses,cwlnx,text,lb216,mtc_s16209x,hd44780,joy,irman,lirc,bayrad,glk,stv5730,sed1330,sed1520,svga,lcdm001,t6963,lcterm,icp_a106,ms6931,iowarrior,glcdlib]
fi
drivers=`echo $drivers | sed 's/,/ /g'`
@@ -230,7 +230,17 @@ dnl else
AC_MSG_WARN([The sed1330 driver needs a parallel port.])
fi
;;
*)
glcdlib)
AC_CHECK_HEADERS([glcdproclib/glcdprocdriver.h],[
LIBGLCD="-lglcddrivers -lglcdgraphics -lglcdprocdriver"
DRIVERS="$DRIVERS glcdlib${SO}"
actdrivers=["$actdrivers glcdlib"]
],[
dnl else
AC_MSG_WARN([The glcdlib driver needs glcdproclib/glcdprocdriver.h])
])
;;
*)
AC_MSG_ERROR([Unknown driver $driver])
;;
esac
@@ -245,6 +255,7 @@ AC_SUBST(LIBLIRC_CLIENT)
AC_SUBST(LIBSVGA)
AC_SUBST(DRIVERS)
AC_SUBST(HD44780_DRIVERS)
AC_SUBST(LIBGLCD)
])
+3
View File
@@ -68,6 +68,9 @@ CrystalFontz LCD displays
.B curses (or ncurses)
Standard video display using the ncurses library
.TP
.B glcdlib
graphical LCDs supported by graphlcd-base
.TP
.B HD44780
Hitachi HD44780 LCD displays
.TP
+1 -1
View File
@@ -74,7 +74,7 @@ Available options are:
Currently available drivers:
lcdm001, LCDM001, MtxOrb, MatrixOrbital, CFontz, CrystalFontz, LB216, text,
curses, ncurses, BayRAD, glk, glc, IOWarrior
curses, ncurses, BayRAD, glk, glc, IOWarrior, glcdlib
]]>
+3 -1
View File
@@ -18,7 +18,7 @@ AM_LDFLAGS = @LDSHARED@
LIBS =
pkglib_PROGRAMS = @DRIVERS@
EXTRA_PROGRAMS = bayrad CFontz CFontz633 curses CwLnx glk hd44780 irman icp_a106 joy lb216 mtc_s16209x lcdm001 lcterm lirc MtxOrb sed1330 sed1520 stv5730 svga t6963 text wirz_sli ms6931 IOWarrior
EXTRA_PROGRAMS = bayrad CFontz CFontz633 curses CwLnx glk hd44780 irman icp_a106 joy lb216 mtc_s16209x lcdm001 lcterm lirc MtxOrb sed1330 sed1520 stv5730 svga t6963 text wirz_sli ms6931 IOWarrior glcdlib
noinst_LIBRARIES = libLCD.a
IOWarrior_CFLAGS = @libusb_cflags@
@@ -38,6 +38,7 @@ lirc_LDADD = @LIBLIRC_CLIENT@
lcterm_LDADD = libLCD.a
svga_LDADD = @LIBSVGA@
t6963_LDADD = libLCD.a
glcdlib_LDADD = libLCD.a @LIBGLCD@
libLCD_a_SOURCES = lcd_lib.h lcd_lib.c
@@ -67,5 +68,6 @@ t6963_SOURCES = lcd.h t6963.c t6963.h t6963_font.h report.h
text_SOURCES = lcd.h text.h text.c report.h
wirz_sli_SOURCES = lcd.h wirz-sli.h wirz-sli.c report.h
ms6931_SOURCES = lcd.h ms6931.h ms6931.c report.h
glcdlib_SOURCES = lcd.h glcdlib.h glcdlib.c report.h
INCLUDES = -I$(top_srcdir)
+425
View File
@@ -0,0 +1,425 @@
/*
* This so-called "meta-driver" extends LCDproc's supported drivers by
* all the drivers supported by graphlcd-base, which you can get from
* http://graphlcd.berlios.de.
* In order to be able to use it, you have to get and install the glcdprocdriver
* from http://www.muresan.de/graphlcd/lcdproc.
*
* This file is released under the GNU General Public License. Refer to the
* COPYING file distributed with this package.
*
* Copyright (c) 2005 Lucian Muresan <lucianm AT users.sourceforge.net>
*
*
*/
#include <glcdproclib/glcdprocdriver.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "lcd.h"
#include "lcd_lib.h"
#include "shared/debug.h"
//#define DEBUG
#include "report.h"
#include "glcdlib.h"
#define DEBUG3 if(debug_level > 2) printf
#define DEBUG4 if(debug_level > 3) printf
#define debug_level 2
//extern int debug_level;
// our private data
typedef struct {
GlcdDriver * glcdDriver;
char info[255];
} glcdlibPD;
// Vars for the server core
MODULE_EXPORT char *api_version = API_VERSION;
MODULE_EXPORT int stay_in_foreground = 0;
MODULE_EXPORT int supports_multiple = 0;
MODULE_EXPORT char *symbol_prefix = "glcdlib_";
MODULE_EXPORT int glcdlib_init (Driver *drvthis, char *args)
{
glcdlibPD * pPD;
// Alocate, initialize and store private p
pPD = (glcdlibPD *) malloc( sizeof(glcdlibPD) );
if(!pPD)
{
debug(RPT_ERR, "glcdlib_init: failed to allocate private data");
return -1;
}
pPD->glcdDriver = 0;
memset(pPD->info, '\0', sizeof(pPD->info));
if( drvthis->store_private_ptr( drvthis, pPD ) )
{
debug(RPT_ERR, "glcdlib_init: failed to store private data pointer");
return -1;
}
debug(RPT_INFO, "glcdlib_init: reading config file...");
//##################################################################
// Read config file
//##################################################################
//##################################################################
// mandatory entries:
// which driver
char strCfgDriver[30];
strncpy(strCfgDriver,
drvthis->config_get_string ( drvthis->name, "Driver", 0, "image"),
sizeof(strCfgDriver));
// use or not FreeType2
bool bCfgUseFT2 = drvthis->config_get_bool( drvthis->name, "UseFT2", 0, true);
// which text resolution
char strTextResDefault[] = "16x4";
char strTextRes[7];
int nCfgTextWidth = 0;
int nCfgTextRows = 0;
strncpy(strTextRes,
drvthis->config_get_string ( drvthis->name,
"TextResolution",
0,
strTextResDefault),
sizeof(strTextRes));
strTextRes[sizeof(strTextRes)-1]=0;
if( sscanf(strTextRes, "%dx%d", &nCfgTextWidth, &nCfgTextRows ) != 2
|| (nCfgTextWidth <= 0) || (nCfgTextWidth > LCD_MAX_WIDTH)
|| (nCfgTextRows <= 0) || (nCfgTextRows > LCD_MAX_HEIGHT))
{
report( RPT_WARNING,
"GLCDLIB: Cannot read or invalid TextResolution: %s, Using default value.\n",
strTextResDefault);
sscanf( strTextResDefault, "%dx%d", &nCfgTextWidth, &nCfgTextRows );
}
// which font file
char strCfgFontFile[256];
strncpy(strCfgFontFile,
drvthis->config_get_string ( drvthis->name,
"FontFile",
0,
"/usr/share/fonts/corefonts/courbd.ttf"),
sizeof(strCfgFontFile));
//##################################################################
// these only apply if bCfgUseFT2 = yes:
// character encoding
char strCfgEncoding[25];
strncpy(strCfgEncoding,
drvthis->config_get_string ( drvthis->name, "CharEncoding", 0, "ISO8859-1"),
sizeof(strCfgEncoding));
// minimum font face pixel resolution
char strMinFaceSizeDef[] = "6x8";
char strMinFontFaceSize[7];
int nCfgMinFontFaceWidth = 0;
int nCfgMinFontFaceHeight = 0;
strncpy(strMinFontFaceSize,
drvthis->config_get_string ( drvthis->name,
"MinFontFaceSize",
0,
strMinFaceSizeDef),
sizeof(strMinFontFaceSize));
strTextRes[sizeof(strMinFontFaceSize)-1]=0;
if( sscanf(strMinFontFaceSize, "%dx%d", &nCfgMinFontFaceWidth, &nCfgMinFontFaceHeight ) != 2
|| (nCfgMinFontFaceWidth <= 0) || (nCfgMinFontFaceWidth > LCD_MAX_WIDTH)
|| (nCfgMinFontFaceHeight <= 0) || (nCfgMinFontFaceHeight > LCD_MAX_HEIGHT))
{
report( RPT_WARNING,
"GLCDLIB: Cannot read or invalid TextResolution: %s, Using default value.\n",
strMinFaceSizeDef);
sscanf( strMinFaceSizeDef, "%dx%d", &nCfgMinFontFaceWidth, &nCfgMinFontFaceHeight );
}
// show debugging frame?
bool bShowDbgFrame = drvthis->config_get_bool( drvthis->name, "ShowDebugFrame", 0, true);
// show big border?
bool bShowBigBorder = drvthis->config_get_bool( drvthis->name, "ShowBigBorder", 0, true);
// show thin border?
bool bShowThinBorder = drvthis->config_get_bool( drvthis->name, "ShowThinBorder", 0, true);
// pixel shift
int nPixShiftX = drvthis->config_get_int( drvthis->name, "PixelShiftX", 0, 0);
int nPixShiftY = drvthis->config_get_int( drvthis->name, "PixelShiftY", 0, 0);
//##################################################################
// these are optional and override graphlcd-base library's own settings
// before on startup only:
int nContrast = drvthis->config_get_int( drvthis->name, "Contrast", 0, 50);
bool bBacklight = drvthis->config_get_bool( drvthis->name, "Backlight", 0, false);
bool bUpsideDown = drvthis->config_get_bool( drvthis->name, "UpsideDown", 0, false);
// instantiate driver in the wrapper library
pPD->glcdDriver = glcddriverCreate();
if( !pPD->glcdDriver )
{
debug(RPT_ERR, "glcdlib_init: failed to instantiate glcdlib wrapper");
return -1;
}
glcddriverInit( pPD->glcdDriver,
strCfgDriver,
strCfgFontFile,
bCfgUseFT2,
strCfgEncoding,
nCfgMinFontFaceHeight,
bShowBigBorder,
bShowThinBorder,
bShowDbgFrame,
nPixShiftX,
nPixShiftY,
bUpsideDown,
bBacklight,
nContrast);
// apply supplemental settings
int nBrightness = drvthis->config_get_int( drvthis->name, "Brightness", 0, 50);
glcddriverSetBrightness(pPD->glcdDriver, nBrightness);
bool bInvert = drvthis->config_get_bool( drvthis->name, "Invert", 0, false);
glcddriverInvert(pPD->glcdDriver, bInvert);
debug (RPT_INFO, "GLCDLIB: Initialization done!");
return 0;
}
MODULE_EXPORT void
glcdlib_close (Driver *drvthis)
{
debug (RPT_INFO, "Shutting down!\n");
glcdlibPD * pPD = drvthis->private_data;
glcddriverDestroy(pPD->glcdDriver);
pPD->glcdDriver = 0;
}
/////////////////////////////////////////////////////////////////
// Returns the display width
//
MODULE_EXPORT int
glcdlib_width (Driver *drvthis)
{
glcdlibPD * pPD = drvthis->private_data;
return glcddriverTextWidth(pPD->glcdDriver);
}
/////////////////////////////////////////////////////////////////
// Returns the display height
//
MODULE_EXPORT int
glcdlib_height (Driver *drvthis)
{
glcdlibPD * pPD = drvthis->private_data;
return glcddriverTextHeight(pPD->glcdDriver);
}
/////////////////////////////////////////////////////////////////
// Clears the LCD screen
//
MODULE_EXPORT void
glcdlib_clear (Driver *drvthis)
{
debug (RPT_DEBUG, "Clearing screen\n");
glcdlibPD * pPD = drvthis->private_data;
glcddriverClear(pPD->glcdDriver);
}
//////////////////////////////////////////////////////////////////
// Flushes all output to the lcd...
//
MODULE_EXPORT void
glcdlib_flush (Driver *drvthis)
{
debug (RPT_DEBUG, "glcdlib_flush: Flushing pixbuffer(s)\n");
glcdlibPD * pPD = drvthis->private_data;
glcddriverRefresh(pPD->glcdDriver, false);
}
/////////////////////////////////////////////////////////////////
// Prints a string on the lcd display, at position (x,y). The
// upper-left is (1,1), and the lower right should be (20,6).
//
MODULE_EXPORT void
glcdlib_string (Driver *drvthis, int x, int y, char string[])
{
debug (RPT_DEBUG, "String out\n");
y--;
x--;
glcdlibPD * pPD = drvthis->private_data;
glcddriverDrawText(pPD->glcdDriver, x, y, string);
}
/////////////////////////////////////////////////////////////////
// Prints a character on the lcd display, at position (x,y). The
// upper-left is (1,1), and the lower right should be (20,6).
//
MODULE_EXPORT void
glcdlib_chr (Driver *drvthis, int x, int y, char c)
{
debug (RPT_DEBUG, "Char out\n");
y--;
x--;
glcdlibPD * pPD = drvthis->private_data;
glcddriverDrawCharacter(pPD->glcdDriver, x, y, c);
}
/////////////////////////////////////////////////////////////////
// Sets an icon...
//
MODULE_EXPORT int
glcdlib_icon (Driver *drvthis, int x, int y, int icon)
{
debug (RPT_DEBUG, "GLCDLIB: set icon %d", icon);
y--;
x--;
glcdlibPD * pPD = drvthis->private_data;
return glcddriverDrawIcon(pPD->glcdDriver, x, y, icon);
}
/////////////////////////////////////////////////////////////////
// provides some info about this driver
//
MODULE_EXPORT char *
glcdlib_get_info (Driver *drvthis)
{
glcdlibPD * pPD = drvthis->private_data;
strcpy(pPD->info, "Meta driver which adds support for displays supported by graphlcd-base ");
return pPD->info;
}
/////////////////////////////////////////////////////////////////
// Returns the display's cell width
//
MODULE_EXPORT int
glcdlib_cellwidth (Driver *drvthis)
{
glcdlibPD * pPD = drvthis->private_data;
return glcddriverCellWidth(pPD->glcdDriver);
}
/////////////////////////////////////////////////////////////////
// Returns the display's cell height
//
MODULE_EXPORT int
glcdlib_cellheight (Driver *drvthis)
{
glcdlibPD * pPD = drvthis->private_data;
return glcddriverCellHeight(pPD->glcdDriver);
}
/////////////////////////////////////////////////////////////////
// Returns the maximum number of custom char slots (not how many
// are free at a moment, maybe this isn't even needed...
//
MODULE_EXPORT int
glcdlib_get_free_chars (Driver *drvthis)
{
glcdlibPD * pPD = drvthis->private_data;
return glcddriverMaxCustomChars(pPD->glcdDriver);
}
/////////////////////////////////////////////////////////////////
// Retrieves brightness (in promille ??????)
//
MODULE_EXPORT int
glcdlib_get_brightness(Driver *drvthis)
{
glcdlibPD * pPD = drvthis->private_data;
return 10 * glcddriverGetBrightness(pPD->glcdDriver);
}
/////////////////////////////////////////////////////////////////
// Sets brightness (in promille ??????)
//
MODULE_EXPORT void
glcdlib_set_brightness(Driver *drvthis, int promille)
{
glcdlibPD * pPD = drvthis->private_data;
glcddriverSetBrightness(pPD->glcdDriver, promille/10);
}
/////////////////////////////////////////////////////////////////
// Sets a custom character from 0 to glcdlib_get_free_chars - 1
// The input is an array of characters [cellheight x cellwidth]
// (0 & 1 according to pixels) ordered by rows
MODULE_EXPORT void
glcdlib_set_char (Driver *drvthis, int n, char *dat)
{
glcdlibPD * pPD = drvthis->private_data;
glcddriverSetCustomChar(pPD->glcdDriver, n, dat);
}
//////////////////////////////////////////////////////////////////////
// Draws a big (4-row) number.
//
MODULE_EXPORT void
glcdlib_num (Driver *drvthis, int x, int num)
{
x--;
glcdlibPD * pPD = drvthis->private_data;
glcddriverDrawBigNum(pPD->glcdDriver, x, num);
}
/////////////////////////////////////////////////////////////////
// Draws a horizontal bar to the right.
//
MODULE_EXPORT void
glcdlib_hbar (Driver *drvthis, int x, int y, int len, int promille, int options)
{
y--;
x--;
glcdlibPD * pPD = drvthis->private_data;
glcddriverDrawBarH(pPD->glcdDriver, x, y, len, promille, options);
}
/////////////////////////////////////////////////////////////////
// Draws a vertical bar, from the bottom of the screen up.
//
MODULE_EXPORT void
glcdlib_vbar (Driver *drvthis, int x, int y, int len, int promille, int options)
{
y--;
x--;
glcdlibPD * pPD = drvthis->private_data;
glcddriverDrawBarV(pPD->glcdDriver, x, y, len, promille, options);
}
/*
/////////////////////////////////////////////////////////////////
// Turns backlight on/off
//
MODULE_EXPORT void
glcdlib_backlight(Driver *drvthis, int on)
{
glcdlibPD * pPD = drvthis->private_data;
}
*/
+53
View File
@@ -0,0 +1,53 @@
/*
* This so-called "meta-driver" extends LCDproc's supported drivers by
* all the drivers supported by graphlcd-base, which you can get from
* http://graphlcd.berlios.de.
* In order to be able to use it, you have to get and install the glcdprocdriver
* from http://www.muresan.de/graphlcd/lcdproc.
*
* This file is released under the GNU General Public License. Refer to the
* COPYING file distributed with this package.
*
* Copyright (c) 2005 Lucian Muresan <lucianm AT users.sourceforge.net>
*
*
*/
#ifndef GLCDLIBLCDPROCDRIVER_H
#define GLCDLIBLCDPROCDRIVER_H
#include "lcd.h"
typedef unsigned short u16;
typedef unsigned char u8;
// ****************************************************************************************
// * F U N C T I O N S *
// ****************************************************************************************
MODULE_EXPORT int glcdlib_init (Driver *drvthis, char *args);
MODULE_EXPORT void glcdlib_close (Driver *drvthis);
MODULE_EXPORT int glcdlib_width (Driver *drvthis);
MODULE_EXPORT int glcdlib_height (Driver *drvthis);
MODULE_EXPORT void glcdlib_clear (Driver *drvthis);
MODULE_EXPORT void glcdlib_flush (Driver *drvthis);
MODULE_EXPORT void glcdlib_string (Driver *drvthis, int x, int y, char string[]);
MODULE_EXPORT void glcdlib_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT int glcdlib_icon (Driver *drvthis, int x, int y, int icon);
MODULE_EXPORT int glcdlib_cellwidth (Driver *drvthis);
MODULE_EXPORT int glcdlib_cellheight (Driver *drvthis);
MODULE_EXPORT int glcdlib_get_free_chars (Driver *drvthis);
MODULE_EXPORT char * glcdlib_get_info (Driver *drvthis);
MODULE_EXPORT int glcdlib_get_brightness(Driver *drvthis);
MODULE_EXPORT void glcdlib_set_brightness(Driver *drvthis, int promille);
MODULE_EXPORT void glcdlib_set_char (Driver *drvthis, int n, char *dat);
MODULE_EXPORT void glcdlib_num (Driver *drvthis, int x, int num);
MODULE_EXPORT void glcdlib_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void glcdlib_hbar (Driver *drvthis, int x, int y, int len, int promille, int options);
//MODULE_EXPORT void glcdlib_backlight(Driver *drvthis, int on);
#endif