First attempt at CFontz633...

This commit is contained in:
dglaude
2002-04-10 23:06:45 +00:00
parent bc61fa0da8
commit f71e4ccfd2
7 changed files with 1214 additions and 4 deletions
+29
View File
@@ -123,6 +123,34 @@ NewFirmware=no
# normally you shouldn't need this
Reboot=no
[CFontz633]
# CrystalFontz633 driver
# Select the output device to use [/dev/lcd]
Device=/dev/ttyS0
# Select the LCD type (size) [20x4]
Size=16x2
# Set the initial contrast [140]
Contrast=140
# Set the initial brightness [100]
# Brightness hardware value is between 0 and 100.
Brightness=100
# Set the initial off-brightness [0]
# This value is used when the display is normally
# switched off in case LCDd is inactive
OffBrightness=50
# Set the communication speed [9600]
# possible values: 19200
Speed=19200
# Set the firmware version (New means >= 2.0) [no]
# Currently this flag is not in use, there is no such thing as NewFirmware. ;=)
NewFirmware=no
# Reinitialize the LCD's BIOS [no]
# normally you shouldn't need this
Reboot=yes
[curses]
file=curses_drv.so
# Curses driver
@@ -199,6 +227,7 @@ DelayBus=true
[IrMan]
#IrMan driver
#if in trouble with IrMan, try Lirc emulator for IrMan
Arguments="fill in here"
+7 -3
View File
@@ -5,15 +5,15 @@ AC_ARG_ENABLE(drivers,
[ --enable-drivers=<list> compile driver for LCDs in <list>.]
[ drivers may be separated with commas.]
[ Possible choices are:]
[ mtxorb,cfontz,curses,text,lb216,]
[ mtxorb,cfontz,cfontz633,curses,text,lb216,]
[ hd44780,joy,irman,lirc,bayrad,glk,]
[ stv5730,sed1330,sed1520,svga,lcdm001,t6963]
[ \"all\" compiles all drivers],
drivers="$enableval",
drivers=[lcdm001,mtxorb,cfontz,curses,text,lb216,bayrad,glk])
drivers=[lcdm001,mtxorb,cfontz,cfontz633,,curses,text,lb216,bayrad,glk])
if test "$drivers" = "all"; then
drivers=[mtxorb,cfontz,curses,text,lb216,hd44780,joy,irman,lirc,bayrad,glk,stv5730,sed1330,sed1520,svga,lcdm001,t6963]
drivers=[mtxorb,cfontz,cfontz633,curses,text,lb216,hd44780,joy,irman,lirc,bayrad,glk,stv5730,sed1330,sed1520,svga,lcdm001,t6963]
fi
drivers=`echo $drivers | sed 's/,/ /g'`
@@ -41,6 +41,10 @@ fi
DRIVERS="$DRIVERS CFontz${SO}"
actdrivers=["$actdrivers cfontz"]
;;
cfontz633)
DRIVERS="$DRIVERS CFontz633${SO}"
actdrivers=["$actdrivers cfontz633"]
;;
sli)
DRIVERS="$DRIVERS wirz-sli${SO}"
actdrivers=["$actdrivers sli"]
+810
View File
@@ -0,0 +1,810 @@
/* This is the LCDproc driver for CrystalFontz 633 devices
(get yours from http://crystalfontz.com)
Copyright (C) 2002 David GLAUDE
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 */
/*
* Driver status
* 04/04/2002: Working driver
* BUT
* + No support for keypad (inactive)
* + No checking of LCD response (ACK of each message)
* + No checking if right hardware is connected (firmware/hardware)
* + No BigNum (but screen is too small ???)
* + No support for multiple instance (require private structure)
* + No cache of custom char usage (like in MtxOrb)
*
* THINGS DONE:
* + Stopping the live reporting (of temperature)
* + Stopping the reporting of temp and fan (is it necessary after reboot)
* + Use of library for hbar and vbar (good but library could be better)
*
* THINGS TO DO:
* + make the caching at least for heartbeat icon
* +
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <termios.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <syslog.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "lcd.h"
#include "CFontz633.h"
#include "CFontz633io.h"
#include "report.h"
#include "lcd_lib.h"
static int custom = 0;
typedef enum {
hbar = 1,
vbar = 2
} custom_type;
static int fd;
static char *framebuf = NULL;
static char *old = NULL;
static int width = 0;
static int height = 0;
static int cellwidth = DEFAULT_CELL_WIDTH;
static int cellheight = DEFAULT_CELL_HEIGHT;
static int contrast = DEFAULT_CONTRAST;
static int brightness = DEFAULT_BRIGHTNESS;
static int offbrightness = DEFAULT_OFFBRIGHTNESS;
static int newfirmware = 0;
/* Vars for the server core */
MODULE_EXPORT char *api_version = API_VERSION;
MODULE_EXPORT int stay_in_foreground = 1;
MODULE_EXPORT int supports_multiple = 0;
MODULE_EXPORT char *symbol_prefix = "CFontz633_";
/* Internal functions */
/* static void CFontz633_linewrap (int on); */
/* static void CFontz633_autoscroll (int on); */
static void CFontz633_hidecursor ();
static void CFontz633_reboot ();
static void CFontz633_init_vbar (Driver * drvthis);
static void CFontz633_init_hbar (Driver * drvthis);
static void CFontz633_no_live_report ();
static void CFontz633_hardware_clear (Driver * drvthis);
/*
* Opens com port and sets baud correctly...
*/
MODULE_EXPORT int
CFontz633_init (Driver * drvthis, char *args)
{
struct termios portset;
int tmp, w, h;
int reboot = 0;
int contrast = DEFAULT_CONTRAST;
char device[200] = DEFAULT_DEVICE;
int speed = DEFAULT_SPEED;
char size[200] = DEFAULT_SIZE;
debug(RPT_INFO, "CFontz633: init(%p,%s)", drvthis, args );
/* Read config file */
/* Which serial device should be used */
strncpy(device, drvthis->config_get_string ( drvthis->name , "Device" , 0 , DEFAULT_DEVICE),sizeof(device));
device[sizeof(device)-1]=0;
debug (RPT_INFO,"CFontz633: Using device: %s", device);
/* Which size */
strncpy(size, drvthis->config_get_string ( drvthis->name , "Size" , 0 , DEFAULT_SIZE),sizeof(size));
size[sizeof(size)-1]=0;
if( sscanf(size , "%dx%d", &w, &h ) != 2
|| (w <= 0) || (w > LCD_MAX_WIDTH)
|| (h <= 0) || (h > LCD_MAX_HEIGHT)) {
report (RPT_WARNING, "CFontz633_init: Cannot read size: %s. Using default value.\n", size);
sscanf( DEFAULT_SIZE , "%dx%d", &w, &h );
} else {
width = w;
height = h;
}
/* Which contrast */
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);
} else {
report (RPT_WARNING, "CFontz633_init: Contrast must between 0 and 1000. Using default value.\n");
}
/* 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) {
brightness = drvthis->config_get_int ( drvthis->name , "Brightness" , 0 , DEFAULT_BRIGHTNESS);
} else {
report (RPT_WARNING, "CFontz633_init: Brightness must between 0 and 100. Using default value.\n");
}
/* 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) {
offbrightness = drvthis->config_get_int ( drvthis->name , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS);
} else {
report (RPT_WARNING, "CFontz633_init: OffBrightness must between 0 and 100. Using default value.\n");
}
/* Which speed */
tmp = drvthis->config_get_int ( drvthis->name , "Speed" , 0 , DEFAULT_SPEED);
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_WARNING, "CFontz633_init: Speed must be 1200, 2400, 9600 or 19200. Using default value.\n", speed);
}
/* New firmware version? */
if(drvthis->config_get_bool( drvthis->name , "NewFirmware" , 0 , 0)) {
newfirmware = 1;
}
/* Reboot display? */
if (drvthis->config_get_bool( drvthis->name , "Reboot" , 0 , 0)) {
report (RPT_INFO, "LCDd: rebooting CrystalFontz LCD...\n");
reboot = 1;
}
/* Set up io port correctly, and open it... */
debug( RPT_DEBUG, "CFontz633: Opening serial device: %s", device);
fd = open (device, O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1) {
report (RPT_ERR, "CFontz633_init: failed (%s)\n", strerror (errno));
return -1;
}
tcgetattr (fd, &portset);
/* We use RAW mode */
#ifdef HAVE_CFMAKERAW
/* The easy way */
cfmakeraw( &portset );
#else
/* The hard way */
portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP
| INLCR | IGNCR | ICRNL | IXON );
portset.c_oflag &= ~OPOST;
portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN );
portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS );
portset.c_cflag |= CS8 | CREAD | CLOCAL ;
#endif
/* Set port speed */
cfsetospeed (&portset, speed);
cfsetispeed (&portset, B0);
/* Do it... */
tcsetattr (fd, TCSANOW, &portset);
/* Make sure the frame buffer is there... */
framebuf = (unsigned char *) malloc (width * height);
memset (framebuf, ' ', width * height);
/* Set display-specific stuff.. */
if (reboot) {
CFontz633_reboot ();
sleep (4);
reboot = 0;
}
sleep (1);
CFontz633_hidecursor ();
CFontz633_set_contrast (drvthis, contrast);
CFontz633_no_live_report ();
report (RPT_DEBUG, "CFontz633_init: done\n");
return 0;
}
/*
* Clean-up
*/
MODULE_EXPORT void
CFontz633_close (Driver * drvthis)
{
close (fd);
if(framebuf) free (framebuf);
framebuf = NULL;
if(old) free (old);
old = NULL;
}
/*
* Returns the display width
*/
MODULE_EXPORT int
CFontz633_width (Driver *drvthis)
{
return width;
}
/*
* Returns the display height
*/
MODULE_EXPORT int
CFontz633_height (Driver *drvthis)
{
return height;
}
/*
* Flushes all output to the lcd...
*/
MODULE_EXPORT void
CFontz633_flush (Driver * drvthis)
{
int i;
char *xp, *xq;
/*
* We don't use delta update yet.
* It should be possible but since we can only update one.
*/
if (old==NULL) {
old = (unsigned char *) malloc (width * height);
memset (old, ' ', width * height);
CFontz633_hardware_clear (drvthis);
}
xp = framebuf;
xq = old;
for (i=0; i<width; i++) {
if (*xp != *xq) {
send_bytes_message(fd, 16, CF633_Set_LCD_Contents_Line_One, &framebuf[0]);
memcpy(old, framebuf, width);
break;
}
xp++; xq++;
}
xp = &framebuf[width];
xq = &old[width];
for (i=0; i<width; i++) {
if (*xp != *xq) {
send_bytes_message(fd, 16, CF633_Set_LCD_Contents_Line_Two, &framebuf[width]);
memcpy(&old[width], &framebuf[width], width);
break;
}
xp++; xq++;
}
}
/*
* Prints a character on the lcd display, at position (x,y).
* The upper-left is (1,1), and the lower right should be (16,2).
*/
MODULE_EXPORT void
CFontz633_chr (Driver * drvthis, int x, int y, char c)
{
y--;
x--;
framebuf[(y * width) + x] = c;
}
/*
* Returns current contrast
* This is only the locally stored contrast, the contrast value
* cannot be retrieved from the LCD.
* Value 0 to 1000.
*/
MODULE_EXPORT int
CFontz633_get_contrast (Driver * drvthis)
{
return contrast;
}
/*
* Changes screen contrast (valid hardware value: 0-50)
* Value 0 to 1000.
*/
MODULE_EXPORT void
CFontz633_set_contrast (Driver * drvthis, int promille)
{
int hardware_contrast;
/* Check it */
if( promille < 0 || promille > 1000 )
return;
/* Store the software value since there is not get. */
contrast = promille;
hardware_contrast = contrast/20;
//send_onebyte_message(fd, CF633_Set_LCD_Contrast, hardware_contrast);
}
/*
* Sets the backlight on or off.
* The hardware support any value between 0 and 100.
* Need to find out if we have support for intermediate value.
*/
MODULE_EXPORT void
CFontz633_backlight (Driver * drvthis, int on)
{
if (on) {
//send_onebyte_message(fd, CF633_Set_LCD_And_Keypad_Backlight, brightness);
} else {
//send_onebyte_message(fd, CF633_Set_LCD_And_Keypad_Backlight, offbrightness);
}
}
/*
* Get rid of the blinking curson
*/
static void
CFontz633_hidecursor ()
{
send_onebyte_message(fd, CF633_Set_LCD_Cursor_Style, 0);
}
/*
* Stop live reporting of temperature.
*/
static void
CFontz633_no_live_report ()
{
char out[2]= {0, 0};
for (out[0]=0; out[0]<8; out[0]++)
send_bytes_message(fd, 2, CF633_Set_Up_Live_Fan_or_Temperature_Display , out);
}
/*
* Stop the reporting of any fan.
*/
static void
CFontz633_no_fan_report ()
{
send_onebyte_message(fd, CF633_Set_Up_Fan_Reporting, 0);
}
/*
* Stop the reporting of any temperature.
*/
static void
CFontz633_no_temp_report ()
{
char out[4]= {0, 0, 0, 0};
send_bytes_message(fd, 4, CF633_Set_Up_Temperature_Reporting, out);
}
/*
* Reset the display bios
*/
static void
CFontz633_reboot ()
{
char out[3]= {8, 18, 99};
send_bytes_message(fd, 3, CF633_Reboot, out);
}
/*
* Sets up for vertical bars.
*/
static void
CFontz633_init_vbar (Driver * drvthis)
{
char a[] = {
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1,
};
char b[] = {
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
};
char c[] = {
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
};
char d[] = {
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
};
char e[] = {
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
};
char f[] = {
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
};
char g[] = {
0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
};
if (custom != vbar) {
// printf("+++ vbar +++\n");
CFontz633_set_char (drvthis, 1, a);
CFontz633_set_char (drvthis, 2, b);
CFontz633_set_char (drvthis, 3, c);
CFontz633_set_char (drvthis, 4, d);
CFontz633_set_char (drvthis, 5, e);
CFontz633_set_char (drvthis, 6, f);
CFontz633_set_char (drvthis, 7, g);
custom = vbar;
}
}
/*
* Inits horizontal bars...
*/
static void
CFontz633_init_hbar (Driver * drvthis)
{
char a[] = {
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
};
char b[] = {
1, 1, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0,
};
char c[] = {
1, 1, 1, 0, 0, 0,
1, 1, 1, 0, 0, 0,
1, 1, 1, 0, 0, 0,
1, 1, 1, 0, 0, 0,
1, 1, 1, 0, 0, 0,
1, 1, 1, 0, 0, 0,
1, 1, 1, 0, 0, 0,
1, 1, 1, 0, 0, 0,
};
char d[] = {
1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 0, 0,
};
char e[] = {
1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 1, 0,
};
char f[] = {
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
};
if (custom != hbar) {
CFontz633_set_char (drvthis, 1, a);
CFontz633_set_char (drvthis, 2, b);
CFontz633_set_char (drvthis, 3, c);
CFontz633_set_char (drvthis, 4, d);
CFontz633_set_char (drvthis, 5, e);
CFontz633_set_char (drvthis, 6, f);
custom = hbar;
}
}
/*
* Draws a vertical bar...
*/
MODULE_EXPORT void
CFontz633_vbar (Driver * drvthis, int x, int y, int len, int promille, int options)
{
/* x and y are the start position of the bar.
* The bar by default grows in the 'up' direction
* (other direction not yet implemented).
* len is the number of characters that the bar is long at 100%
* promille is the number of promilles (0..1000) that the bar should be filled.
*/
CFontz633_init_vbar(drvthis);
lib_vbar_static(drvthis, x, y, len, promille, options, cellheight, 0);
}
/*
* Draws a horizontal bar to the right.
*/
MODULE_EXPORT void
CFontz633_hbar (Driver * drvthis, int x, int y, int len, int promille, int options)
{
/* x and y are the start position of the bar.
* The bar by default grows in the 'right' direction
* (other direction not yet implemented).
* len is the number of characters that the bar is long at 100%
* promille is the number of promilles (0..1000) that the bar should be filled.
*/
CFontz633_init_hbar(drvthis);
lib_hbar_static(drvthis, x, y, len, promille, options, cellwidth, 0);
}
/*
* Writes a big number.
* This is not supported on 633 because we only have 2 lines...
*/
MODULE_EXPORT void
CFontz633_num (Driver * drvthis, int x, int num)
{
/*
char out[5];
snprintf (out, sizeof(out), "%c%c%c", 28, x, num);
write (fd, out, 3);
*/
}
/*
* Sets a custom character from 0-7...
*
* For input, values > 0 mean "on" and values <= 0 are "off".
*
* The input is just an array of characters...
*/
MODULE_EXPORT void
CFontz633_set_char (Driver * drvthis, int n, char *dat)
{
char out[9];
int row, col;
int letter;
if (n < 0 || n > 7)
return;
if (!dat)
return;
out[0]=n; /* Custom char to define. xxx */
for (row = 0; row < cellheight; row++) {
letter = 0;
for (col = 0; col < cellwidth; col++) {
letter <<= 1;
letter |= (dat[(row * cellwidth) + col] > 0);
// if (dat[(row * cellheight) + col] == 0) printf(".");
// if (dat[(row * cellheight) + col] == 1) printf("+");
// if (dat[(row * cellheight) + col] == 2) printf("x");
// if (dat[(row * cellheight) + col] == 3) printf("*");
// printf("'%1d'", dat[(row * cellwidth) + col]);
// printf("%3d ", letter);
}
out[row+1]=letter;
// printf(": %d\n", letter);
}
send_bytes_message(fd, 9, CF633_Set_LCD_Special_Character_Data , out);
}
/*
* Places an icon on screen
*/
MODULE_EXPORT void
CFontz633_icon (Driver * drvthis, int x, int y, int icon)
{
char icons[3][6 * 8] = {
{
1, 1, 1, 1, 1, 1, /* Empty Heart */
1, 1, 0, 1, 0, 1,
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
1, 1, 0, 0, 0, 1,
1, 1, 1, 0, 1, 1,
1, 1, 1, 1, 1, 1,
},
{
1, 1, 1, 1, 1, 1, /* Filled Heart */
1, 1, 0, 1, 0, 1,
1, 0, 1, 0, 1, 0,
1, 0, 1, 1, 1, 0,
1, 0, 1, 1, 1, 0,
1, 1, 0, 1, 0, 1,
1, 1, 1, 0, 1, 1,
1, 1, 1, 1, 1, 1,
},
{
0, 0, 0, 0, 0, 0, /* Ellipsis */
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
1, 0, 1, 0, 1, 0,
},
};
switch( icon ) {
case ICON_BLOCK_FILLED:
CFontz633_chr( drvthis, x, y, 255 );
break;
case ICON_HEART_FILLED:
CFontz633_set_char( drvthis, 0, icons[1] );
CFontz633_chr( drvthis, x, y, 0 );
break;
case ICON_HEART_OPEN:
CFontz633_set_char( drvthis, 0, icons[0] );
CFontz633_chr( drvthis, x, y, 0 );
break;
default:
report( RPT_WARNING, "CFontz633_icon: unknown or unsupported icon: %d", icon );
}
}
/*
* Clears the LCD screen
*/
MODULE_EXPORT void
CFontz633_clear (Driver * drvthis)
{
memset (framebuf, ' ', width * height);
}
/*
* Hardware clears the LCD screen
*/
static void
CFontz633_hardware_clear (Driver * drvthis)
{
send_zerobyte_message(fd, CF633_Clear_LCD_Screen);
}
/*
* Prints a string on the lcd display, at position (x,y). The
* upper-left is (1,1), and the lower right should be (16,2).
*/
MODULE_EXPORT void
CFontz633_string (Driver * drvthis, int x, int y, char string[])
{
int i;
/* Convert 1-based coords to 0-based... */
x -= 1;
y -= 1;
for (i = 0; string[i]; i++) {
/* Check for buffer overflows... */
if ((y * width) + x + i > (width * height))
break;
framebuf[(y * width) + x + i] = string[i];
}
}
/*
* Does the heartbeat...
*/
MODULE_EXPORT void
CFontz633_heartbeat (Driver *drvthis, int type)
{
static int timer = 0;
static int saved_type = HEARTBEAT_ON;
int whichIcon;
if (type)
saved_type = type;
if (type == HEARTBEAT_ON) {
/* Set this to pulsate like a real heart beat... */
if( ((timer + 4) & 5))
whichIcon = ICON_HEART_OPEN;
else
whichIcon = ICON_HEART_FILLED;
/* place the icon */
CFontz633_icon (drvthis, width, 1, whichIcon);
}
timer++;
timer &= 0x0f;
}
+36
View File
@@ -0,0 +1,36 @@
#ifndef CFONTZ633_H
#define CFONTZ633_H
#include "lcd.h"
#define DEFAULT_CELL_WIDTH 6
#define DEFAULT_CELL_HEIGHT 8
#define DEFAULT_CONTRAST 560
#define DEFAULT_DEVICE "/dev/lcd"
#define DEFAULT_SPEED B19200
#define DEFAULT_BRIGHTNESS 100
#define DEFAULT_OFFBRIGHTNESS 0
#define DEFAULT_SIZE "16x2"
MODULE_EXPORT int CFontz633_init (Driver * drvthis, char *device);
MODULE_EXPORT void CFontz633_close (Driver * drvthis);
MODULE_EXPORT int CFontz633_width (Driver * drvthis);
MODULE_EXPORT int CFontz633_height (Driver * drvthis);
MODULE_EXPORT void CFontz633_clear (Driver * drvthis);
MODULE_EXPORT void CFontz633_flush (Driver * drvthis);
MODULE_EXPORT void CFontz633_string (Driver * drvthis, int x, int y, char string[]);
MODULE_EXPORT void CFontz633_chr (Driver * drvthis, int x, int y, char c);
MODULE_EXPORT void CFontz633_vbar (Driver * drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void CFontz633_hbar (Driver * drvthis, int x, int y, int len, int promille, int options);
MODULE_EXPORT void CFontz633_num (Driver * drvthis, int x, int num);
MODULE_EXPORT void CFontz633_heartbeat (Driver *drvthis, int type);
MODULE_EXPORT void CFontz633_icon(Driver * drvthis, int x, int y, int icon);
MODULE_EXPORT void CFontz633_set_char (Driver * drvthis, int n, char *dat);
MODULE_EXPORT int CFontz633_get_contrast (Driver * drvthis);
MODULE_EXPORT void CFontz633_set_contrast (Driver * drvthis, int contrast);
MODULE_EXPORT void CFontz633_backlight (Driver * drvthis, int on);
#endif
+251
View File
@@ -0,0 +1,251 @@
/*
* ===========================================================================
* 633 Test code for linux.
* Copyright 2002, David GLAUDE
* Partial copyright
* 2001 Crystalfontz America, Inc.
* brent@crystalfontz.com
* Written by Brent A. Crosby
* www.crystalfontz.com
* ===========================================================================
*/
#include "CFontz633io.h"
#include <stdio.h>
/*
* ----------------------------------------------------------------------------
* send_packet() send_packet() will send set the CRC in outgoing_response
* and send it to the host.
* ----------------------------------------------------------------------------
*/
void send_bytes_message(int fd, int len, int msg, char *framebuf)
{
int i;
outgoing_response.command=msg;
outgoing_response.data_length=len;
for (i = 0; i < outgoing_response.data_length; i++) {
outgoing_response.data[i]=framebuf[i];
}
send_packet(fd);
}
void send_onebyte_message(int fd, int msg, int value)
{
outgoing_response.command=msg;
outgoing_response.data_length=1;
outgoing_response.data[0]=value;
send_packet(fd);
}
void send_zerobyte_message(int fd, int msg)
{
outgoing_response.command=msg;
outgoing_response.data_length=0;
send_packet(fd);
}
/*----------------------------------------------------------------------------*/
int get_crc(char *bufptr, int len, int seed)
{
/*
* CRC lookup table to avoid bit-shifting loops.
*/
static const word crcLookupTable[256] = {
0x00000, 0x01189, 0x02312, 0x0329B, 0x04624, 0x057AD, 0x06536, 0x074BF,
0x08C48, 0x09DC1, 0x0AF5A, 0x0BED3, 0x0CA6C, 0x0DBE5, 0x0E97E, 0x0F8F7,
0x01081, 0x00108, 0x03393, 0x0221A, 0x056A5, 0x0472C, 0x075B7, 0x0643E,
0x09CC9, 0x08D40, 0x0BFDB, 0x0AE52, 0x0DAED, 0x0CB64, 0x0F9FF, 0x0E876,
0x02102, 0x0308B, 0x00210, 0x01399, 0x06726, 0x076AF, 0x04434, 0x055BD,
0x0AD4A, 0x0BCC3, 0x08E58, 0x09FD1, 0x0EB6E, 0x0FAE7, 0x0C87C, 0x0D9F5,
0x03183, 0x0200A, 0x01291, 0x00318, 0x077A7, 0x0662E, 0x054B5, 0x0453C,
0x0BDCB, 0x0AC42, 0x09ED9, 0x08F50, 0x0FBEF, 0x0EA66, 0x0D8FD, 0x0C974,
0x04204, 0x0538D, 0x06116, 0x0709F, 0x00420, 0x015A9, 0x02732, 0x036BB,
0x0CE4C, 0x0DFC5, 0x0ED5E, 0x0FCD7, 0x08868, 0x099E1, 0x0AB7A, 0x0BAF3,
0x05285, 0x0430C, 0x07197, 0x0601E, 0x014A1, 0x00528, 0x037B3, 0x0263A,
0x0DECD, 0x0CF44, 0x0FDDF, 0x0EC56, 0x098E9, 0x08960, 0x0BBFB, 0x0AA72,
0x06306, 0x0728F, 0x04014, 0x0519D, 0x02522, 0x034AB, 0x00630, 0x017B9,
0x0EF4E, 0x0FEC7, 0x0CC5C, 0x0DDD5, 0x0A96A, 0x0B8E3, 0x08A78, 0x09BF1,
0x07387, 0x0620E, 0x05095, 0x0411C, 0x035A3, 0x0242A, 0x016B1, 0x00738,
0x0FFCF, 0x0EE46, 0x0DCDD, 0x0CD54, 0x0B9EB, 0x0A862, 0x09AF9, 0x08B70,
0x08408, 0x09581, 0x0A71A, 0x0B693, 0x0C22C, 0x0D3A5, 0x0E13E, 0x0F0B7,
0x00840, 0x019C9, 0x02B52, 0x03ADB, 0x04E64, 0x05FED, 0x06D76, 0x07CFF,
0x09489, 0x08500, 0x0B79B, 0x0A612, 0x0D2AD, 0x0C324, 0x0F1BF, 0x0E036,
0x018C1, 0x00948, 0x03BD3, 0x02A5A, 0x05EE5, 0x04F6C, 0x07DF7, 0x06C7E,
0x0A50A, 0x0B483, 0x08618, 0x09791, 0x0E32E, 0x0F2A7, 0x0C03C, 0x0D1B5,
0x02942, 0x038CB, 0x00A50, 0x01BD9, 0x06F66, 0x07EEF, 0x04C74, 0x05DFD,
0x0B58B, 0x0A402, 0x09699, 0x08710, 0x0F3AF, 0x0E226, 0x0D0BD, 0x0C134,
0x039C3, 0x0284A, 0x01AD1, 0x00B58, 0x07FE7, 0x06E6E, 0x05CF5, 0x04D7C,
0x0C60C, 0x0D785, 0x0E51E, 0x0F497, 0x08028, 0x091A1, 0x0A33A, 0x0B2B3,
0x04A44, 0x05BCD, 0x06956, 0x078DF, 0x00C60, 0x01DE9, 0x02F72, 0x03EFB,
0x0D68D, 0x0C704, 0x0F59F, 0x0E416, 0x090A9, 0x08120, 0x0B3BB, 0x0A232,
0x05AC5, 0x04B4C, 0x079D7, 0x0685E, 0x01CE1, 0x00D68, 0x03FF3, 0x02E7A,
0x0E70E, 0x0F687, 0x0C41C, 0x0D595, 0x0A12A, 0x0B0A3, 0x08238, 0x093B1,
0x06B46, 0x07ACF, 0x04854, 0x059DD, 0x02D62, 0x03CEB, 0x00E70, 0x01FF9,
0x0F78F, 0x0E606, 0x0D49D, 0x0C514, 0x0B1AB, 0x0A022, 0x092B9, 0x08330,
0x07BC7, 0x06A4E, 0x058D5, 0x0495C, 0x03DE3, 0x02C6A, 0x01EF1, 0x00F78
};
/*
* Initial value of the CRC.
*/
int newCrc;
/*
* seed should be 0xFFFF;
*/
newCrc = seed;
/*
* This algorithim is based on the IrDA LAP example.
*/
while (len--)
newCrc =
(newCrc >> 8) ^ crcLookupTable[(newCrc ^ *bufptr++) & 0xff];
/*
* Make this crc match the one's complement that is sent in the
*/
/*
* packet.
*/
return (~newCrc);
}
void
SendByte(int fd, unsigned char datum)
{
int bytes_written;
bytes_written = 0;
bytes_written = write(fd, &datum, 1);
if (bytes_written != 1) {
printf("SendByte(): only %d of %d bytes sent.", bytes_written, 1);
}
/* printf(" Sent 0x%03x \n ", datum); */
return;
}
/*---------------------------------------------------------------------------*/
COMMAND_PACKET outgoing_response;
/*
* ============================================================================
* send_packet() send_packet() will send set the CRC in outgoing_response
* and send it to the host.
* ----------------------------------------------------------------------------
*/
#if 0
void
send_packet(int fd)
{
ubyte i;
printf("* Packet ");
SendByte(fd, outgoing_response.command);
printf("cmd:%d ", outgoing_response.command);
SendByte(fd, outgoing_response.data_length);
printf("len:%d [ ", outgoing_response.data_length);
for (i = 0; i < outgoing_response.data_length; i++) {
SendByte(fd, outgoing_response.data[i]);
printf("%02x ", outgoing_response.data[i]);
}
printf("] ");
/*
* Set the CRC
*/
outgoing_response.CRC.as_word =
get_crc((ubyte *) & outgoing_response,
outgoing_response.data_length + 2, 0xFFFF);
SendByte(fd, outgoing_response.CRC.as_bytes[0]);
printf("crc: 0x%02x", outgoing_response.CRC.as_bytes[0]);
SendByte(fd, outgoing_response.CRC.as_bytes[1]);
printf("%02x *\n", outgoing_response.CRC.as_bytes[1]);
}
#else
void
send_packet(int fd)
{
ubyte i;
SendByte(fd, outgoing_response.command);
SendByte(fd, outgoing_response.data_length);
for (i = 0; i < outgoing_response.data_length; i++) {
SendByte(fd, outgoing_response.data[i]);
}
/*
* Set the CRC
*/
outgoing_response.CRC.as_word =
get_crc((ubyte *) & outgoing_response,
outgoing_response.data_length + 2, 0xFFFF);
SendByte(fd, outgoing_response.CRC.as_bytes[0]);
SendByte(fd, outgoing_response.CRC.as_bytes[1]);
}
#endif
/* ======================================================================== */
#if 0
unsigned char buffer[10000];
int buffer_count;
void
Clear_Buffer(void)
{
buffer_count = 0;
}
void
Buffer_Character(int fd, unsigned char datum)
{
buffer[buffer_count++] = datum;
if (256 <= buffer_count)
Send_Buffer(fd);
}
void
Buffer_String(int fd, char *input)
{
char this_character;
while ((this_character = *input++))
Buffer_Character(fd, this_character);
}
void
Send_Buffer(int fd)
{
int bytes_written = 0;
if (buffer_count) {
bytes_written = write(fd, &buffer, buffer_count);
if (bytes_written != buffer_count) {
printf("Send_Buffer(): WriteFile()failed.");
} else if (bytes_written != buffer_count) {
printf("Send_Buffer():only % d of % d bytes sent.",
bytes_written, 1);
}
buffer_count = 0;
}
}
/*============================================================================*/
COMMAND_PACKET incoming_command;
#endif
+78
View File
@@ -0,0 +1,78 @@
#ifndef CFONTZ633IO_H
#define CFONTZ633IO_H
/* ====================================================================
* 635 WinTest Code.
* SERIAL.C: Windows 32 packet based example code
* Copyright 2001, Crystalfontz America, Inc. Written by Brent A. Crosby
* www.crystalfontz.com, brent@crystalfontz.com
* ====================================================================
*/
#define CF633_Ping_Command 0
#define CF633_Get_Hardware_And_Firmware_Version 1
#define CF633_Write_User_Flash_Area 2
#define CF633_Read_User_Flash_Area 3
#define CF633_Store_Current_State_As_Boot_State 4
#define CF633_Reboot 5
#define CF633_Clear_LCD_Screen 6
#define CF633_Set_LCD_Contents_Line_One 7
#define CF633_Set_LCD_Contents_Line_Two 8
#define CF633_Set_LCD_Special_Character_Data 9
#define CF633_Read_Height_Bytes_of_LCD_Memory 10
#define CF633_Set_LCD_Cursor_Position 11
#define CF633_Set_LCD_Cursor_Style 12
#define CF633_Set_LCD_Contrast 13
#define CF633_Set_LCD_And_Keypad_Backlight 14
#define CF633_Query_Last_Fan_Pulse_Count 15
#define CF633_Set_Up_Fan_Reporting 16
#define CF633_Set_Fan_Power 17
#define CF633_Read_DOW_Device_Information 18
#define CF633_Set_Up_Temperature_Reporting 19
#define CF633_Arbitrary_DOW_Transaction 20
#define CF633_Set_Up_Live_Fan_or_Temperature_Display 21
typedef unsigned char ubyte;
typedef signed char sbyte;
typedef unsigned short word;
typedef unsigned long dword;
typedef union {
ubyte as_bytes[2];
word as_word;
} WORD_UNION;
void send_bytes_message(int fd, int len, int msg, char *framebuf);
void send_onebyte_message(int fd, int msg, int value);
void send_zerobyte_message(int fd, int msg);
void EmptyReceiveBuffer(void);
int Serial_Init(int port, int baud_rate);
void Uninit_Serial();
void SendByte(int fd, unsigned char datum);
void Sync_Read_Buffer(ubyte expected_bytes);
int BytesAvail(void);
char GetByte(void);
int PeekBytesAvail(void);
void Sync_Peek_Pointer(void);
void AcceptPeekedData(void);
ubyte PeekByte(void);
void Clear_Buffer(void);
void Buffer_Character(int fd, unsigned char datum);
void Buffer_String(int fd, char *input);
void Send_Buffer(int fd);
#define MAX_DATA_LENGTH 16
#define MAX_COMMAND 21
typedef struct {
ubyte command;
ubyte data_length;
ubyte data[MAX_DATA_LENGTH];
WORD_UNION CRC;
} COMMAND_PACKET;
int get_crc(char * bufptr, int len, int seed);
extern COMMAND_PACKET incoming_command;
extern COMMAND_PACKET outgoing_response;
ubyte check_for_packet(ubyte expected_length);
void send_packet(int fd);
#endif
+3 -1
View File
@@ -6,7 +6,7 @@
##
pkglib_PROGRAMS = @DRIVERS@
EXTRA_PROGRAMS = bayrad.!SO! CFontz.!SO! curses.!SO! glk.!SO! hd44780.!SO! irman.!SO! joy.!SO! lb216.!SO! lcdm001.!SO! lirc.!SO! MtxOrb.!SO! sed1330.!SO! sed1520.!SO! stv5730.!SO! svga.!SO! t6963.!SO! text.!SO! wirz_sli.!SO!
EXTRA_PROGRAMS = bayrad.!SO! CFontz.!SO! CFontz633.!SO! curses.!SO! glk.!SO! hd44780.!SO! irman.!SO! joy.!SO! lb216.!SO! lcdm001.!SO! lirc.!SO! MtxOrb.!SO! sed1330.!SO! sed1520.!SO! stv5730.!SO! svga.!SO! t6963.!SO! text.!SO! wirz_sli.!SO!
noinst_LIBRARIES = libLCD.a
EXTRA_DIST = Makefile.am.pre
@@ -25,6 +25,7 @@ LIBS =
EXEEXT =
CFontz_!SO!_LDADD = libLCD.a
CFontz633_!SO!_LDADD = libLCD.a
curses_!SO!_LDADD = @LIBCURSES@
hd44780_!SO!_LDADD = libLCD.a
irman_!SO!_LDADD = @LIBIRMAN@
@@ -36,6 +37,7 @@ libLCD_a_SOURCES = lcd_lib.h lcd_lib.c
bayrad_!SO!_SOURCES = lcd.h bayrad.h bayrad.c report.h
CFontz_!SO!_SOURCES = lcd.h CFontz.c CFontz.h report.h
CFontz633_!SO!_SOURCES = lcd.h CFontz633.c CFontz633.h CFontz633io.c CFontz633io.h report.h
curses_!SO!_SOURCES = lcd.h curses_drv.h curses_drv.c report.h
glk_!SO!_SOURCES = lcd.h glk.c glk.h glkproto.c glkproto.h report.h
hd44780_!SO!_SOURCES = lcd.h hd44780.h hd44780.c hd44780-drivers.h hd44780-low.h hd44780-charmap.h hd44780-4bit.c hd44780-4bit.h hd44780-ext8bit.c hd44780-ext8bit.h lcd_sem.c lcd_sem.h hd44780-serialLpt.c hd44780-serialLpt.h hd44780-winamp.c hd44780-winamp.h hd44780-picanlcd.c hd44780-picanlcd.h port.h lpt-port.h timing.h report.h