Port remaining drivers to 0.5 API (icon, hbar, vbar).

This commit is contained in:
mmdolze
2011-02-10 22:48:57 +00:00
parent 361fcb2a51
commit 565a861d91
7 changed files with 320 additions and 400 deletions
+1
View File
@@ -17,6 +17,7 @@ v.0.5dev (ongoing development)
* lcdproc: Fix a single dot appearing on line 5 of the D screen * lcdproc: Fix a single dot appearing on line 5 of the D screen
* lcdproc: Make the iface screen more readable on 2x16 displays * lcdproc: Make the iface screen more readable on 2x16 displays
* All drivers: sync functions with prototypes * All drivers: sync functions with prototypes
* Port remaining drivers to 0.5 API (glk, lcdm001, stv5730)
v0.5.4 v0.5.4
* Update driver includes and LDFLAGS (fixed glk and bayrad binding error) * Update driver includes and LDFLAGS (fixed glk and bayrad binding error)
+58 -117
View File
@@ -1,14 +1,17 @@
/** \file server/drivers/glk.c /** \file server/drivers/glk.c
* LCDd \c glk driver for graphical displays by MatroxOrbital. * LCDd \c glk driver for graphical displays by MatrixOrbital (GLK series).
*
* \todo Adapt hBar, vBar, and icon to 0.5 API.
*/ */
/* /*
* MatrixOrbital GLK Graphic Display Driver * MatrixOrbital GLK Graphic Display Driver
* *
* http://www.matrixorbital.com * http://www.matrixorbital.com
*/
/*-
* Copyright ???
* *
* License ???
*/ */
#include <stdlib.h> #include <stdlib.h>
@@ -33,12 +36,10 @@
# endif # endif
#endif #endif
#define DEBUG 1
#include "lcd.h" #include "lcd.h"
#include "glk.h" #include "glk.h"
#include "glkproto.h" #include "glkproto.h"
#include "report.h" #include "report.h"
#include "adv_bignum.h" #include "adv_bignum.h"
#define GLK_DEFAULT_DEVICE "/dev/lcd" #define GLK_DEFAULT_DEVICE "/dev/lcd"
@@ -48,10 +49,6 @@
#define GLK_DEFAULT_CELLHEIGHT 8 #define GLK_DEFAULT_CELLHEIGHT 8
//////////////////////////////////////////////////////////////////////////
//////////////////// Matrix Orbital Graphical Driver /////////////////////
//////////////////////////////////////////////////////////////////////////
/** private data for the \c glk driver */ /** private data for the \c glk driver */
typedef struct glk_private_data { typedef struct glk_private_data {
char device[256]; char device[256];
@@ -79,7 +76,7 @@ typedef struct glk_private_data {
} PrivateData; } PrivateData;
// Vars for the server core /* Vars for the server core */
MODULE_EXPORT char *api_version = API_VERSION; MODULE_EXPORT char *api_version = API_VERSION;
MODULE_EXPORT int stay_in_foreground = 0; MODULE_EXPORT int stay_in_foreground = 0;
MODULE_EXPORT int supports_multiple = 0; MODULE_EXPORT int supports_multiple = 0;
@@ -110,7 +107,7 @@ glk_init(Driver *drvthis)
p->fd = NULL; p->fd = NULL;
p->speed = GLK_DEFAULT_SPEED; p->speed = GLK_DEFAULT_SPEED;
p->backingstore = NULL; p->backingstore = NULL;
p->fontselected = -1; // No font selected p->fontselected = -1; /* No font selected */
p->gpo_count = 0; p->gpo_count = 0;
p->framebuf = NULL; p->framebuf = NULL;
p->cellwidth = GLK_DEFAULT_CELLWIDTH; p->cellwidth = GLK_DEFAULT_CELLWIDTH;
@@ -131,7 +128,7 @@ glk_init(Driver *drvthis)
if (p->speed == 9600) p->speed = B9600; if (p->speed == 9600) p->speed = B9600;
else if (p->speed == 19200) p->speed = B19200; else if (p->speed == 19200) p->speed = B19200;
// not in the specs: /* not in the specs: */
//else if (p->speed == 38400) p->speed = B38400; //else if (p->speed == 38400) p->speed = B38400;
else if (p->speed == 57600) p->speed = B57600; else if (p->speed == 57600) p->speed = B57600;
else if (p->speed == 115200) p->speed = B115200; else if (p->speed == 115200) p->speed = B115200;
@@ -158,7 +155,7 @@ glk_init(Driver *drvthis)
return -1; return -1;
} }
// Query the module for a device type /* Query the module for a device type */
glkputl(p->fd, GLKCommand, 0x37, EOF); glkputl(p->fd, GLKCommand, 0x37, EOF);
i = glkget(p->fd); i = glkget(p->fd);
if (i < 0) { if (i < 0) {
@@ -227,22 +224,21 @@ glk_init(Driver *drvthis)
memset(p->framebuf, ' ', p->width * p->height); memset(p->framebuf, ' ', p->width * p->height);
// glk_clear();
glkputl(p->fd, GLKCommand, 0x58, EOF); glkputl(p->fd, GLKCommand, 0x58, EOF);
/* Enable flow control */
// Enable flow control
glkflow(p->fd, 40, 2); glkflow(p->fd, 40, 2);
// Set read character timeout to 0 /* Set read character timeout to 0 */
glktimeout(p->fd, 0); glktimeout(p->fd, 0);
// Enable auto-transmit of up/down key events /*
// This allows us to generate REPEAT keys distinct from * Enable auto-transmit of up/down key events. This allows us to generate
// normal keys using timeouts. (see glk_get_key) * REPEAT keys distinct from normal keys using timeouts. (see glk_get_key)
*/
glkputl(p->fd, GLKCommand, 0x7e, 1, GLKCommand, 0x41, EOF); glkputl(p->fd, GLKCommand, 0x7e, 1, GLKCommand, 0x41, EOF);
// Set p->contrast /* Set p->contrast */
glk_set_contrast(drvthis, p->contrast); glk_set_contrast(drvthis, p->contrast);
report(RPT_DEBUG, "%s: init() done", drvthis->name); report(RPT_DEBUG, "%s: init() done", drvthis->name);
@@ -360,7 +356,7 @@ glk_clear(Driver *drvthis)
memset(p->framebuf, ' ', p->width * p->height); memset(p->framebuf, ' ', p->width * p->height);
// do a hardware clear very CLEARCOUNT invocation /* do a hardware clear very CLEARCOUNT invocation */
if (--p->clearcount < 0) if (--p->clearcount < 0)
glk_clear_forced(drvthis); glk_clear_forced(drvthis);
} }
@@ -375,7 +371,6 @@ glk_flush(Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
// puts("glk_flush()");
unsigned char *pf = p->framebuf; unsigned char *pf = p->framebuf;
unsigned char *qf = p->backingstore; unsigned char *qf = p->backingstore;
int x, y; int x, y;
@@ -450,7 +445,7 @@ glk_chr(Driver *drvthis, int x, int y, char c)
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int myc = (unsigned char) c; int myc = (unsigned char) c;
x--; // Convert 1-based coords to 0-based... x--; /* Convert 1-based coords to 0-based... */
y--; y--;
if (p->fontselected != 1) { if (p->fontselected != 1) {
@@ -507,14 +502,12 @@ glk_set_contrast(Driver *drvthis, int promille)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
// Check it
if ((promille < 0) || (promille > 1000)) if ((promille < 0) || (promille > 1000))
return; return;
// Store it
p->contrast = promille; p->contrast = promille;
// Do it: map logical [0, 1000] -> physical [0, 255] for the hardware /* Do it: map logical [0, 1000] -> physical [0, 255] for the hardware */
debug(RPT_DEBUG, "Contrast: %d", p->contrast); debug(RPT_DEBUG, "Contrast: %d", p->contrast);
glkputl(p->fd, GLKCommand, 0x50, (int) ((long) promille * 255 / 1000), EOF); glkputl(p->fd, GLKCommand, 0x50, (int) ((long) promille * 255 / 1000), EOF);
} }
@@ -573,7 +566,6 @@ glk_output(Driver *drvthis, int on)
MODULE_EXPORT void MODULE_EXPORT void
glk_num(Driver *drvthis, int x, int num) glk_num(Driver *drvthis, int x, int num)
{ {
//PrivateData *p = drvthis->private_data;
int do_init = 1; int do_init = 1;
debug(RPT_DEBUG, "glk_num(%d, %d)", x, num); debug(RPT_DEBUG, "glk_num(%d, %d)", x, num);
@@ -581,52 +573,20 @@ glk_num(Driver *drvthis, int x, int num)
if ((num < 0) || (num > 10)) if ((num < 0) || (num > 10))
return; return;
/* no need to check for alternative ccmodes: we have no custom characters /* Lib_adv_bignum does everything needed to show the bignumbers. */
if (p->ccmode != bignum) {
if (p->ccmode != standard) {
// Not supported (yet)
report(RPT_WARNING, "%s: num: cannot combine two modes using user-defined characters",
drvthis->name);
return;
}
p->ccmode = bignum;
do_init = 1;
}
*/
// Lib_adv_bignum does everything needed to show the bignumbers.
lib_adv_bignum(drvthis, x, num, 0, do_init); lib_adv_bignum(drvthis, x, num, 0, do_init);
/* previous implementation using alternative font:
if (p->fontselected != 3) {
debug(RPT_DEBUG, "Switching to font 3");
// Select Big Numbers font
glkputl(p->fd, GLKCommand, 0x31, 3, EOF);
p->fontselected = 3;
// Set font metrics
glkputl(p->fd, GLKCommand, 0x32, 1, 0, 1, 1, 32, EOF);
// Clear the screen
glk_clear_forced(drvthis);
}
if ((x > 0) && (x <= p->width))
p->framebuf[x-1] = (num >= 10) ? ':' : (num + '0');
*/
} }
/** /**
* Get total number of custom characters available. * Get total number of custom characters available. This is required in order
* to be able to use bignum library.
* \param drvthis Pointer to driver structure. * \param drvthis Pointer to driver structure.
* \return Number of custom characters (always 0). * \return Number of custom characters (always 0).
*/ */
MODULE_EXPORT int MODULE_EXPORT int
glk_get_free_chars(Driver *drvthis) glk_get_free_chars(Driver *drvthis)
{ {
//PrivateData *p = drvthis->private_data;
debug(RPT_DEBUG, "glk_get_free_chars()"); debug(RPT_DEBUG, "glk_get_free_chars()");
return 0; return 0;
@@ -640,35 +600,32 @@ glk_get_free_chars(Driver *drvthis)
MODULE_EXPORT void MODULE_EXPORT void
glk_set_char(Driver *drvthis, int n, char *dat) glk_set_char(Driver *drvthis, int n, char *dat)
{ {
//PrivateData *p = drvthis->private_data;
debug(RPT_DEBUG, "glk_set_char(%d)", n); debug(RPT_DEBUG, "glk_set_char(%d)", n);
} }
/** /**
* Draws a vertical bar, from the bottom of the screen up. * Draws a vertical bar, from line y the screen up.
* This function still uses 0.4 API.
*/ */
MODULE_EXPORT void MODULE_EXPORT void
glk_old_vbar(Driver *drvthis, int x, int len) glk_vbar(Driver *drvthis, int x, int y, int len, int promille, int options)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int y = p->height; int pixels = ((long) 2 * len * p->cellheight) * promille / 2000;
debug(RPT_DEBUG, "glk_old_vbar(%d, %d)", x, len); debug(RPT_DEBUG, "glk_old_vbar(%d, %d)", x, pixels);
while (len > p->cellheight) { while (pixels > p->cellheight) {
glk_chr(drvthis, x, y, 255); glk_chr(drvthis, x, y, 255);
--y; --y;
len -= p->cellheight; pixels -= p->cellheight;
} }
if (y >= 0) { if (y >= 0) {
int lastc; int lastc;
switch (len) { switch (pixels) {
case 0 : return; break; /* Don't output a char */ case 0 : return; /* Don't output a char */
case 1 : lastc = 138; break; /* One bar */ case 1 : lastc = 138; break; /* One bar */
case 2 : lastc = 139; break; case 2 : lastc = 139; break;
case 3 : lastc = 140; break; case 3 : lastc = 140; break;
@@ -684,25 +641,25 @@ glk_old_vbar(Driver *drvthis, int x, int len)
/** /**
* Draws a horizontal bar to the right. * Draws a horizontal bar to the right.
* This function still uses 0.4 API.
*/ */
MODULE_EXPORT void MODULE_EXPORT void
glk_old_hbar(Driver *drvthis, int x, int y, int len) glk_hbar(Driver *drvthis, int x, int y, int len, int promille, int options)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int pixels = ((long) 2 * len * p->cellwidth) * promille / 2000;
debug(RPT_DEBUG, "glk_old_hbar(%d, %d, %d)", x, y, len); debug(RPT_DEBUG, "glk_old_hbar(%d, %d, %d)", x, y, pixels);
while (len > p->cellwidth) { while (pixels > p->cellwidth) {
glk_chr(drvthis, x, y, 255); glk_chr(drvthis, x, y, 255);
++x; ++x;
len -= p->cellwidth; pixels -= p->cellwidth;
} }
if (x <= p->width) { if (x <= p->width) {
int lastc; int lastc;
switch (len) { switch (pixels) {
case 0 : lastc = ' '; break; case 0 : lastc = ' '; break;
case 1 : lastc = 134; break; /* One bar */ case 1 : lastc = 134; break; /* One bar */
case 2 : lastc = 135; break; case 2 : lastc = 135; break;
@@ -716,47 +673,31 @@ glk_old_hbar(Driver *drvthis, int x, int y, int len)
/** /**
* Sets character 0 to an icon. * API: Draw an icon character on the screen.
* This function still uses 0.4 API.
*/ */
MODULE_EXPORT void MODULE_EXPORT int
glk_old_icon(Driver *drvthis, int which, int dest) glk_icon (Driver *drvthis, int x, int y, int icon)
{ {
PrivateData *p = drvthis->private_data; debug(RPT_DEBUG, "%s: x=%d, y=%d, icon=%x", __FUNCTION__, x, y, icon);
unsigned char old, new;
unsigned char *pf = p->framebuf;
unsigned char *qf = p->backingstore;
int count;
debug(RPT_DEBUG, "glk_old_icon(%i, %i)", which, dest); switch (icon) {
case ICON_BLOCK_FILLED:
if ((dest < 0) || (dest > 7)) { glk_chr(drvthis, x, y, 255);
/* Illegal custom character */ break;
return; case ICON_HEART_FILLED:
glk_chr(drvthis, x, y, 132);
break;
case ICON_HEART_OPEN:
glk_chr(drvthis, x, y, 131);
break;
case ICON_ELLIPSIS:
glk_chr(drvthis, x, y, 128);
break;
default:
return -1; /* Let the core do the others */
} }
/* which == 0 => empty heart => 131 return 0;
* which == 1 => filled heart => 132
* which == 2 => ellipsis => 128
*/
switch (which) {
case 0: new = 131; break;
case 1: new = 132; break;
case 2: new = 128; break;
default: return; /* ERROR */
}
old = p->CGRAM[(int) dest];
p->CGRAM[(int) dest] = new;
/* Replace all old icons with new icon in new frame */
for (count = p->width * p->height; count > 0; count--) {
if (*qf == old) {
debug(RPT_DEBUG, "icon %d to %d at %d", old, new, qf - p->backingstore);
*pf = new;
}
++qf; ++pf;
}
} }
@@ -828,7 +769,7 @@ glk_get_key(Driver *drvthis)
break; break;
default : break; default : break;
// What to do with repeated keys? We currently ignore them. /* What to do with repeated keys? We currently ignore them. */
//case 'v' : c = 'N'; break; //case 'v' : c = 'N'; break;
//case 'p' : c = 'O'; break; //case 'p' : c = 'O'; break;
//case 'q' : c = 'P'; break; //case 'q' : c = 'P'; break;
+3 -7
View File
@@ -1,8 +1,6 @@
#ifndef GLK_H #ifndef GLK_H
#define GLK_H #define GLK_H
#include "lcd.h"
MODULE_EXPORT int glk_init(Driver *drvthis); MODULE_EXPORT int glk_init(Driver *drvthis);
MODULE_EXPORT void glk_close(Driver *drvthis); MODULE_EXPORT void glk_close(Driver *drvthis);
MODULE_EXPORT int glk_width(Driver *drvthis); MODULE_EXPORT int glk_width(Driver *drvthis);
@@ -15,6 +13,9 @@ MODULE_EXPORT void glk_string(Driver *drvthis, int x, int y, const char string[]
MODULE_EXPORT void glk_chr(Driver *drvthis, int x, int y, char c); MODULE_EXPORT void glk_chr(Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void glk_num(Driver *drvthis, int x, int num); MODULE_EXPORT void glk_num(Driver *drvthis, int x, int num);
MODULE_EXPORT void glk_vbar(Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void glk_hbar(Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT int glk_icon(Driver *drvthis, int x, int y, int icon);
MODULE_EXPORT int glk_get_free_chars(Driver *drvthis); MODULE_EXPORT int glk_get_free_chars(Driver *drvthis);
MODULE_EXPORT void glk_set_char(Driver *drvthis, int n, char *dat); MODULE_EXPORT void glk_set_char(Driver *drvthis, int n, char *dat);
@@ -26,9 +27,4 @@ MODULE_EXPORT void glk_output(Driver *drvthis, int on);
MODULE_EXPORT const char *glk_get_key(Driver *drvthis); MODULE_EXPORT const char *glk_get_key(Driver *drvthis);
// Functions using old 0.4 API.
MODULE_EXPORT void glk_old_vbar(Driver *drvthis, int x, int len);
MODULE_EXPORT void glk_old_hbar(Driver *drvthis, int x, int y, int len);
MODULE_EXPORT void glk_old_icon(Driver *drvthis, int which, int dest);
#endif #endif
+135 -157
View File
@@ -2,39 +2,33 @@
* LCDd \c lcdm001 driver for the LCDM001 device from kernelconcepts.de. * LCDd \c lcdm001 driver for the LCDM001 device from kernelconcepts.de.
*/ */
/*-
* This driver is mostly based on the MtxOrb driver. See the file MtxOrb.c
* for copyright details. The function calls needed for reporting and getting
* settings from the configfile have been written taking the calls in
* sed1330.c.
*
* Copyright (C) 2001 Rene Wagner <reenoo@gmx.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
*/
/* /*
Copyright (C) 2001 Rene Wagner <reenoo@gmx.de> * LCDM001 does NOT support custom chars. You can modify the characters that
* are displayed instead of the normal icons for the heartbeat in lcdm001.h.
This program is free software; you can redistribute it and/or modify */
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */
/* This driver is mostly based on the MtxOrb driver.
See the file MtxOrb.c for copyright details */
/* The heartbeat workaround has been taken from the curses driver
See the file curses_drv.c for copyright details */
/* The function calls needed for reporting and getting settings from the
configfile have been written taking the calls in
sed1330.c ((C) by Joris Robijn) as examples*/
/* (Hopefully I have NOT forgotten any file I have stolen code from.
If so send me an e-mail or add your copyright here!) */
/* LCDM001 does NOT support custom chars
Most of the displaying problems have been fixed
using ASCII workarounds*/
/* You can modify the characters that are displayed instead of
the normal icons for the heartbeat in lcdm001.h*/
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@@ -49,21 +43,9 @@
# include "config.h" # include "config.h"
#endif #endif
# if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
# else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
# endif
#include "lcd.h" #include "lcd.h"
#include "lcdm001.h" #include "lcdm001.h"
#include "report.h" #include "report.h"
//#include "configfile.h"
/** private data for the \c lcdm001 driver */ /** private data for the \c lcdm001 driver */
@@ -72,8 +54,6 @@ typedef struct lcdm001_private_data {
int fd; int fd;
int speed; int speed;
char icon_char;
char pause_key; char pause_key;
char back_key; char back_key;
char forward_key; char forward_key;
@@ -81,23 +61,32 @@ typedef struct lcdm001_private_data {
char *framebuf; char *framebuf;
int width; int width, height;
int height; int cellwidth, cellheight;
} PrivateData; } PrivateData;
// Vars for the server core /* Vars for the server core */
MODULE_EXPORT char *api_version = API_VERSION; MODULE_EXPORT char *api_version = API_VERSION;
MODULE_EXPORT int stay_in_foreground = 0; MODULE_EXPORT int stay_in_foreground = 0;
MODULE_EXPORT int supports_multiple = 0; MODULE_EXPORT int supports_multiple = 0;
MODULE_EXPORT char *symbol_prefix = "lcdm001_"; MODULE_EXPORT char *symbol_prefix = "lcdm001_";
/* Local function prototypes */
static void lcdm001_cursorblink(Driver *drvthis, int on); static void lcdm001_cursorblink(Driver *drvthis, int on);
static char lcdm001_parse_keypad_setting(Driver *drvthis, char * keyname, char * default_value); static char lcdm001_parse_keypad_setting(Driver *drvthis, char * keyname, char * default_value);
// Parse one key from the configfile /**
static char lcdm001_parse_keypad_setting(Driver *drvthis, char * keyname, char * default_value) * Parse one key from the configfile.
* \param drvthis Pointer to driver
* \param keyname Name of the key in config file
* \param default_value Default key value to assign if keyname does not exist.
* \return The key character that will be assigned if the key on the device is
* pressed.
*/
static char
lcdm001_parse_keypad_setting(Driver *drvthis, char * keyname, char * default_value)
{ {
char return_val = 0; char return_val = 0;
@@ -125,7 +114,11 @@ static char lcdm001_parse_keypad_setting(Driver *drvthis, char * keyname, char *
return return_val; return return_val;
} }
/* Set cursorblink on/off */ /**
* Turn cursor blinking on or off.
* \param drvthis Pointer to driver structure.
* \param on Integer: 0 to turn off blinking, 1 to turn on blinking.
*/
static void static void
lcdm001_cursorblink(Driver *drvthis, int on) lcdm001_cursorblink(Driver *drvthis, int on)
{ {
@@ -141,11 +134,8 @@ lcdm001_cursorblink(Driver *drvthis, int on)
} }
/* TODO: Get lcd.framebuf to properly work as whatever driver is running...*/ /**
* API: Set up any device-specific stuff.
/*********************************************************************
* init() should set up any device-specific stuff, and
* point all the function pointers.
*/ */
MODULE_EXPORT int MODULE_EXPORT int
lcdm001_init (Driver *drvthis) lcdm001_init (Driver *drvthis)
@@ -162,7 +152,6 @@ lcdm001_init (Driver *drvthis)
/* initialize private data */ /* initialize private data */
p->speed = B38400; p->speed = B38400;
p->icon_char = '@';
p->pause_key = DOWN_KEY; p->pause_key = DOWN_KEY;
p->back_key = LEFT_KEY; p->back_key = LEFT_KEY;
p->forward_key = RIGHT_KEY; p->forward_key = RIGHT_KEY;
@@ -170,6 +159,8 @@ lcdm001_init (Driver *drvthis)
p->framebuf = NULL; p->framebuf = NULL;
p->width = LCD_DEFAULT_WIDTH; p->width = LCD_DEFAULT_WIDTH;
p->height = LCD_DEFAULT_HEIGHT; p->height = LCD_DEFAULT_HEIGHT;
p->cellwidth = LCD_DEFAULT_CELLWIDTH;
p->cellheight = LCD_DEFAULT_CELLHEIGHT;
debug(RPT_INFO, "LCDM001: init(%p)", drvthis); debug(RPT_INFO, "LCDM001: init(%p)", drvthis);
@@ -180,20 +171,20 @@ lcdm001_init (Driver *drvthis)
} }
memset(p->framebuf, ' ', p->width * p->height); memset(p->framebuf, ' ', p->width * p->height);
// READ CONFIG FILE: /* READ CONFIG FILE: */
// which serial device should be used /* which serial device should be used */
strncpy(p->device, drvthis->config_get_string(drvthis->name, "Device", 0, "/dev/lcd"), sizeof(p->device)); strncpy(p->device, drvthis->config_get_string(drvthis->name, "Device", 0, "/dev/lcd"), sizeof(p->device));
p->device[sizeof(p->device)-1] = '\0'; p->device[sizeof(p->device)-1] = '\0';
report(RPT_INFO, "%s: using Device %s", drvthis->name, p->device); report(RPT_INFO, "%s: using Device %s", drvthis->name, p->device);
// keypad settings /* keypad settings */
p->pause_key = lcdm001_parse_keypad_setting(drvthis, "PauseKey", "DownKey"); p->pause_key = lcdm001_parse_keypad_setting(drvthis, "PauseKey", "DownKey");
p->back_key = lcdm001_parse_keypad_setting(drvthis, "BackKey", "LeftKey"); p->back_key = lcdm001_parse_keypad_setting(drvthis, "BackKey", "LeftKey");
p->forward_key = lcdm001_parse_keypad_setting(drvthis, "ForwardKey", "RightKey"); p->forward_key = lcdm001_parse_keypad_setting(drvthis, "ForwardKey", "RightKey");
p->main_menu_key = lcdm001_parse_keypad_setting(drvthis, "MainMenuKey", "UpKey"); p->main_menu_key = lcdm001_parse_keypad_setting(drvthis, "MainMenuKey", "UpKey");
// Set up io port correctly, and open it... /* Set up io port correctly, and open it... */
debug(RPT_DEBUG, "%s: opening serial device: %s", __FUNCTION__, p->device); debug(RPT_DEBUG, "%s: opening serial device: %s", __FUNCTION__, p->device);
p->fd = open(p->device, O_RDWR | O_NOCTTY | O_NDELAY); p->fd = open(p->device, O_RDWR | O_NOCTTY | O_NDELAY);
if (p->fd == -1) { if (p->fd == -1) {
@@ -224,23 +215,22 @@ lcdm001_init (Driver *drvthis)
tcsetattr(p->fd, TCSANOW, &portset); tcsetattr(p->fd, TCSANOW, &portset);
tcflush(p->fd, TCIOFLUSH); tcflush(p->fd, TCIOFLUSH);
// Reset and clear the LCDM001 /* Reset and clear the LCDM001 */
write(p->fd, "~C", 2); write(p->fd, "~C", 2);
//Set cursorblink default /* Set cursorblink default */
lcdm001_cursorblink(drvthis, DEFAULT_CURSORBLINK); lcdm001_cursorblink(drvthis, DEFAULT_CURSORBLINK);
// Turn all LEDs off /* Turn all LEDs off */
lcdm001_output(drvthis, 0); lcdm001_output(drvthis, 0);
report(RPT_DEBUG, "%s: init() done", drvthis->name); report(RPT_INFO, "%s: init() done", drvthis->name);
return 0; return 0;
} }
/* Below here, you may use either lcd.framebuf or driver->framebuf..
* lcd.framebuf will be set to the appropriate buffer before calling
* your driver.
*/
/**
* API: Cleanup all data structures and close device.
*/
MODULE_EXPORT void MODULE_EXPORT void
lcdm001_close (Driver *drvthis) lcdm001_close (Driver *drvthis)
{ {
@@ -252,7 +242,7 @@ lcdm001_close (Driver *drvthis)
p->framebuf = NULL; p->framebuf = NULL;
if (p->fd >= 0) { if (p->fd >= 0) {
//switch off all LEDs /* switch off all LEDs */
lcdm001_output(drvthis, 0); lcdm001_output(drvthis, 0);
close(p->fd); close(p->fd);
} }
@@ -265,9 +255,9 @@ lcdm001_close (Driver *drvthis)
report(RPT_INFO, "%s: closed", drvthis->name); report(RPT_INFO, "%s: closed", drvthis->name);
} }
///////////////////////////////////////////////////////////////// /**
// Returns the display width * API: Returns the display width
// */
MODULE_EXPORT int MODULE_EXPORT int
lcdm001_width (Driver *drvthis) lcdm001_width (Driver *drvthis)
{ {
@@ -276,9 +266,9 @@ lcdm001_width (Driver *drvthis)
return p->width; return p->width;
} }
///////////////////////////////////////////////////////////////// /**
// Returns the display height * API: Returns the display height
// */
MODULE_EXPORT int MODULE_EXPORT int
lcdm001_height (Driver *drvthis) lcdm001_height (Driver *drvthis)
{ {
@@ -287,49 +277,44 @@ lcdm001_height (Driver *drvthis)
return p->height; return p->height;
} }
///////////////////////////////////////////////////////////////// /**
// Clears the LCD screen * API: Clears the internal frame buffer. Does not clear display screen
// * immediately as it only makes the display flicker.
*/
MODULE_EXPORT void MODULE_EXPORT void
lcdm001_clear (Driver *drvthis) lcdm001_clear (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
memset(p->framebuf, ' ', p->width * p->height); memset(p->framebuf, ' ', p->width * p->height);
/* instant clear is NOT neccessary, it only makes the display flicker */
//write(fd, "~C", 2);
debug(RPT_DEBUG, "LCDM001: cleared screen"); debug(RPT_DEBUG, "LCDM001: cleared screen");
} }
////////////////////////////////////////////////////////////////// /**
// Flushes all output to the lcd... * API: Flushes all output to the lcd...
// */
MODULE_EXPORT void MODULE_EXPORT void
lcdm001_flush (Driver *drvthis) lcdm001_flush (Driver *drvthis)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
//TODO: Check whether this is still correct /* TODO: Check whether this is still correct */
write(p->fd, p->framebuf, p->width * p->height); write(p->fd, p->framebuf, p->width * p->height);
debug(RPT_DEBUG, "LCDM001: frame buffer flushed"); debug(RPT_DEBUG, "LCDM001: frame buffer flushed");
} }
///////////////////////////////////////////////////////////////// /**
// Prints a character on the lcd display, at position (x,y). The * API: Prints a character on the lcd display, at position (x,y). The
// upper-left is (1,1), and the lower right should be (20,4). * upper-left is (1,1), and the lower right should be (20,4).
// */
MODULE_EXPORT void MODULE_EXPORT void
lcdm001_chr (Driver *drvthis, int x, int y, char c) lcdm001_chr (Driver *drvthis, int x, int y, char c)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
if (c == '\0') y--; x--; /* translate to 0-coords */
c = p->icon_char; //heartbeat workaround
y--; x--; // translate to 0-coords
if ((x >= 0) && (y >= 0) && (x < p->width) && (y < p->height)) if ((x >= 0) && (y >= 0) && (x < p->width) && (y < p->height))
p->framebuf[(y * p->width) + x] = c; p->framebuf[(y * p->width) + x] = c;
@@ -337,31 +322,36 @@ lcdm001_chr (Driver *drvthis, int x, int y, char c)
debug(RPT_DEBUG, "LCDM001: writing character %02X to position (%d,%d)", c, x, y); debug(RPT_DEBUG, "LCDM001: writing character %02X to position (%d,%d)", c, x, y);
} }
///////////////////////////////////////////////////////////////// /**
// Prints a string on the lcd display, at position (x,y). The * API: Prints a string on the lcd display, at position (x,y). The
// upper-left is (1,1), and the lower right should be (20,4). * upper-left is (1,1), and the lower right should be (20,4).
// */
MODULE_EXPORT void MODULE_EXPORT void
lcdm001_string (Driver *drvthis, int x, int y, const char string[]) lcdm001_string (Driver *drvthis, int x, int y, const char string[])
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
x--; y--; // Convert 1-based coords to 0-based... x--; y--; /* Convert 1-based coords to 0-based... */
if ((y < 0) || (y >= p->height)) if ((y < 0) || (y >= p->height))
return; return;
for (i = 0; (string[i] != '\0') && (x < p->width); i++, x++) { for (i = 0; (string[i] != '\0') && (x < p->width); i++, x++) {
if (x >= 0) // no write left of left border if (x >= 0) /* no write left of left border */
p->framebuf[(y * p->width) + x] = string[i]; p->framebuf[(y * p->width) + x] = string[i];
} }
debug(RPT_DEBUG, "LCDM001: printed string at (%d,%d)", x, y); debug(RPT_DEBUG, "LCDM001: printed string at (%d,%d)", x, y);
} }
///////////////////////////////////////////////////////////////// /**
// Controls LEDs * API: Controls LEDs.
* \param drvthis Pointer to driver
* \param state LED state
*
* \todo Document LED state.
*/
MODULE_EXPORT void MODULE_EXPORT void
lcdm001_output (Driver *drvthis, int state) lcdm001_output (Driver *drvthis, int state)
{ {
@@ -376,91 +366,79 @@ lcdm001_output (Driver *drvthis, int state)
debug(RPT_DEBUG, "LCDM001: current LED state %d", state); debug(RPT_DEBUG, "LCDM001: current LED state %d", state);
} }
///////////////////////////////////////////////////////////////// /**
// Draws a vertical bar, from the bottom of the screen up. * API: Draws a vertical bar, from the bottom of the screen up.
// */
MODULE_EXPORT void MODULE_EXPORT void
lcdm001_old_vbar(Driver *drvthis, int x, int len) lcdm001_vbar (Driver *drvthis, int x, int y, int len, int promille, int options)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int y = p->height; int pixels = ((long) 2 * len * p->cellheight) * promille / 2000;
debug(RPT_DEBUG , "LCDM001: vertical bar at %d set to %d", x, len); if ((x <= 0) || (x > p->width) || (y <= 0) || (y > p->height))
return;
while (len >= LCD_DEFAULT_CELLHEIGHT) { debug(RPT_DEBUG , "LCDM001: vertical bar at %d set to %d", x, pixels);
while (y > 0 && pixels >= p->cellheight) {
lcdm001_chr(drvthis, x, y, 0xFF); lcdm001_chr(drvthis, x, y, 0xFF);
len -= LCD_DEFAULT_CELLHEIGHT; pixels -= p->cellheight;
y--; y--;
} }
if (!len)
return;
//TODO: Distinguish between len>=4 and len<4
} }
///////////////////////////////////////////////////////////////// /**
// Draws a horizontal bar to the right. * API: Draws a horizontal bar to the right.
// */
MODULE_EXPORT void MODULE_EXPORT void
lcdm001_old_hbar(Driver *drvthis, int x, int y, int len) lcdm001_hbar (Driver *drvthis, int x, int y, int len, int promille, int options)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int pixels = ((long) 2 * len * p->cellwidth) * promille / 2000;
if ((y <= 0) || (y > p->height)) if ((x <= 0) || (y <= 0) || (y > p->height))
return; return;
debug(RPT_DEBUG, "LCDM001: horizontal bar at %d set to %d", x, len); debug(RPT_DEBUG, "LCDM001: horizontal bar at %d set to %d", x, pixels);
//TODO: Improve this function
while ((x <= p->width) && (len > 0)) {
if (len < LCD_DEFAULT_CELLWIDTH) {
//lcdm001_chr(x, y, 0x98 + len);
break;
}
while (x <= p->width && pixels >= p->cellwidth) {
lcdm001_chr(drvthis, x, y, 0xFF); lcdm001_chr(drvthis, x, y, 0xFF);
len -= LCD_DEFAULT_CELLWIDTH; pixels -= p->cellwidth;
x++; x++;
} }
return; return;
} }
///////////////////////////////////////////////////////////////// /**
// Sets character 0 to an icon... * API: Place an icon on the screen. As this driver does not support custom
// * characters only generic icons from core are supported. The heartbeat
MODULE_EXPORT void * icons however are replaced with some different characters.
lcdm001_old_icon (Driver *drvthis, int which, char dest) */
MODULE_EXPORT int
lcdm001_icon (Driver *drvthis, int x, int y, int icon)
{ {
PrivateData *p = drvthis->private_data; switch (icon) {
case ICON_HEART_OPEN:
/*Heartbeat workaround: lcdm001_chr(drvthis, x, y, LCDM001_OPEN_HEART);
As custom chars are not supported OPEN_HEART
and FILLED_HEART are displayed instead.
Change them in lcdm001.h*/
if (dest == 0)
switch (which) {
case 0:
p->icon_char = OPEN_HEART;
break; break;
case 1: case ICON_HEART_FILLED:
p->icon_char = FILLED_HEART; lcdm001_chr(drvthis, x, y, LCDM001_FILLED_HEART);
break; break;
default: default:
p->icon_char = PAD; return -1; /* Let the core do the other */
break;
}
} }
////////////////////////////////////////////////////////////////////// return 0;
// Tries to read a character from an input device... }
//
// Return NULL for "nothing available".
//
/**
* API: Tries to read a character from an input device...
*
* \return NULL for "nothing available" or one of the fixed strings "Enter",
* "Left", "Right", or "Escape".
*/
MODULE_EXPORT const char * MODULE_EXPORT const char *
lcdm001_get_key (Driver *drvthis) lcdm001_get_key (Driver *drvthis)
{ {
+31 -41
View File
@@ -1,38 +1,29 @@
/* This is the header file of the LCDproc driver for /**
the "LCDM001" device from kernelconcepts.de * This is the header file of the LCDproc driver for the "LCDM001" device from
* kernelconcepts.de
Copyright (C) 2001 Rene Wagner <reenoo@gmx.de> */
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */
/* This driver is mostly based on the MtxOrb driver.
See the file MtxOrb.c for copyright details */
/* The heartbeat workaround has been taken from the curses driver
See the file curses_drv.c for copyright details */
/*-
* Copyright (C) 2001 Rene Wagner <reenoo@gmx.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
*/
#ifndef LCDM001_H #ifndef LCDM001_H
#define LCDM001_H #define LCDM001_H
/********************************************************************
lcdm001.h
******************************************************************/
/* REMOVE: I don't thing this is actualy needed. */
/* extern lcd_logical_driver *lcdm001; */
MODULE_EXPORT int lcdm001_init (Driver *drvthis); MODULE_EXPORT int lcdm001_init (Driver *drvthis);
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);
@@ -42,24 +33,23 @@ MODULE_EXPORT void lcdm001_flush (Driver *drvthis);
MODULE_EXPORT void lcdm001_string (Driver *drvthis, int x, int y, const char string[]); MODULE_EXPORT void lcdm001_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void lcdm001_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void lcdm001_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void lcdm001_old_vbar (Driver *drvthis, int x, int len); MODULE_EXPORT void lcdm001_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void lcdm001_old_hbar (Driver *drvthis, int x, int y, int len); MODULE_EXPORT void lcdm001_hbar (Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void lcdm001_num (Driver *drvthis, int x, int num); MODULE_EXPORT void lcdm001_num (Driver *drvthis, int x, int num);
MODULE_EXPORT void lcdm001_old_icon (Driver *drvthis, int which, char dest); MODULE_EXPORT int lcdm001_icon (Driver *drvthis, int x, int y, int icon);
MODULE_EXPORT void lcdm001_output (Driver *drvthis, int on); MODULE_EXPORT void lcdm001_output (Driver *drvthis, int on);
MODULE_EXPORT char lcdm001_getkey (Driver *drvthis); MODULE_EXPORT char lcdm001_getkey (Driver *drvthis);
#define DEFAULT_DEVICE "/dev/lcd" #define DEFAULT_DEVICE "/dev/lcd"
#define DEFAULT_CURSORBLINK 0 #define DEFAULT_CURSORBLINK 0 /* cursor blinking off */
/*Heartbeat workaround /*
set chars to be displayed instead of "normal" icons*/ * Use our own chars for the heartbeat instead of core's default. This
* combination is at least visible.
#define OPEN_HEART ' ' /* This combination is at least visible */ */
#define FILLED_HEART '*' #define LCDM001_OPEN_HEART ' '
#define PAD 255 #define LCDM001_FILLED_HEART '*'
#define LEFT_KEY '1' #define LEFT_KEY '1'
#define RIGHT_KEY '2' #define RIGHT_KEY '2'
+78 -62
View File
@@ -29,7 +29,6 @@
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
//#include <sys/io.h>
#include <time.h> #include <time.h>
#include "port.h" #include "port.h"
#include "timing.h" #include "timing.h"
@@ -102,49 +101,50 @@ MODULE_EXPORT char *symbol_prefix = "stv5730_";
// Translation map ascii->stv5730 charset // Translation map ascii->stv5730 charset
unsigned char stv5730_to_ascii[256] = unsigned char stv5730_to_ascii[256] =
{ 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, {
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, /* 00 - 7F */
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
0x27, 0x0B, 0x27, 0x28, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x26, 0x26, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x29, /* ' */
0x62, 0x78, 0x61, 0x70, 0x0B, 0x0B, 0x5F, 0x5E, 0x27, 0x0A, 0x27, 0x28, /* * + . - . / */
0x6c, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0 1 2 3 4 5 6 7 */
0x17, 0x18, 0x19, 0x1A, 0x08, 0x09, 0x26, 0x26, 0x62, 0x78, 0x61, 0x70, /* 8 9 : : « = » ? */
0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x0B, 0x6c, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, /* @ A B C D E F G */
0x0B, 0x0B, 0x0B, 0x72, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, /* H I J K L M N O */
0x0B, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, /* P Q R S T U V W */
0x35, 0x36, 0x37, 0x38, 0x23, 0x24, 0x25, 0x0B, 0x0B, 0x0B, 0x0B, 0x72, /* X Y Z _ */
0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x6E, 0x0B, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, /* a b c d e f g */
0x6C, 0x71, 0x79, 0x7F, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, /* h i j k l m n o */
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, /* p q r s t u v w */
0x0B, 0x0B, 0x0B, 0x0B, 0x41, 0x42, 0x43, 0x6E, 0x6C, 0x71, 0x79, 0x7F, /* x y z # # # # # */
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, /* 80 - FF */
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x58, 0x69, 0x0B, 0x0B, /* Ä Å */
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x6B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, /* É */
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x6D, 0x0B, 0x0B, 0x0B, 0x0B, 0x59, 0x0B, /* Ñ Ö */
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x5A, 0x0B, 0x0B, 0x5C, /* Ü ß */
0x0B, 0x0B, 0x0B, 0x77 0x44, 0x47, 0x45, 0x0B, 0x46, 0x6A, 0x0B, 0x58, /* à á â ä å ç */
0x49, 0x48, 0x4B, 0x4A, 0x4C, 0x4F, 0x4D, 0x4E, /* è é ê ë ì í î ï */
0x0B, 0x5D, 0x50, 0x53, 0x51, 0x0B, 0x52, 0x0B, /* ñ ò ó ô ö */
0x0B, 0x54, 0x57, 0x55, 0x56, 0x0B, 0x0B, 0x77 /* ù ú û ü # */
}; };
//static void stv5730_upause(int delayCalls); //static void stv5730_upause(int delayCalls);
#define stv5730_upause timing_uPause #define stv5730_upause timing_uPause
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// This function returns true if a powered and working STV5730 // This function returns true if a powered and working STV5730
// hardware is present at p->port // hardware is present at p->port
static int static int
stv5730_detect (unsigned int port) stv5730_detect (unsigned int port)
{ {
@@ -178,7 +178,6 @@ stv5730_is_mute (unsigned int port)
// this family of functions write commands or data to the stv5730 // this family of functions write commands or data to the stv5730
// 8 bit writes repeat the high byte, 0 byte writes repeat the last // 8 bit writes repeat the high byte, 0 byte writes repeat the last
// written word // written word
static void static void
stv5730_write16bit (unsigned int port, unsigned int flags, unsigned int value) stv5730_write16bit (unsigned int port, unsigned int flags, unsigned int value)
{ {
@@ -571,49 +570,53 @@ stv5730_num (Driver *drvthis, int x, int num)
} }
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Draws a vertical bar from the bottom up to the last 7 rows of the // Draws a vertical bar from the bottom up at 1-based position x.
// framebuffer at 1-based position x. len is given in pixels.
// //
MODULE_EXPORT void MODULE_EXPORT void
stv5730_old_vbar (Driver *drvthis, int x, int len) stv5730_vbar(Driver *drvthis, int x, int y, int len, int promille, int options)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i; /* number of pixels drawn */
int pixels;
x--; x--;
if (x < 0 || len < 0 || (len / 6) >= STV5730_WID) if (x < 0 || len < 0 || (len) >= STV5730_HGT)
return; return;
for (i = 0; i <= len; i += 6) { pixels = ((long) 2 * len * 6) * promille / 2000;
if (len >= (i + 6)) /* 6 = cellheight */
for (i = 0; i <= pixels; i += 6) {
if (pixels >= (i + 6)) /* 6 = cellheight */
p->framebuf[((10 - (i / 6)) * STV5730_WID) + x] = 0x77; p->framebuf[((10 - (i / 6)) * STV5730_WID) + x] = 0x77;
else else
p->framebuf[((10 - (i / 6)) * STV5730_WID) + x] = 0x72 + (len % 6); p->framebuf[((10 - (i / 6)) * STV5730_WID) + x] = 0x72 + (pixels % 6);
} }
} }
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Draws a horizontal bar from left to right at 1-based position // Draws a horizontal bar from left to right at 1-based position
// x,y into the framebuffer. len is given in pixels. // x,y into the framebuffer.
// It uses the STV5730 'channel-tuning' chars(0x64-0x68) to do // It uses the STV5730 'channel-tuning' chars(0x64-0x68) to do
// this. // this.
MODULE_EXPORT void MODULE_EXPORT void
stv5730_old_hbar (Driver *drvthis, int x, int y, int len) stv5730_hbar (Driver *drvthis, int x, int y, int len, int promille, int options)
{ {
PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
int i; int i;
int pixels;
x--; x--;
y--; y--;
if (y < 0 || y >= STV5730_HGT || x < 0 || len < 0 if (y < 0 || y >= STV5730_HGT || x < 0 || len < 0 || (x + len) >= STV5730_WID)
|| (x + (len / 5)) >= STV5730_WID)
return; return;
for (i = 0; i <= len; i += 5) { pixels = ((long) 2 * len * 4) * promille / 2000;
if (len >= (i + 4)) /* 4 = cellwidth */
for (i = 0; i <= pixels; i += 5) {
if (pixels >= (i + 4)) /* 4 = cellwidth */
p->framebuf[(y * STV5730_WID) + x + (i / 5)] = 0x64; p->framebuf[(y * STV5730_WID) + x + (i / 5)] = 0x64;
else else
p->framebuf[(y * STV5730_WID) + x + (i / 5)] = 0x65 + (len % 5); p->framebuf[(y * STV5730_WID) + x + (i / 5)] = 0x65 + (len % 5);
@@ -626,23 +629,36 @@ stv5730_old_hbar (Driver *drvthis, int x, int y, int len)
// The STV5730 has no programmable chars. The charset is very // The STV5730 has no programmable chars. The charset is very
// limited, it doesn't even contain a '%' char. But wait... // limited, it doesn't even contain a '%' char. But wait...
// It contains a heartbeat char ! :-) // It contains a heartbeat char ! :-)
MODULE_EXPORT void MODULE_EXPORT int
stv5730_old_icon (Driver *drvthis, int which, char dest) stv5730_icon(Driver *drvthis, int x, int y, int icon)
{ {
//PrivateData *p = drvthis->private_data; PrivateData *p = drvthis->private_data;
switch (which) { switch (icon) {
case 0: // 0:empty Heart case ICON_BLOCK_FILLED:
stv5730_to_ascii[(int) dest] = 0x71; p->framebuf[(y * STV5730_WID) + x] = 0x77;
break; break;
case 1: // 1:Filled Heart case ICON_HEART_OPEN:
stv5730_to_ascii[(int) dest] = 0x0B; p->framebuf[(y * STV5730_WID) + x] = 0x0B;
break; break;
case 2: // 2:Ellipsis case ICON_HEART_FILLED:
stv5730_to_ascii[(int) dest] = 0x5F; p->framebuf[(y * STV5730_WID) + x] = 0x71;
break;
case ICON_ARROW_UP:
p->framebuf[(y * STV5730_WID) + x] = 0x7C;
break;
case ICON_ARROW_DOWN:
p->framebuf[(y * STV5730_WID) + x] = 0x7D;
break;
case ICON_ARROW_LEFT:
p->framebuf[(y * STV5730_WID) + x] = 0x7B;
break;
case ICON_ARROW_RIGHT:
p->framebuf[(y * STV5730_WID) + x] = 0x7A;
break; break;
default: default:
stv5730_to_ascii[(int) dest] = 0x0B; return -1; /* Let the core do the others */
break;
} }
return 0;
} }
+3 -5
View File
@@ -1,8 +1,6 @@
#ifndef STV5730_H #ifndef STV5730_H
#define STV5730_H #define STV5730_H
#include "lcd.h"
MODULE_EXPORT int stv5730_init (Driver *drvthis); MODULE_EXPORT int stv5730_init (Driver *drvthis);
MODULE_EXPORT void stv5730_close (Driver *drvthis); MODULE_EXPORT void stv5730_close (Driver *drvthis);
MODULE_EXPORT int stv5730_width (Driver *drvthis); MODULE_EXPORT int stv5730_width (Driver *drvthis);
@@ -13,9 +11,9 @@ MODULE_EXPORT void stv5730_clear (Driver *drvthis);
MODULE_EXPORT void stv5730_flush (Driver *drvthis); MODULE_EXPORT void stv5730_flush (Driver *drvthis);
MODULE_EXPORT void stv5730_string (Driver *drvthis, int x, int y, const char string[]); MODULE_EXPORT void stv5730_string (Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void stv5730_chr (Driver *drvthis, int x, int y, char c); MODULE_EXPORT void stv5730_chr (Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void stv5730_old_vbar (Driver *drvthis, int x, int len); MODULE_EXPORT void stv5730_vbar(Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void stv5730_old_hbar (Driver *drvthis, int x, int y, int len); MODULE_EXPORT void stv5730_hbar (Driver *drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void stv5730_num (Driver *drvthis, int x, int num); MODULE_EXPORT void stv5730_num (Driver *drvthis, int x, int num);
MODULE_EXPORT void stv5730_old_icon (Driver *drvthis, int which, char dest); MODULE_EXPORT int stv5730_icon(Driver *drvthis, int x, int y, int icon);
#endif #endif