v0.5 kick-off
This commit is contained in:
+187
-180
@@ -35,10 +35,12 @@
|
||||
|
||||
#include "lcd.h"
|
||||
#include "CFontz.h"
|
||||
#include "render.h"
|
||||
//#include "drv_base.h"
|
||||
//#include "shared/debug.h"
|
||||
#include "shared/str.h"
|
||||
#include "shared/report.h"
|
||||
#include "server/configfile.h"
|
||||
#include "report.h"
|
||||
//#include "server/configfile.h"
|
||||
|
||||
|
||||
static int custom = 0;
|
||||
typedef enum {
|
||||
@@ -49,25 +51,36 @@ typedef enum {
|
||||
} custom_type;
|
||||
|
||||
static int fd;
|
||||
static char *framebuf = 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 = "CFontz_";
|
||||
|
||||
// Internal functions
|
||||
static void CFontz_linewrap (int on);
|
||||
static void CFontz_autoscroll (int on);
|
||||
static void CFontz_hidecursor ();
|
||||
static void CFontz_reboot ();
|
||||
static void CFontz_heartbeat (int type);
|
||||
|
||||
// TODO: Get rid of this variable?
|
||||
lcd_logical_driver *CFontz;
|
||||
|
||||
// TODO: Get the frame buffers working right
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Opens com port and sets baud correctly...
|
||||
//
|
||||
int
|
||||
CFontz_init (lcd_logical_driver * driver, char *args)
|
||||
CFontz_init (Driver * drvthis, char *args)
|
||||
{
|
||||
struct termios portset;
|
||||
int tmp, w, h;
|
||||
@@ -78,57 +91,52 @@ CFontz_init (lcd_logical_driver * driver, char *args)
|
||||
int speed = DEFAULT_SPEED;
|
||||
char size[200] = DEFAULT_SIZE;
|
||||
|
||||
CFontz = driver;
|
||||
|
||||
debug(RPT_INFO, "CFontz: init(%p,%s)", driver, args );
|
||||
|
||||
// TODO: replace DriverName with driver->name when that field exists.
|
||||
#define DriverName "CFontz"
|
||||
|
||||
debug(RPT_INFO, "CFontz: init(%p,%s)", drvthis, args );
|
||||
|
||||
/*Read config file*/
|
||||
|
||||
/*Which serial device should be used*/
|
||||
strncpy(device, config_get_string ( DriverName , "Device" , 0 , DEFAULT_DEVICE),sizeof(device));
|
||||
strncpy(device, drvthis->config_get_string ( drvthis->name , "Device" , 0 , DEFAULT_DEVICE),sizeof(device));
|
||||
device[sizeof(device)-1]=0;
|
||||
debug (RPT_INFO,"CFontz: Using device: %s", device);
|
||||
|
||||
/*Which size*/
|
||||
strncpy(size, config_get_string ( DriverName , "Size" , 0 , DEFAULT_SIZE),sizeof(size));
|
||||
strncpy(size, drvthis->config_get_string ( drvthis->name , "Size" , 0 , DEFAULT_SIZE),sizeof(size));
|
||||
size[sizeof(size)-1]=0;
|
||||
if( sscanf(size , "%dx%d", &w, &h ) != 2
|
||||
|| (w <= 0) || (w > LCD_MAX_WIDTH)
|
||||
|| (h <= 0) || (h > LCD_MAX_HEIGHT)) {
|
||||
report (RPT_WARNING, "CFontz_init: Cannot read size: %s. Using default value.\n", size);
|
||||
sscanf( DEFAULT_SIZE , "%dx%d", &w, &h );
|
||||
} else {
|
||||
width = w;
|
||||
height = h;
|
||||
}
|
||||
driver->wid = w;
|
||||
driver->hgt = h;
|
||||
|
||||
/*Which contrast*/
|
||||
if (0<=config_get_int ( DriverName , "Contrast" , 0 , DEFAULT_CONTRAST) && config_get_int ( DriverName , "Contrast" , 0 , DEFAULT_CONTRAST) <= 255) {
|
||||
contrast = config_get_int ( DriverName , "Contrast" , 0 , DEFAULT_CONTRAST);
|
||||
if (0<=drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST) && drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST) <= 255) {
|
||||
contrast = drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST);
|
||||
} else {
|
||||
report (RPT_WARNING, "CFontz_init: Contrast must between 0 and 255. Using default value.\n");
|
||||
}
|
||||
|
||||
/*Which backlight brightness*/
|
||||
if (0<=config_get_int ( DriverName , "Brightness" , 0 , DEFAULT_BRIGHTNESS) && config_get_int ( DriverName , "Brightness" , 0 , DEFAULT_BRIGHTNESS) <= 255) {
|
||||
brightness = config_get_int ( DriverName , "Brightness" , 0 , DEFAULT_BRIGHTNESS);
|
||||
if (0<=drvthis->config_get_int ( drvthis->name , "Brightness" , 0 , DEFAULT_BRIGHTNESS) && drvthis->config_get_int ( drvthis->name , "Brightness" , 0 , DEFAULT_BRIGHTNESS) <= 255) {
|
||||
brightness = drvthis->config_get_int ( drvthis->name , "Brightness" , 0 , DEFAULT_BRIGHTNESS);
|
||||
} else {
|
||||
report (RPT_WARNING, "CFontz_init: Brightness must between 0 and 255. Using default value.\n");
|
||||
}
|
||||
|
||||
/*Which backlight-off "brightness"*/
|
||||
if (0<=config_get_int ( DriverName , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS) && config_get_int ( DriverName , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS) <= 255) {
|
||||
offbrightness = config_get_int ( DriverName , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS);
|
||||
if (0<=drvthis->config_get_int ( drvthis->name , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS) && drvthis->config_get_int ( drvthis->name , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS) <= 255) {
|
||||
offbrightness = drvthis->config_get_int ( drvthis->name , "OffBrightness" , 0 , DEFAULT_OFFBRIGHTNESS);
|
||||
} else {
|
||||
report (RPT_WARNING, "CFontz_init: OffBrightness must between 0 and 255. Using default value.\n");
|
||||
}
|
||||
|
||||
|
||||
/*Which speed*/
|
||||
tmp = config_get_int ( DriverName , "Speed" , 0 , DEFAULT_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;
|
||||
@@ -136,12 +144,12 @@ CFontz_init (lcd_logical_driver * driver, char *args)
|
||||
}
|
||||
|
||||
/*New firmware version?*/
|
||||
if(config_get_bool( DriverName , "NewFirmware" , 0 , 0)) {
|
||||
if(drvthis->config_get_bool( drvthis->name , "NewFirmware" , 0 , 0)) {
|
||||
newfirmware = 1;
|
||||
}
|
||||
|
||||
/*Reboot display?*/
|
||||
if (config_get_bool( DriverName , "Reboot" , 0 , 0)) {
|
||||
if (drvthis->config_get_bool( drvthis->name , "Reboot" , 0 , 0)) {
|
||||
report (RPT_INFO, "LCDd: rebooting CrystalFontz LCD...\n");
|
||||
reboot = 1;
|
||||
}
|
||||
@@ -178,10 +186,8 @@ CFontz_init (lcd_logical_driver * driver, char *args)
|
||||
tcsetattr (fd, TCSANOW, &portset);
|
||||
|
||||
// Make sure the frame buffer is there...
|
||||
if (!CFontz->framebuf)
|
||||
CFontz->framebuf = (unsigned char *)
|
||||
malloc (CFontz->wid * CFontz->hgt);
|
||||
memset (CFontz->framebuf, ' ', CFontz->wid * CFontz->hgt);
|
||||
framebuf = (unsigned char *) malloc (width * height);
|
||||
memset (framebuf, ' ', width * height);
|
||||
|
||||
// Set display-specific stuff..
|
||||
if (reboot) {
|
||||
@@ -193,84 +199,107 @@ CFontz_init (lcd_logical_driver * driver, char *args)
|
||||
CFontz_hidecursor ();
|
||||
CFontz_linewrap (1);
|
||||
CFontz_autoscroll (0);
|
||||
CFontz_backlight (backlight_brightness);
|
||||
//CFontz_backlight (drvthis, backlight_brightness); // render.c variables should not be used in drivers !
|
||||
|
||||
// Set the functions the driver supports...
|
||||
// Set variables for server
|
||||
drvthis->api_version = api_version;
|
||||
drvthis->stay_in_foreground = &stay_in_foreground;
|
||||
drvthis->supports_multiple = &supports_multiple;
|
||||
|
||||
driver->clear = CFontz_clear;
|
||||
driver->string = CFontz_string;
|
||||
driver->chr = CFontz_chr;
|
||||
driver->vbar = CFontz_vbar;
|
||||
driver->init_vbar = CFontz_init_vbar;
|
||||
driver->hbar = CFontz_hbar;
|
||||
driver->init_hbar = CFontz_init_hbar;
|
||||
driver->num = CFontz_num;
|
||||
// Set the functions the driver supports
|
||||
|
||||
driver->init = CFontz_init;
|
||||
driver->close = CFontz_close;
|
||||
driver->flush = CFontz_flush;
|
||||
driver->flush_box = CFontz_flush_box;
|
||||
driver->contrast = CFontz_contrast;
|
||||
driver->backlight = CFontz_backlight;
|
||||
driver->set_char = CFontz_set_char;
|
||||
driver->icon = CFontz_icon;
|
||||
driver->draw_frame = CFontz_draw_frame;
|
||||
drvthis->clear = CFontz_clear;
|
||||
drvthis->string = CFontz_string;
|
||||
drvthis->chr = CFontz_chr;
|
||||
drvthis->old_vbar = CFontz_vbar;
|
||||
drvthis->init_vbar = CFontz_init_vbar;
|
||||
drvthis->old_hbar = CFontz_hbar;
|
||||
drvthis->init_hbar = CFontz_init_hbar;
|
||||
drvthis->num = CFontz_num;
|
||||
|
||||
CFontz_contrast (contrast);
|
||||
drvthis->init = CFontz_init;
|
||||
drvthis->close = CFontz_close;
|
||||
drvthis->flush = CFontz_flush;
|
||||
drvthis->get_contrast = CFontz_get_contrast;
|
||||
drvthis->set_contrast = CFontz_set_contrast;
|
||||
drvthis->backlight = CFontz_backlight;
|
||||
drvthis->set_char = CFontz_set_char;
|
||||
drvthis->old_icon = CFontz_icon;
|
||||
drvthis->heartbeat = CFontz_heartbeat;
|
||||
|
||||
driver->cellwid = DEFAULT_CELL_WIDTH;
|
||||
driver->cellhgt = DEFAULT_CELL_HEIGHT;
|
||||
CFontz_set_contrast (drvthis, contrast);
|
||||
|
||||
driver->heartbeat = CFontz_heartbeat;
|
||||
|
||||
report (RPT_DEBUG, "CFontz_init: done\n");
|
||||
|
||||
return fd;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clean-up
|
||||
//
|
||||
void
|
||||
CFontz_close ()
|
||||
MODULE_EXPORT void
|
||||
CFontz_close (Driver * drvthis)
|
||||
{
|
||||
close (fd);
|
||||
|
||||
if (CFontz->framebuf)
|
||||
free (CFontz->framebuf);
|
||||
|
||||
CFontz->framebuf = NULL;
|
||||
if(framebuf) free (framebuf);
|
||||
framebuf = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
CFontz_flush ()
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display width
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
CFontz_width (Driver *drvthis)
|
||||
{
|
||||
CFontz_draw_frame (CFontz->framebuf);
|
||||
return width;
|
||||
}
|
||||
|
||||
void
|
||||
CFontz_flush_box (int lft, int top, int rgt, int bot)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display height
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
CFontz_height (Driver *drvthis)
|
||||
{
|
||||
int y;
|
||||
char out[LCD_MAX_WIDTH];
|
||||
return height;
|
||||
}
|
||||
|
||||
// printf("Flush (%i,%i)-(%i,%i)\n", lft, top, rgt, bot);
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Flushes all output to the lcd...
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
CFontz_flush (Driver * drvthis)
|
||||
{
|
||||
char out[LCD_MAX_WIDTH * LCD_MAX_HEIGHT];
|
||||
int i;
|
||||
|
||||
for (y = top; y <= bot; y++) {
|
||||
snprintf (out, sizeof(out), "%c%c%c", 17, lft, y);
|
||||
write (fd, out, 4);
|
||||
write (fd, CFontz->framebuf + (y * CFontz->wid) + lft, rgt - lft + 1);
|
||||
// Custom characters start at 128, not at 0.
|
||||
/*
|
||||
for(i=0; i<width*height; i++)
|
||||
{
|
||||
if(framebuf[i] < 32 && framebuf[i] >= 0) framebuf[i] += 128;
|
||||
}
|
||||
*/
|
||||
|
||||
for (i = 0; i < height; i++) {
|
||||
snprintf (out, sizeof(out), "%c%c%c", 17, 0, i);
|
||||
write (fd, out, 3);
|
||||
write (fd, framebuf + (width * i), width);
|
||||
}
|
||||
|
||||
/*
|
||||
snprintf(out, sizeof(out), "%c", 1);
|
||||
write(fd, out, 1);
|
||||
write(fd, framebuf, width*height);
|
||||
*/
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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).
|
||||
//
|
||||
void
|
||||
CFontz_chr (int x, int y, char c)
|
||||
MODULE_EXPORT void
|
||||
CFontz_chr (Driver * drvthis, int x, int y, char c)
|
||||
{
|
||||
y--;
|
||||
x--;
|
||||
@@ -280,38 +309,51 @@ CFontz_chr (int x, int y, char c)
|
||||
|
||||
// For V2 of the firmware to get the block to display right
|
||||
if (newfirmware && c==-1) {
|
||||
c=214;
|
||||
c=214;
|
||||
}
|
||||
|
||||
CFontz->framebuf[(y * CFontz->wid) + x] = c;
|
||||
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
|
||||
CFontz_get_contrast (Driver * drvthis)
|
||||
{
|
||||
return contrast;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Changes screen contrast (0-255; 140 seems good)
|
||||
// Value 0 to 100.
|
||||
//
|
||||
int
|
||||
CFontz_contrast (int contrast)
|
||||
MODULE_EXPORT void
|
||||
CFontz_set_contrast (Driver * drvthis, int promille)
|
||||
{
|
||||
int realcontrast;
|
||||
char out[4];
|
||||
static int status = 140;
|
||||
|
||||
if (contrast > 0) {
|
||||
status = contrast;
|
||||
realcontrast = (((int) (status)) * 100) / 255;
|
||||
snprintf (out, sizeof(out), "%c%c", 15, realcontrast);
|
||||
write (fd, out, 3);
|
||||
}
|
||||
// Check it
|
||||
if( promille < 0 || promille > 1000 )
|
||||
return;
|
||||
|
||||
return status;
|
||||
// Store it
|
||||
contrast = promille;
|
||||
|
||||
// And do it
|
||||
snprintf (out, sizeof(out), "%c%c", 15, (unsigned char) (promille / 10) ); // converted to be 0 to 100
|
||||
write (fd, out, 3);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets the backlight on or off -- can be done quickly for
|
||||
// an intermediate brightness...
|
||||
//
|
||||
void
|
||||
CFontz_backlight (int on)
|
||||
MODULE_EXPORT void
|
||||
CFontz_backlight (Driver * drvthis, int on)
|
||||
{
|
||||
char out[4];
|
||||
if (on) {
|
||||
@@ -375,8 +417,8 @@ CFontz_reboot ()
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets up for vertical bars. Call before CFontz->vbar()
|
||||
//
|
||||
void
|
||||
CFontz_init_vbar ()
|
||||
MODULE_EXPORT void
|
||||
CFontz_init_vbar (Driver * drvthis)
|
||||
{
|
||||
char a[] = {
|
||||
0, 0, 0, 0, 0, 0,
|
||||
@@ -450,13 +492,13 @@ CFontz_init_vbar ()
|
||||
};
|
||||
|
||||
if (custom != vbar) {
|
||||
CFontz_set_char (1, a);
|
||||
CFontz_set_char (2, b);
|
||||
CFontz_set_char (3, c);
|
||||
CFontz_set_char (4, d);
|
||||
CFontz_set_char (5, e);
|
||||
CFontz_set_char (6, f);
|
||||
CFontz_set_char (7, g);
|
||||
CFontz_set_char (drvthis, 1, a);
|
||||
CFontz_set_char (drvthis, 2, b);
|
||||
CFontz_set_char (drvthis, 3, c);
|
||||
CFontz_set_char (drvthis, 4, d);
|
||||
CFontz_set_char (drvthis, 5, e);
|
||||
CFontz_set_char (drvthis, 6, f);
|
||||
CFontz_set_char (drvthis, 7, g);
|
||||
custom = vbar;
|
||||
}
|
||||
}
|
||||
@@ -464,8 +506,8 @@ CFontz_init_vbar ()
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Inits horizontal bars...
|
||||
//
|
||||
void
|
||||
CFontz_init_hbar ()
|
||||
MODULE_EXPORT void
|
||||
CFontz_init_hbar (Driver * drvthis)
|
||||
{
|
||||
|
||||
char a[] = {
|
||||
@@ -530,12 +572,12 @@ CFontz_init_hbar ()
|
||||
};
|
||||
|
||||
if (custom != hbar) {
|
||||
CFontz_set_char (1, a);
|
||||
CFontz_set_char (2, b);
|
||||
CFontz_set_char (3, c);
|
||||
CFontz_set_char (4, d);
|
||||
CFontz_set_char (5, e);
|
||||
CFontz_set_char (6, f);
|
||||
CFontz_set_char (drvthis, 1, a);
|
||||
CFontz_set_char (drvthis, 2, b);
|
||||
CFontz_set_char (drvthis, 3, c);
|
||||
CFontz_set_char (drvthis, 4, d);
|
||||
CFontz_set_char (drvthis, 5, e);
|
||||
CFontz_set_char (drvthis, 6, f);
|
||||
custom = hbar;
|
||||
}
|
||||
}
|
||||
@@ -543,19 +585,19 @@ CFontz_init_hbar ()
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a vertical bar...
|
||||
//
|
||||
void
|
||||
CFontz_vbar (int x, int len)
|
||||
MODULE_EXPORT void
|
||||
CFontz_vbar (Driver * drvthis, int x, int len)
|
||||
{
|
||||
char map[9] = { 32, 1, 2, 3, 4, 5, 6, 7, 255 };
|
||||
|
||||
int y;
|
||||
for (y = CFontz->hgt; y > 0 && len > 0; y--) {
|
||||
if (len >= CFontz->cellhgt)
|
||||
CFontz_chr (x, y, 255);
|
||||
for (y = height; y > 0 && len > 0; y--) {
|
||||
if (len >= cellheight)
|
||||
CFontz_chr (drvthis, x, y, 255);
|
||||
else
|
||||
CFontz_chr (x, y, map[len]);
|
||||
CFontz_chr (drvthis, x, y, map[len]);
|
||||
|
||||
len -= CFontz->cellhgt;
|
||||
len -= cellheight;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -563,18 +605,18 @@ CFontz_vbar (int x, int len)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
void
|
||||
CFontz_hbar (int x, int y, int len)
|
||||
MODULE_EXPORT void
|
||||
CFontz_hbar (Driver * drvthis, int x, int y, int len)
|
||||
{
|
||||
char map[7] = { 32, 1, 2, 3, 4, 5, 6 };
|
||||
|
||||
for (; x <= CFontz->wid && len > 0; x++) {
|
||||
if (len >= CFontz->cellwid)
|
||||
CFontz_chr (x, y, map[6]);
|
||||
for (; x <= width && len > 0; x++) {
|
||||
if (len >= cellwidth)
|
||||
CFontz_chr (drvthis, x, y, map[6]);
|
||||
else
|
||||
CFontz_chr (x, y, map[len]);
|
||||
CFontz_chr (drvthis, x, y, map[len]);
|
||||
|
||||
len -= CFontz->cellwid;
|
||||
len -= cellwidth;
|
||||
|
||||
}
|
||||
|
||||
@@ -584,8 +626,8 @@ CFontz_hbar (int x, int y, int len)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Writes a big number.
|
||||
//
|
||||
void
|
||||
CFontz_num (int x, int num)
|
||||
MODULE_EXPORT void
|
||||
CFontz_num (Driver * drvthis, int x, int num)
|
||||
{
|
||||
char out[5];
|
||||
snprintf (out, sizeof(out), "%c%c%c", 28, x, num);
|
||||
@@ -599,8 +641,8 @@ CFontz_num (int x, int num)
|
||||
//
|
||||
// The input is just an array of characters...
|
||||
//
|
||||
void
|
||||
CFontz_set_char (int n, char *dat)
|
||||
MODULE_EXPORT void
|
||||
CFontz_set_char (Driver * drvthis, int n, char *dat)
|
||||
{
|
||||
char out[4];
|
||||
int row, col;
|
||||
@@ -614,18 +656,18 @@ CFontz_set_char (int n, char *dat)
|
||||
snprintf (out, sizeof(out), "%c%c", 25, n);
|
||||
write (fd, out, 2);
|
||||
|
||||
for (row = 0; row < CFontz->cellhgt; row++) {
|
||||
for (row = 0; row < cellheight; row++) {
|
||||
letter = 0;
|
||||
for (col = 0; col < CFontz->cellwid; col++) {
|
||||
for (col = 0; col < cellheight; col++) {
|
||||
letter <<= 1;
|
||||
letter |= (dat[(row * CFontz->cellwid) + col] > 0);
|
||||
letter |= (dat[(row * cellheight) + col] > 0);
|
||||
}
|
||||
write (fd, &letter, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CFontz_icon (int which, char dest)
|
||||
MODULE_EXPORT void
|
||||
CFontz_icon (Driver * drvthis, int which, char dest)
|
||||
{
|
||||
char icons[3][6 * 8] = {
|
||||
{
|
||||
@@ -665,51 +707,16 @@ CFontz_icon (int which, char dest)
|
||||
|
||||
if (custom == bign)
|
||||
custom = beat;
|
||||
CFontz_set_char (dest, &icons[which][0]);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Blasts a single frame onscreen, to the lcd...
|
||||
//
|
||||
// Input is a character array, sized CFontz->wid*CFontz->hgt
|
||||
//
|
||||
void
|
||||
CFontz_draw_frame (char *dat)
|
||||
{
|
||||
char out[LCD_MAX_WIDTH * LCD_MAX_HEIGHT];
|
||||
int i;
|
||||
|
||||
if (!dat)
|
||||
return;
|
||||
|
||||
// Custom characters start at 128, not at 0.
|
||||
/*
|
||||
for(i=0; i<CFontz->wid*CFontz->hgt; i++)
|
||||
{
|
||||
if(dat[i] < 32 && dat[i] >= 0) dat[i] += 128;
|
||||
}
|
||||
*/
|
||||
|
||||
for (i = 0; i < CFontz->hgt; i++) {
|
||||
snprintf (out, sizeof(out), "%c%c%c", 17, 0, i);
|
||||
write (fd, out, 3);
|
||||
write (fd, dat + (CFontz->wid * i), CFontz->wid);
|
||||
}
|
||||
/*
|
||||
snprintf(out, sizeof(out), "%c", 1);
|
||||
write(fd, out, 1);
|
||||
write(fd, dat, CFontz->wid*CFontz->hgt);
|
||||
*/
|
||||
|
||||
CFontz_set_char (drvthis, dest, &icons[which][0]);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clears the LCD screen
|
||||
//
|
||||
void
|
||||
CFontz_clear ()
|
||||
MODULE_EXPORT void
|
||||
CFontz_clear (Driver * drvthis)
|
||||
{
|
||||
memset (CFontz->framebuf, ' ', CFontz->wid * CFontz->hgt);
|
||||
memset (framebuf, ' ', width * height);
|
||||
|
||||
}
|
||||
|
||||
@@ -717,8 +724,8 @@ CFontz_clear ()
|
||||
// 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).
|
||||
//
|
||||
void
|
||||
CFontz_string (int x, int y, char string[])
|
||||
MODULE_EXPORT void
|
||||
CFontz_string (Driver * drvthis, int x, int y, char string[])
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -727,7 +734,7 @@ CFontz_string (int x, int y, char string[])
|
||||
|
||||
for (i = 0; string[i]; i++) {
|
||||
|
||||
|
||||
|
||||
// For V2 of the firmware to get the block to display right
|
||||
if (newfirmware && string[i]==-1) {
|
||||
string[i]=214;
|
||||
@@ -735,17 +742,17 @@ CFontz_string (int x, int y, char string[])
|
||||
|
||||
|
||||
// Check for buffer overflows...
|
||||
if ((y * CFontz->wid) + x + i > (CFontz->wid * CFontz->hgt))
|
||||
if ((y * width) + x + i > (width * height))
|
||||
break;
|
||||
CFontz->framebuf[(y * CFontz->wid) + x + i] = string[i];
|
||||
framebuf[(y * width) + x + i] = string[i];
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Does the heartbeat...
|
||||
//
|
||||
static void
|
||||
CFontz_heartbeat (int type)
|
||||
MODULE_EXPORT void
|
||||
CFontz_heartbeat (Driver *drvthis, int type)
|
||||
{
|
||||
static int timer = 0;
|
||||
int whichIcon;
|
||||
@@ -760,13 +767,13 @@ CFontz_heartbeat (int type)
|
||||
|
||||
// This defines a custom character EVERY time...
|
||||
// not efficient... is this necessary?
|
||||
CFontz_icon (whichIcon, 0);
|
||||
CFontz_icon (drvthis, whichIcon, 0);
|
||||
|
||||
// Put character on screen...
|
||||
CFontz_chr (CFontz->wid, 1, 0);
|
||||
CFontz_chr (drvthis, width, 1, 0);
|
||||
|
||||
// change display...
|
||||
CFontz_flush ();
|
||||
CFontz_flush (drvthis);
|
||||
}
|
||||
|
||||
timer++;
|
||||
|
||||
+27
-21
@@ -1,34 +1,40 @@
|
||||
#ifndef CFONTZ_H
|
||||
#define CFONTZ_H
|
||||
|
||||
extern lcd_logical_driver *CFontz;
|
||||
|
||||
int CFontz_init (lcd_logical_driver * driver, char *device);
|
||||
void CFontz_close ();
|
||||
void CFontz_flush ();
|
||||
void CFontz_flush_box (int lft, int top, int rgt, int bot);
|
||||
void CFontz_chr (int x, int y, char c);
|
||||
int CFontz_contrast (int contrast);
|
||||
void CFontz_backlight (int on);
|
||||
void CFontz_init_vbar ();
|
||||
void CFontz_init_hbar ();
|
||||
void CFontz_vbar (int x, int len);
|
||||
void CFontz_hbar (int x, int y, int len);
|
||||
void CFontz_init_num ();
|
||||
void CFontz_num (int x, int num);
|
||||
void CFontz_set_char (int n, char *dat);
|
||||
void CFontz_icon (int which, char dest);
|
||||
void CFontz_draw_frame (char *dat);
|
||||
void CFontz_clear (void);
|
||||
void CFontz_string (int x, int y, char string[]);
|
||||
#include "lcd.h"
|
||||
|
||||
#define DEFAULT_CELL_WIDTH 6
|
||||
#define DEFAULT_CELL_HEIGHT 8
|
||||
#define DEFAULT_CONTRAST 140
|
||||
#define DEFAULT_CONTRAST 560
|
||||
#define DEFAULT_DEVICE "/dev/lcd"
|
||||
#define DEFAULT_SPEED B9600
|
||||
#define DEFAULT_BRIGHTNESS 60
|
||||
#define DEFAULT_OFFBRIGHTNESS 0
|
||||
#define DEFAULT_SIZE "20x4"
|
||||
|
||||
|
||||
int CFontz_init (Driver * drvthis, char *device);
|
||||
MODULE_EXPORT void CFontz_close (Driver * drvthis);
|
||||
MODULE_EXPORT int CFontz_width (Driver * drvthis);
|
||||
MODULE_EXPORT int CFontz_height (Driver * drvthis);
|
||||
MODULE_EXPORT void CFontz_clear (Driver * drvthis);
|
||||
MODULE_EXPORT void CFontz_flush (Driver * drvthis);
|
||||
MODULE_EXPORT void CFontz_string (Driver * drvthis, int x, int y, char string[]);
|
||||
MODULE_EXPORT void CFontz_chr (Driver * drvthis, int x, int y, char c);
|
||||
|
||||
MODULE_EXPORT void CFontz_vbar (Driver * drvthis, int x, int len);
|
||||
MODULE_EXPORT void CFontz_hbar (Driver * drvthis, int x, int y, int len);
|
||||
MODULE_EXPORT void CFontz_num (Driver * drvthis, int x, int num);
|
||||
MODULE_EXPORT void CFontz_heartbeat (Driver *drvthis, int type);
|
||||
MODULE_EXPORT void CFontz_icon (Driver * drvthis, int which, char dest);
|
||||
|
||||
MODULE_EXPORT void CFontz_set_char (Driver * drvthis, int n, char *dat);
|
||||
|
||||
MODULE_EXPORT int CFontz_get_contrast (Driver * drvthis);
|
||||
MODULE_EXPORT void CFontz_set_contrast (Driver * drvthis, int contrast);
|
||||
MODULE_EXPORT void CFontz_backlight (Driver * drvthis, int on);
|
||||
|
||||
MODULE_EXPORT void CFontz_init_vbar (Driver * drvthis);
|
||||
MODULE_EXPORT void CFontz_init_hbar (Driver * drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
+300
-298
File diff suppressed because it is too large
Load Diff
+40
-28
@@ -1,41 +1,53 @@
|
||||
#ifndef MTXORB_H
|
||||
#define MTXORB_H
|
||||
|
||||
extern lcd_logical_driver *MtxOrb;
|
||||
#include "lcd.h"
|
||||
|
||||
int MtxOrb_init (lcd_logical_driver * driver, char *device);
|
||||
/*
|
||||
* Just like in hd44780 those function are assing by _init ...
|
||||
static void MtxOrb_clear ();
|
||||
static void MtxOrb_close ();
|
||||
static void MtxOrb_flush ();
|
||||
static void MtxOrb_flush_box (int lft, int top, int rgt, int bot);
|
||||
static void MtxOrb_chr (int x, int y, char c);
|
||||
static int MtxOrb_contrast (int contrast);
|
||||
static void MtxOrb_backlight (int on);
|
||||
static void MtxOrb_output (int on);
|
||||
static void MtxOrb_init_vbar ();
|
||||
static void MtxOrb_init_hbar ();
|
||||
static void MtxOrb_vbar (int x, int len);
|
||||
static void MtxOrb_hbar (int x, int y, int len);
|
||||
static void MtxOrb_init_num ();
|
||||
static void MtxOrb_num (int x, int num);
|
||||
static void MtxOrb_set_char (int n, char *dat);
|
||||
static void MtxOrb_icon (int which, char dest);
|
||||
static void MtxOrb_draw_frame (char *dat);
|
||||
static char MtxOrb_getkey ();
|
||||
static char * MtxOrb_getinfo ();
|
||||
static void MtxOrb_heartbeat (int type);
|
||||
int MtxOrb_init (Driver *drvthis, char *device);
|
||||
MODULE_EXPORT void MtxOrb_close (Driver *drvthis);
|
||||
MODULE_EXPORT int MtxOrb_width (Driver *drvthis);
|
||||
MODULE_EXPORT int MtxOrb_height (Driver *drvthis);
|
||||
MODULE_EXPORT void MtxOrb_clear (Driver *drvthis);
|
||||
MODULE_EXPORT void MtxOrb_flush (Driver *drvthis);
|
||||
MODULE_EXPORT void MtxOrb_string (Driver *drvthis, int x, int y, char *string);
|
||||
MODULE_EXPORT void MtxOrb_chr (Driver *drvthis, int x, int y, char c);
|
||||
|
||||
static int MtxOrb_ask_bar (int type);
|
||||
static void MtxOrb_set_known_char (int car, int type);
|
||||
*/
|
||||
MODULE_EXPORT void MtxOrb_vbar (Driver *drvthis, int x, int len);
|
||||
MODULE_EXPORT void MtxOrb_hbar (Driver *drvthis, int x, int y, int len);
|
||||
MODULE_EXPORT void MtxOrb_num (Driver *drvthis, int x, int num);
|
||||
MODULE_EXPORT void MtxOrb_icon (Driver *drvthis, int which, char dest);
|
||||
MODULE_EXPORT void MtxOrb_heartbeat (Driver *drvthis, int type);
|
||||
|
||||
#define DEFAULT_CONTRAST 120
|
||||
MODULE_EXPORT void MtxOrb_set_char (Driver *drvthis, int n, char *dat);
|
||||
|
||||
MODULE_EXPORT int MtxOrb_get_contrast (Driver *drvthis);
|
||||
MODULE_EXPORT void MtxOrb_set_contrast (Driver *drvthis, int promille);
|
||||
MODULE_EXPORT void MtxOrb_backlight (Driver *drvthis, int on);
|
||||
MODULE_EXPORT void MtxOrb_output (Driver *drvthis, int on);
|
||||
|
||||
MODULE_EXPORT char MtxOrb_getkey (Driver *drvthis);
|
||||
MODULE_EXPORT char * MtxOrb_get_info (Driver *drvthis);
|
||||
|
||||
MODULE_EXPORT void MtxOrb_init_vbar (Driver *drvthis);
|
||||
MODULE_EXPORT void MtxOrb_init_hbar (Driver *drvthis);
|
||||
MODULE_EXPORT void MtxOrb_init_num (Driver *drvthis);
|
||||
|
||||
#define DEFAULT_CONTRAST 480
|
||||
#define DEFAULT_DEVICE "/dev/lcd"
|
||||
#define DEFAULT_SPEED B19200
|
||||
#define DEFAULT_LINEWRAP 1
|
||||
#define DEFAULT_AUTOSCROLL 1
|
||||
#define DEFAULT_CURSORBLINK 0
|
||||
|
||||
/* These are the keys for a (possibly) broken LK202-25...*/
|
||||
#define KEY_UP 'I'
|
||||
#define KEY_DOWN 'F'
|
||||
#define KEY_LEFT 'K'
|
||||
#define KEY_RIGHT 'A'
|
||||
#define KEY_F1 'N'
|
||||
/* TODO: add more if you've got any more ;) or correct the settings
|
||||
* the actual translation is done in MtxOrb_getkey()
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+196
-182
@@ -30,24 +30,27 @@
|
||||
#endif
|
||||
#include "lcd.h"
|
||||
#include "bayrad.h"
|
||||
#include "drv_base.h"
|
||||
//#include "drv_base.h"
|
||||
#include "shared/str.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// Base "class" to derive from ///////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
lcd_logical_driver *bayrad;
|
||||
static int fd;
|
||||
|
||||
static int width = 0;
|
||||
static int height = 0;
|
||||
static int cellwidth = 5;
|
||||
static int cellheight = 8;
|
||||
static char *framebuf = NULL;
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
/* Declare a bunch of global, static custom character data */
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
char bar_up[7][5*8] = {
|
||||
char bar_up[7][5*8] = {
|
||||
{
|
||||
0,0,0,0,0, // char u1[] =
|
||||
0,0,0,0,0, // char u1[] =
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
@@ -57,7 +60,7 @@ char bar_up[7][5*8] = {
|
||||
1,1,1,1,1,
|
||||
},
|
||||
{
|
||||
0,0,0,0,0, // char u2[] =
|
||||
0,0,0,0,0, // char u2[] =
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
@@ -66,7 +69,7 @@ char bar_up[7][5*8] = {
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
},{
|
||||
0,0,0,0,0, // char u3[] =
|
||||
0,0,0,0,0, // char u3[] =
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
@@ -75,7 +78,7 @@ char bar_up[7][5*8] = {
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
},{
|
||||
0,0,0,0,0, // char u4[] =
|
||||
0,0,0,0,0, // char u4[] =
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
@@ -84,7 +87,7 @@ char bar_up[7][5*8] = {
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
},{
|
||||
0,0,0,0,0, // char u5[] =
|
||||
0,0,0,0,0, // char u5[] =
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
1,1,1,1,1,
|
||||
@@ -93,7 +96,7 @@ char bar_up[7][5*8] = {
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
},{
|
||||
0,0,0,0,0, // char u6[] =
|
||||
0,0,0,0,0, // char u6[] =
|
||||
0,0,0,0,0,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
@@ -102,7 +105,7 @@ char bar_up[7][5*8] = {
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
},{
|
||||
0,0,0,0,0, // char u7[] =
|
||||
0,0,0,0,0, // char u7[] =
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
@@ -115,7 +118,7 @@ char bar_up[7][5*8] = {
|
||||
|
||||
char bar_down[7][5*8] = { /* Presently, this is not used */
|
||||
{
|
||||
1,1,1,1,1, // char d1[] =
|
||||
1,1,1,1,1, // char d1[] =
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
@@ -124,7 +127,7 @@ char bar_down[7][5*8] = { /* Presently, this is not used */
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
},{
|
||||
1,1,1,1,1, // char d2[] =
|
||||
1,1,1,1,1, // char d2[] =
|
||||
1,1,1,1,1,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
@@ -133,7 +136,7 @@ char bar_down[7][5*8] = { /* Presently, this is not used */
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
},{
|
||||
1,1,1,1,1, // char d3[] =
|
||||
1,1,1,1,1, // char d3[] =
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
0,0,0,0,0,
|
||||
@@ -142,7 +145,7 @@ char bar_down[7][5*8] = { /* Presently, this is not used */
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
},{
|
||||
1,1,1,1,1, // char d4[] =
|
||||
1,1,1,1,1, // char d4[] =
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
@@ -151,7 +154,7 @@ char bar_down[7][5*8] = { /* Presently, this is not used */
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
},{
|
||||
1,1,1,1,1, // char d5[] =
|
||||
1,1,1,1,1, // char d5[] =
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
@@ -160,7 +163,7 @@ char bar_down[7][5*8] = { /* Presently, this is not used */
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
},{
|
||||
1,1,1,1,1, // char d6[] =
|
||||
1,1,1,1,1, // char d6[] =
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
@@ -169,7 +172,7 @@ char bar_down[7][5*8] = { /* Presently, this is not used */
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
},{
|
||||
1,1,1,1,1, // char d7[] =
|
||||
1,1,1,1,1, // char d7[] =
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
@@ -181,7 +184,7 @@ char bar_down[7][5*8] = { /* Presently, this is not used */
|
||||
|
||||
char bar_right[4][5*8] = {
|
||||
{
|
||||
1,0,0,0,0, // char r1[] =
|
||||
1,0,0,0,0, // char r1[] =
|
||||
1,0,0,0,0,
|
||||
1,0,0,0,0,
|
||||
1,0,0,0,0,
|
||||
@@ -190,7 +193,7 @@ char bar_right[4][5*8] = {
|
||||
1,0,0,0,0,
|
||||
1,0,0,0,0,
|
||||
},{
|
||||
1,1,0,0,0, // char r2[] =
|
||||
1,1,0,0,0, // char r2[] =
|
||||
1,1,0,0,0,
|
||||
1,1,0,0,0,
|
||||
1,1,0,0,0,
|
||||
@@ -199,7 +202,7 @@ char bar_right[4][5*8] = {
|
||||
1,1,0,0,0,
|
||||
1,1,0,0,0,
|
||||
},{
|
||||
1,1,1,0,0, // char r3[] =
|
||||
1,1,1,0,0, // char r3[] =
|
||||
1,1,1,0,0,
|
||||
1,1,1,0,0,
|
||||
1,1,1,0,0,
|
||||
@@ -208,7 +211,7 @@ char bar_right[4][5*8] = {
|
||||
1,1,1,0,0,
|
||||
1,1,1,0,0,
|
||||
},{
|
||||
1,1,1,1,0, // char r4[] =
|
||||
1,1,1,1,0, // char r4[] =
|
||||
1,1,1,1,0,
|
||||
1,1,1,1,0,
|
||||
1,1,1,1,0,
|
||||
@@ -220,7 +223,7 @@ char bar_right[4][5*8] = {
|
||||
|
||||
char bar_left[4][5*8] = { /* Presently, this is not used. */
|
||||
{
|
||||
0,0,0,0,1, // char l1[] =
|
||||
0,0,0,0,1, // char l1[] =
|
||||
0,0,0,0,1,
|
||||
0,0,0,0,1,
|
||||
0,0,0,0,1,
|
||||
@@ -229,7 +232,7 @@ char bar_left[4][5*8] = { /* Presently, this is not used. */
|
||||
0,0,0,0,1,
|
||||
0,0,0,0,1,
|
||||
},{
|
||||
0,0,0,1,1, // char l2[] =
|
||||
0,0,0,1,1, // char l2[] =
|
||||
0,0,0,1,1,
|
||||
0,0,0,1,1,
|
||||
0,0,0,1,1,
|
||||
@@ -238,7 +241,7 @@ char bar_left[4][5*8] = { /* Presently, this is not used. */
|
||||
0,0,0,1,1,
|
||||
0,0,0,1,1,
|
||||
},{
|
||||
0,0,1,1,1, // char l3[] =
|
||||
0,0,1,1,1, // char l3[] =
|
||||
0,0,1,1,1,
|
||||
0,0,1,1,1,
|
||||
0,0,1,1,1,
|
||||
@@ -247,7 +250,7 @@ char bar_left[4][5*8] = { /* Presently, this is not used. */
|
||||
0,0,1,1,1,
|
||||
0,0,1,1,1,
|
||||
},{
|
||||
0,1,1,1,1, // char l4[] =
|
||||
0,1,1,1,1, // char l4[] =
|
||||
0,1,1,1,1,
|
||||
0,1,1,1,1,
|
||||
0,1,1,1,1,
|
||||
@@ -268,7 +271,7 @@ char icons[3][5*8] = {
|
||||
1,0,0,0,1,
|
||||
1,1,0,1,1,
|
||||
1,1,1,1,1,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
1,1,1,1,1, // Filled Heart
|
||||
@@ -280,7 +283,7 @@ char icons[3][5*8] = {
|
||||
1,1,0,1,1,
|
||||
1,1,1,1,1,
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
0,0,0,0,0, // Ellipsis
|
||||
0,0,0,0,0,
|
||||
@@ -291,19 +294,25 @@ char icons[3][5*8] = {
|
||||
0,0,0,0,0,
|
||||
1,0,1,0,1,
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
// 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 = "bayrad_";
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// init() should set up any device-specific stuff, and
|
||||
// point all the function pointers.
|
||||
int bayrad_init(struct lcd_logical_driver *driver, char *args)
|
||||
int
|
||||
bayrad_init(Driver *drvthis, char *args)
|
||||
{
|
||||
|
||||
char device[256];
|
||||
char device[256];
|
||||
int speed=B9600;
|
||||
char *argv[64];
|
||||
int argc;
|
||||
@@ -312,31 +321,28 @@ int bayrad_init(struct lcd_logical_driver *driver, char *args)
|
||||
int tmp;
|
||||
|
||||
//printf("bayrad_init()\n");
|
||||
bayrad = driver;
|
||||
strcpy(device, "/dev/lcd");
|
||||
driver->wid = 20;
|
||||
driver->hgt = 2;
|
||||
width = 20;
|
||||
height = 2;
|
||||
|
||||
// You must use driver->framebuf here, but may use lcd.framebuf later.
|
||||
if(!driver->framebuf)
|
||||
driver->framebuf = malloc(driver->wid * driver->hgt);
|
||||
framebuf = malloc(width * height);
|
||||
|
||||
if(!driver->framebuf)
|
||||
if(!framebuf)
|
||||
{
|
||||
bayrad_close();
|
||||
bayrad_close(drvthis);
|
||||
fprintf(stderr, "\nError: unable to create BayRAD framebuffer.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(driver->framebuf, ' ', driver->wid*driver->hgt);
|
||||
memset(framebuf, ' ', width * height);
|
||||
|
||||
driver->cellwid = 5;
|
||||
driver->cellhgt = 8;
|
||||
//cellheight = 5;
|
||||
//cellwidth = 8;
|
||||
|
||||
/*-----------------------------------------------------*/
|
||||
|
||||
//fprintf(stderr, "bayrad_init: Args(all): %s\n", args);
|
||||
|
||||
|
||||
argc = get_args(argv, args, 64);
|
||||
|
||||
/*
|
||||
@@ -345,7 +351,7 @@ int bayrad_init(struct lcd_logical_driver *driver, char *args)
|
||||
printf("Arg(%i): %s\n", i, argv[i]);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
for(i=0; i<argc; i++)
|
||||
{
|
||||
//printf("Arg(%i): %s\n", i, argv[i]);
|
||||
@@ -360,21 +366,21 @@ int bayrad_init(struct lcd_logical_driver *driver, char *args)
|
||||
}
|
||||
else if(0 == strcmp(argv[i], "-s") || 0 == strcmp(argv[i], "--speed"))
|
||||
{
|
||||
if(i + 1 > argc)
|
||||
if(i + 1 > argc)
|
||||
{
|
||||
fprintf(stderr, "bayrad_init: %s requires an argument\n", argv[i]);
|
||||
return -1;
|
||||
}
|
||||
tmp = atoi(argv[++i]);
|
||||
if(tmp==1200)
|
||||
if(tmp==1200)
|
||||
speed=B1200;
|
||||
else if(tmp==2400)
|
||||
else if(tmp==2400)
|
||||
speed=B2400;
|
||||
else if(tmp==9600)
|
||||
else if(tmp==9600)
|
||||
speed=B9600;
|
||||
else if(tmp==19200)
|
||||
else if(tmp==19200)
|
||||
speed=B19200;
|
||||
else
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "bayrad_init: %s argument must be 1200, 2400, 9600 or 19200. Using default value.\n",
|
||||
argv[i]);
|
||||
@@ -393,12 +399,12 @@ int bayrad_init(struct lcd_logical_driver *driver, char *args)
|
||||
{
|
||||
printf("Invalid parameter: %s\n", argv[i]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Set up io port correctly, and open it...
|
||||
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
if (fd == -1)
|
||||
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
if (fd == -1)
|
||||
{
|
||||
fprintf(stderr, "bayrad_init: failed (%s)\n", strerror(errno));
|
||||
return -1;
|
||||
@@ -442,71 +448,96 @@ int bayrad_init(struct lcd_logical_driver *driver, char *args)
|
||||
write(fd, "\x80\x86\x00\x1a\x1e", 5); // sync,reset to type 0, clear screen, home
|
||||
|
||||
|
||||
driver->clear = bayrad_clear;
|
||||
driver->string = bayrad_string;
|
||||
driver->chr = bayrad_chr;
|
||||
driver->vbar = bayrad_vbar;
|
||||
driver->init_vbar = bayrad_init_vbar;
|
||||
driver->hbar = bayrad_hbar;
|
||||
driver->init_hbar = bayrad_init_hbar;
|
||||
//driver->num = NULL; //bayrad_num;
|
||||
//driver->init_num = NULL; //bayrad_init_num;
|
||||
driver->init = bayrad_init;
|
||||
driver->close = bayrad_close;
|
||||
driver->flush = bayrad_flush;
|
||||
driver->flush_box = bayrad_flush_box;
|
||||
//driver->contrast = NULL;
|
||||
driver->backlight = bayrad_backlight;
|
||||
driver->set_char = bayrad_set_char;
|
||||
driver->icon = bayrad_icon;
|
||||
driver->draw_frame = bayrad_draw_frame;
|
||||
// Set variables for server
|
||||
drvthis->api_version = api_version;
|
||||
drvthis->stay_in_foreground = &stay_in_foreground;
|
||||
drvthis->supports_multiple = &supports_multiple;
|
||||
|
||||
driver->getkey = bayrad_getkey;
|
||||
|
||||
|
||||
return fd;
|
||||
// Set the functions the driver supports
|
||||
drvthis->clear = bayrad_clear;
|
||||
drvthis->string = bayrad_string;
|
||||
drvthis->chr = bayrad_chr;
|
||||
drvthis->old_vbar = bayrad_vbar;
|
||||
drvthis->init_vbar = bayrad_init_vbar;
|
||||
drvthis->old_hbar = bayrad_hbar;
|
||||
drvthis->init_hbar = bayrad_init_hbar;
|
||||
//drvthis->num = NULL; //bayrad_num;
|
||||
//drvthis->init_num = NULL; //bayrad_init_num;
|
||||
drvthis->init = bayrad_init;
|
||||
drvthis->close = bayrad_close;
|
||||
drvthis->flush = bayrad_flush;
|
||||
drvthis->backlight = bayrad_backlight;
|
||||
drvthis->set_char = bayrad_set_char;
|
||||
drvthis->old_icon = bayrad_icon;
|
||||
|
||||
drvthis->getkey = bayrad_getkey;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Below here, you may use either lcd.framebuf or driver->framebuf..
|
||||
// Below here, you may use either lcd.framebuf or drvthis->framebuf..
|
||||
// lcd.framebuf will be set to the appropriate buffer before calling
|
||||
// your driver.
|
||||
|
||||
void bayrad_close()
|
||||
MODULE_EXPORT void
|
||||
bayrad_close(Driver * drvthis)
|
||||
{
|
||||
if(bayrad->framebuf != NULL)
|
||||
free(bayrad->framebuf);
|
||||
|
||||
bayrad->framebuf = NULL;
|
||||
//fprintf(stderr, "\nClosing BayRAD.\n");
|
||||
write(fd, "\x8e\x00", 2); // Backlight OFF
|
||||
|
||||
//fprintf(stderr, "\nClosing BayRAD.\n");
|
||||
if(framebuf) free(framebuf);
|
||||
framebuf = NULL;
|
||||
|
||||
close(fd);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display width
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
bayrad_width(Driver * drvthis)
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display height
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
bayrad_height(Driver * drvthis)
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clears the LCD screen
|
||||
//
|
||||
void bayrad_clear()
|
||||
MODULE_EXPORT void
|
||||
bayrad_clear(Driver * drvthis)
|
||||
{
|
||||
memset(bayrad->framebuf, ' ', bayrad->wid*bayrad->hgt);
|
||||
|
||||
memset(framebuf, ' ', width * height);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Flushes all output to the lcd...
|
||||
//
|
||||
void bayrad_flush()
|
||||
MODULE_EXPORT void
|
||||
bayrad_flush(Driver * drvthis)
|
||||
{
|
||||
|
||||
//fprintf(stderr, "\nBayRAD flush");
|
||||
//fprintf(stderr, "\nBayRAD flush");
|
||||
|
||||
write(fd, "\x80\x1e", 2); //sync, home
|
||||
write(fd, bayrad->framebuf, 20);
|
||||
write(fd, framebuf, 20);
|
||||
write(fd, "\x1e\x0a", 2); //home, LF
|
||||
write(fd, bayrad->framebuf+20, 20);
|
||||
write(fd, framebuf+20, 20);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -515,7 +546,8 @@ void bayrad_flush()
|
||||
// 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).
|
||||
//
|
||||
void bayrad_string(int x, int y, char string[])
|
||||
MODULE_EXPORT void
|
||||
bayrad_string(Driver * drvthis, int x, int y, char string[])
|
||||
{
|
||||
int i;
|
||||
unsigned char c;
|
||||
@@ -524,11 +556,11 @@ void bayrad_string(int x, int y, char string[])
|
||||
|
||||
x -= 1; // Convert 1-based coords to 0-based...
|
||||
y -= 1;
|
||||
|
||||
|
||||
for(i=0; string[i]; i++)
|
||||
{
|
||||
// Check for buffer overflows...
|
||||
if((y*bayrad->wid) + x + i > (bayrad->wid*bayrad->hgt))
|
||||
if((y*width) + x + i > (width*height))
|
||||
break;
|
||||
|
||||
c = (unsigned char) string[i];
|
||||
@@ -538,14 +570,14 @@ void bayrad_string(int x, int y, char string[])
|
||||
//c &= 0x7F;
|
||||
fprintf(stderr, "\nIllegal char %#x requested in bayrad_string()!\n", c);
|
||||
c = ' ';
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(c < 8) /* The custom characters are mapped at 0x98 - 0x9F, */
|
||||
c += 0x98; /* as 0x07 makes a beep instead of printing a character */
|
||||
|
||||
|
||||
bayrad->framebuf[(y*bayrad->wid) + x + i] = c;
|
||||
framebuf[(y*width) + x + i] = c;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -553,8 +585,9 @@ void bayrad_string(int x, int y, char 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,2).
|
||||
//
|
||||
void bayrad_chr(int x, int y, char c)
|
||||
{
|
||||
MODULE_EXPORT void
|
||||
bayrad_chr(Driver * drvthis, int x, int y, char c)
|
||||
{
|
||||
unsigned char ch;
|
||||
|
||||
//fprintf(stderr, "\nPutting char %c (%#x) at %i, %i", c, c, x, y);
|
||||
@@ -571,13 +604,14 @@ void bayrad_chr(int x, int y, char c)
|
||||
|
||||
/* No shifting the custom chars here, so bayrad_chr() can beep */
|
||||
|
||||
bayrad->framebuf[(y*bayrad->wid) + x] = ch;
|
||||
framebuf[(y*width) + x] = ch;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Turns the lcd backlight on or off...
|
||||
//
|
||||
void bayrad_backlight(int on)
|
||||
MODULE_EXPORT void
|
||||
bayrad_backlight(Driver * drvthis, int on)
|
||||
{
|
||||
|
||||
/* This violates the LCDd driver model, but it does leave the
|
||||
@@ -601,18 +635,19 @@ void bayrad_backlight(int on)
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Tells the driver to get ready for vertical bargraphs.
|
||||
//
|
||||
void bayrad_init_vbar()
|
||||
MODULE_EXPORT void
|
||||
bayrad_init_vbar(Driver * drvthis)
|
||||
{
|
||||
//printf("Init Vertical bars.\n");
|
||||
|
||||
bayrad_set_char(1, bar_up[0]);
|
||||
bayrad_set_char(2, bar_up[1]);
|
||||
bayrad_set_char(3, bar_up[2]);
|
||||
bayrad_set_char(4, bar_up[3]);
|
||||
bayrad_set_char(5, bar_up[4]);
|
||||
bayrad_set_char(6, bar_up[5]);
|
||||
bayrad_set_char(7, bar_up[6]);
|
||||
|
||||
bayrad_set_char(drvthis, 1, bar_up[0]);
|
||||
bayrad_set_char(drvthis, 2, bar_up[1]);
|
||||
bayrad_set_char(drvthis, 3, bar_up[2]);
|
||||
bayrad_set_char(drvthis, 4, bar_up[3]);
|
||||
bayrad_set_char(drvthis, 5, bar_up[4]);
|
||||
bayrad_set_char(drvthis, 6, bar_up[5]);
|
||||
bayrad_set_char(drvthis, 7, bar_up[6]);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -620,14 +655,15 @@ void bayrad_init_vbar()
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Tells the driver to get ready for horizontal bargraphs.
|
||||
//
|
||||
void bayrad_init_hbar()
|
||||
MODULE_EXPORT void
|
||||
bayrad_init_hbar(Driver * drvthis)
|
||||
{
|
||||
//printf("Init Horizontal bars.\n");
|
||||
//printf("Init Horizontal bars.\n");
|
||||
|
||||
bayrad_set_char(1, bar_right[0]);
|
||||
bayrad_set_char(2, bar_right[1]);
|
||||
bayrad_set_char(3, bar_right[2]);
|
||||
bayrad_set_char(4, bar_right[3]);
|
||||
bayrad_set_char(drvthis, 1, bar_right[0]);
|
||||
bayrad_set_char(drvthis, 2, bar_right[1]);
|
||||
bayrad_set_char(drvthis, 3, bar_right[2]);
|
||||
bayrad_set_char(drvthis, 4, bar_right[3]);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -635,7 +671,8 @@ return;
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Tells the driver to get ready for big numbers, if possible.
|
||||
//
|
||||
void bayrad_init_num()
|
||||
MODULE_EXPORT void
|
||||
bayrad_init_num(Driver * drvthis)
|
||||
{
|
||||
// printf("Big Numbers.\n");
|
||||
}
|
||||
@@ -643,7 +680,8 @@ void bayrad_init_num()
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Draws a big (4-row) number.
|
||||
//
|
||||
void bayrad_num(int x, int num)
|
||||
MODULE_EXPORT void
|
||||
bayrad_num(Driver * drvthis, int x, int num)
|
||||
{
|
||||
// printf("BigNum(%i, %i)\n", x, num);
|
||||
}
|
||||
@@ -651,7 +689,8 @@ void bayrad_num(int x, int num)
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Changes the font data of character n.
|
||||
//
|
||||
void bayrad_set_char(int n, char *dat)
|
||||
MODULE_EXPORT void
|
||||
bayrad_set_char(Driver * drvthis, int n, char *dat)
|
||||
{
|
||||
char out[4];
|
||||
int row, col;
|
||||
@@ -663,7 +702,7 @@ void bayrad_set_char(int n, char *dat)
|
||||
return;
|
||||
|
||||
|
||||
if(!dat)
|
||||
if(!dat)
|
||||
return;
|
||||
|
||||
n = 0x40 + (n * 8); /* Set n to the proper location in CG RAM */
|
||||
@@ -671,14 +710,14 @@ void bayrad_set_char(int n, char *dat)
|
||||
/* Set the LCD to accept data for rewrite-able char n */
|
||||
snprintf(out, sizeof(out), "\x88%c", n);
|
||||
write(fd, out, 2);
|
||||
|
||||
for(row=0; row<bayrad->cellhgt; row++)
|
||||
|
||||
for(row=0; row<cellheight; row++)
|
||||
{
|
||||
letter = 0;
|
||||
for(col=0; col<bayrad->cellwid; col++)
|
||||
for(col=0; col<cellwidth; col++)
|
||||
{
|
||||
letter <<= 1;
|
||||
letter |= (dat[(row*bayrad->cellwid) + col] > 0);
|
||||
letter |= (dat[(row*cellwidth) + col] > 0);
|
||||
}
|
||||
write(fd, &letter, 1);
|
||||
}
|
||||
@@ -692,58 +731,60 @@ return;
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a vertical bar, from the bottom of the screen up.
|
||||
//
|
||||
void bayrad_vbar(int x, int len)
|
||||
MODULE_EXPORT void
|
||||
bayrad_vbar(Driver * drvthis, int x, int len)
|
||||
{
|
||||
int y = 2;
|
||||
|
||||
//fprintf(stderr, "\nVbar at %i, length %i", x, len);
|
||||
|
||||
if(len >= bayrad->cellhgt)
|
||||
if(len >= cellheight)
|
||||
{
|
||||
bayrad_chr(x, y, 0xFF);
|
||||
len -= bayrad->cellhgt;
|
||||
bayrad_chr(drvthis, x, y, 0xFF);
|
||||
len -= cellheight;
|
||||
y = 1;
|
||||
}
|
||||
|
||||
|
||||
if(!len)
|
||||
return;
|
||||
|
||||
if(len > bayrad->cellhgt)
|
||||
|
||||
if(len > cellheight)
|
||||
{
|
||||
bayrad_chr(x, y, '^'); /* Show we've gone off the chart */
|
||||
bayrad_chr(drvthis, x, y, '^'); /* Show we've gone off the chart */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* init_vbar sets custom chars 1 - 7. Height 8 is char 0xFF. */
|
||||
if(len == 8)
|
||||
bayrad_chr(x, y, 0xFF);
|
||||
bayrad_chr(drvthis, x, y, 0xFF);
|
||||
else
|
||||
bayrad_chr(x, y, (len+0x98));
|
||||
|
||||
bayrad_chr(drvthis, x, y, (len+0x98));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
void bayrad_hbar(int x, int y, int len)
|
||||
MODULE_EXPORT void
|
||||
bayrad_hbar(Driver * drvthis, int x, int y, int len)
|
||||
{
|
||||
|
||||
//fprintf(stderr, "\nHbar at %i,%i; length %i", x, y, len);
|
||||
|
||||
while((x <= bayrad->wid) && (len > 0))
|
||||
while((x <= cellwidth) && (len > 0))
|
||||
{
|
||||
if(len < bayrad->cellwid)
|
||||
if(len < cellwidth)
|
||||
{
|
||||
bayrad_chr(x, y, 0x98 + len);
|
||||
bayrad_chr(drvthis, x, y, 0x98 + len);
|
||||
break;
|
||||
}
|
||||
|
||||
bayrad_chr(x, y, 0xFF);
|
||||
len -= bayrad->cellwid;
|
||||
bayrad_chr(drvthis, x, y, 0xFF);
|
||||
len -= cellwidth;
|
||||
x++;
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -751,54 +792,27 @@ void bayrad_hbar(int x, int y, int len)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets character 0 to an icon...
|
||||
//
|
||||
void bayrad_icon(int which, char dest)
|
||||
MODULE_EXPORT void
|
||||
bayrad_icon(Driver * drvthis, int which, char dest)
|
||||
{
|
||||
|
||||
//printf("Char %i set to icon %i\n", dest, which);
|
||||
bayrad_set_char(dest, &icons[which][0]);
|
||||
//printf("Char %i set to icon %i\n", dest, which);
|
||||
bayrad_set_char(drvthis, dest, &icons[which][0]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Send a rectangular area to the display.
|
||||
//
|
||||
// I've just called bayrad_flush() because there's not much point yet
|
||||
// in flushing less than the entire framebuffer.
|
||||
//
|
||||
void bayrad_flush_box(int lft, int top, int rgt, int bot)
|
||||
{
|
||||
bayrad_flush();
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Draws the framebuffer on the display.
|
||||
//
|
||||
|
||||
void bayrad_draw_frame(char *dat)
|
||||
{
|
||||
|
||||
//fprintf(stderr, "\nBayRAD draw frame");
|
||||
|
||||
write(fd, "\x80\x1e", 2); // NOP, home
|
||||
write(fd, bayrad->framebuf, 20);
|
||||
write(fd, "\n", 1);
|
||||
write(fd, bayrad->framebuf+20, 20);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Tries to read a character from an input device...
|
||||
//
|
||||
// Return 0 for "nothing available".
|
||||
//
|
||||
char bayrad_getkey()
|
||||
{
|
||||
MODULE_EXPORT char
|
||||
bayrad_getkey(Driver * drvthis)
|
||||
{
|
||||
fd_set brfdset;
|
||||
struct timeval twait;
|
||||
struct timeval twait;
|
||||
char readchar;
|
||||
int retval;
|
||||
|
||||
@@ -809,7 +823,7 @@ char bayrad_getkey()
|
||||
/* with received keypad characters. */
|
||||
FD_ZERO(&brfdset);
|
||||
FD_SET(fd, &brfdset);
|
||||
|
||||
|
||||
twait.tv_sec = 0;
|
||||
twait.tv_usec = 0;
|
||||
|
||||
@@ -817,9 +831,9 @@ char bayrad_getkey()
|
||||
{
|
||||
retval = read(fd, &readchar, 1);
|
||||
if(retval > 0)
|
||||
{
|
||||
{
|
||||
//fprintf(stderr, "Received char %c", readchar);
|
||||
|
||||
|
||||
if(readchar == 'Y')
|
||||
{
|
||||
write(fd, "\x8e\x0f", 2);
|
||||
@@ -828,7 +842,7 @@ char bayrad_getkey()
|
||||
{
|
||||
write(fd, "\x8e\x00", 2);
|
||||
}
|
||||
|
||||
|
||||
} /* if read returned data */
|
||||
else
|
||||
{ /* Read error */
|
||||
@@ -837,7 +851,7 @@ char bayrad_getkey()
|
||||
} /* if select */
|
||||
else
|
||||
{
|
||||
;//fprintf(stderr, "No BayRAD data present.");
|
||||
;//fprintf(stderr, "No BayRAD data present.");
|
||||
}
|
||||
|
||||
return readchar;
|
||||
|
||||
+22
-18
@@ -8,24 +8,28 @@
|
||||
#ifndef _BAYRAD_H
|
||||
#define _BAYRAD_H
|
||||
|
||||
extern lcd_logical_driver *bayrad;
|
||||
#include "lcd.h"
|
||||
|
||||
int bayrad_init(struct lcd_logical_driver *driver, char *args);
|
||||
void bayrad_close();
|
||||
void bayrad_clear();
|
||||
void bayrad_flush();
|
||||
void bayrad_string(int x, int y, char string[]);
|
||||
void bayrad_chr(int x, int y, char c);
|
||||
int bayrad_contrast(int contrast);
|
||||
void bayrad_backlight(int on);
|
||||
void bayrad_vbar(int x, int len);
|
||||
void bayrad_init_vbar();
|
||||
void bayrad_hbar(int x, int y, int len);
|
||||
void bayrad_init_hbar();
|
||||
void bayrad_set_char(int n, char *dat);
|
||||
void bayrad_icon(int which, char dest);
|
||||
void bayrad_flush_box(int lft, int top, int rgt, int bot);
|
||||
void bayrad_draw_frame(char *dat);
|
||||
char bayrad_getkey();
|
||||
int bayrad_init(Driver * drvthis, char *args);
|
||||
MODULE_EXPORT void bayrad_close(Driver * drvthis);
|
||||
MODULE_EXPORT int bayrad_width(Driver * drvthis);
|
||||
MODULE_EXPORT int bayrad_height(Driver * drvthis);
|
||||
MODULE_EXPORT void bayrad_clear(Driver * drvthis);
|
||||
MODULE_EXPORT void bayrad_flush(Driver * drvthis);
|
||||
MODULE_EXPORT void bayrad_string(Driver * drvthis, int x, int y, char string[]);
|
||||
MODULE_EXPORT void bayrad_chr(Driver * drvthis, int x, int y, char c);
|
||||
|
||||
MODULE_EXPORT void bayrad_vbar(Driver * drvthis, int x, int len);
|
||||
MODULE_EXPORT void bayrad_hbar(Driver * drvthis, int x, int y, int len);
|
||||
MODULE_EXPORT void bayrad_icon(Driver * drvthis, int which, char dest);
|
||||
|
||||
MODULE_EXPORT void bayrad_set_char(Driver * drvthis, int n, char *dat);
|
||||
|
||||
MODULE_EXPORT void bayrad_backlight(Driver * drvthis, int promille);
|
||||
|
||||
MODULE_EXPORT char bayrad_getkey(Driver * drvthis);
|
||||
|
||||
MODULE_EXPORT void bayrad_init_vbar(Driver * drvthis);
|
||||
MODULE_EXPORT void bayrad_init_hbar(Driver * drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
+160
-142
@@ -22,13 +22,13 @@
|
||||
|
||||
/*
|
||||
Different implementations of (n)curses available on:
|
||||
OpenBSD:
|
||||
OpenBSD:
|
||||
http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libcurses/
|
||||
ncurses
|
||||
NetBSD:
|
||||
NetBSD:
|
||||
http://cvsweb.netbsd.org/bsdweb.cgi/basesrc/lib/libcurses/
|
||||
curses : does not define ACS_S3, ACS_S7, wcolor_set() or redrawwin().
|
||||
it is possible to make a:
|
||||
it is possible to make a:
|
||||
#define ACS_S3 (_acs_char['p'])
|
||||
#define ACS_S7 (_acs_char['r'])
|
||||
FreeBSD:
|
||||
@@ -38,7 +38,7 @@ RedHat, Debian, (most distros) Linux:
|
||||
ncurses
|
||||
SunOS (5.5.1):
|
||||
curses : does not define ACS_S3, ACS_S7 or wcolor_set().
|
||||
it is possible to make a:
|
||||
it is possible to make a:
|
||||
#define ACS_S3 (acs_map['p'])
|
||||
#define ACS_S7 (acs_map['r'])
|
||||
*/
|
||||
@@ -63,11 +63,10 @@ SunOS (5.5.1):
|
||||
|
||||
#include "shared/str.h"
|
||||
|
||||
#include "render.h"
|
||||
#include "lcd.h"
|
||||
#include "curses_drv.h"
|
||||
#include "shared/report.h"
|
||||
#include "configfile.h"
|
||||
#include "report.h"
|
||||
//#include "configfile.h"
|
||||
|
||||
// ACS_S9 and ACS_S1 are defined as part of XSI Curses standard, Issue 4.
|
||||
// However, ACS_S3 and ACS_S7 are not; these definitions were created to support
|
||||
@@ -85,7 +84,7 @@ SunOS (5.5.1):
|
||||
# else
|
||||
# define ACS_S3 ACS_S1 // Last resort
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ACS_S7
|
||||
@@ -97,17 +96,16 @@ SunOS (5.5.1):
|
||||
# else
|
||||
# define ACS_S7 ACS_S9 // Last resort
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
lcd_logical_driver *curses_drv;
|
||||
|
||||
// Character used for title bars...
|
||||
#define PAD '#'
|
||||
// #define PAD ACS_BLOCK
|
||||
|
||||
int ELLIPSIS = 7;
|
||||
void curses_drv_restore_screen (void);
|
||||
int ELLIPSIS = 7; // Should this go in PrivateData ?
|
||||
void curses_drv_restore_screen (Driver *drvthis);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// For Curses Terminal Output ////////////////////////
|
||||
@@ -117,7 +115,7 @@ static char icon_char = '@';
|
||||
static WINDOW *lcd_win;
|
||||
|
||||
/*this is really ugly ;) but works ;)*/
|
||||
static char num_icon [10][4][3] = {{{' ','_',' '}, /*0*/
|
||||
static char num_icon [10][4][3] = {{{' ','_',' '}, /*0*/
|
||||
{'|',' ','|'},
|
||||
{'|','_','|'},
|
||||
{' ',' ',' '}},
|
||||
@@ -222,13 +220,22 @@ set_background_color (char * buf) {
|
||||
#define TOP_LEFT_X 7
|
||||
#define TOP_LEFT_Y 7
|
||||
|
||||
int current_color_pair, current_border_pair, curses_backlight_state = 0;
|
||||
static int current_color_pair, current_border_pair, curses_backlight_state = 0;
|
||||
static int width, height;
|
||||
|
||||
|
||||
// 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 = "curses_drv_";
|
||||
|
||||
|
||||
int
|
||||
curses_drv_init (struct lcd_logical_driver *driver, char *args)
|
||||
curses_drv_init (Driver *drvthis, char *args)
|
||||
{
|
||||
char buf[256];
|
||||
int wid=0, hgt=0;
|
||||
int w, h;
|
||||
|
||||
// Colors....
|
||||
chtype back_color = DEFAULT_BACKGROUND_COLOR,
|
||||
@@ -239,26 +246,34 @@ curses_drv_init (struct lcd_logical_driver *driver, char *args)
|
||||
int screen_begx = CONF_DEF_TOP_LEFT_X,
|
||||
screen_begy = CONF_DEF_TOP_LEFT_Y;
|
||||
|
||||
curses_drv = driver;
|
||||
|
||||
// TODO: replace DriverName with driver->name when that field exists.
|
||||
#define DriverName "curses"
|
||||
// Set display sizes
|
||||
if( drvthis->request_display_width() > 0
|
||||
&& drvthis->request_display_height() > 0 ) {
|
||||
// Use size from primary driver
|
||||
width = drvthis->request_display_width();
|
||||
height = drvthis->request_display_height();
|
||||
}
|
||||
else {
|
||||
// Use default size
|
||||
width = LCD_DEFAULT_WIDTH;
|
||||
height = LCD_DEFAULT_HEIGHT;
|
||||
}
|
||||
|
||||
/*Get settings from config file*/
|
||||
|
||||
/*Get color settings*/
|
||||
/*foreground color*/
|
||||
strncpy(buf, config_get_string ( DriverName , "foreground" , 0 , CONF_DEF_FOREGR),sizeof(buf));
|
||||
strncpy(buf, drvthis->config_get_string ( drvthis->name , "foreground" , 0 , CONF_DEF_FOREGR),sizeof(buf));
|
||||
buf[sizeof(buf)-1]=0;
|
||||
fore_color = set_foreground_color(buf);
|
||||
debug( RPT_DEBUG, "CURSES: using foreground color: %s", buf);
|
||||
/*background color*/
|
||||
strncpy(buf, config_get_string ( DriverName , "background" , 0 , CONF_DEF_BACKGR),sizeof(buf));
|
||||
strncpy(buf, drvthis->config_get_string ( drvthis->name , "background" , 0 , CONF_DEF_BACKGR),sizeof(buf));
|
||||
buf[sizeof(buf)-1]=0;
|
||||
back_color = set_background_color(buf);
|
||||
debug( RPT_DEBUG, "CURSES: using background color: %s", buf);
|
||||
/*backlight color*/
|
||||
strncpy(buf, config_get_string ( DriverName , "backlight" , 0 , CONF_DEF_BACKLIGHT), sizeof(buf));
|
||||
strncpy(buf, drvthis->config_get_string ( drvthis->name , "backlight" , 0 , CONF_DEF_BACKLIGHT), sizeof(buf));
|
||||
buf[sizeof(buf)-1]=0;
|
||||
backlight_color = set_background_color(buf);
|
||||
debug( RPT_DEBUG, "CURSES: using backlight color: %s", buf);
|
||||
@@ -267,25 +282,28 @@ curses_drv_init (struct lcd_logical_driver *driver, char *args)
|
||||
// Or maybe don't do so? - Rene Wagner
|
||||
|
||||
/*Get size settings*/
|
||||
strncpy(buf, config_get_string ( DriverName , "size" , 0 , CONF_DEF_SIZE), sizeof(buf));
|
||||
strncpy(buf, drvthis->config_get_string ( drvthis->name , "size" , 0 , CONF_DEF_SIZE), sizeof(buf));
|
||||
buf[sizeof(buf)-1]=0;
|
||||
if( sscanf(buf , "%dx%d", &wid, &hgt ) != 2
|
||||
|| (wid <= 0)
|
||||
|| (hgt <= 0)) {
|
||||
report (RPT_WARNING, "CURSES: Cannot read size: %s. Using default value %s.\n", buf, CONF_DEF_SIZE);
|
||||
sscanf( CONF_DEF_SIZE , "%dx%d", &wid, &hgt );
|
||||
if( sscanf(buf , "%dx%d", &w, &h ) != 2
|
||||
|| (w <= 0)
|
||||
|| (h <= 0)) {
|
||||
report (RPT_WARNING, "CURSES: Cannot read size: %s. Using default value.\n", buf);
|
||||
//sscanf( CONF_DEF_SIZE , "%dx%d", &width, &height );
|
||||
// default value is already set
|
||||
}
|
||||
else {
|
||||
width = w;
|
||||
height = h;
|
||||
}
|
||||
driver->wid = wid;
|
||||
driver->hgt = hgt;
|
||||
|
||||
/*Get position settings*/
|
||||
if (0<=config_get_int ( DriverName , "topleftx" , 0 , CONF_DEF_TOP_LEFT_X) && config_get_int ( DriverName , "topleftx" , 0 , CONF_DEF_TOP_LEFT_X) <= 255) {
|
||||
screen_begx = config_get_int ( DriverName , "topleftx" , 0 , CONF_DEF_TOP_LEFT_X);
|
||||
if (0<=drvthis->config_get_int ( drvthis->name , "topleftx" , 0 , CONF_DEF_TOP_LEFT_X) && drvthis->config_get_int ( drvthis->name , "topleftx" , 0 , CONF_DEF_TOP_LEFT_X) <= 255) {
|
||||
screen_begx = drvthis->config_get_int ( drvthis->name , "topleftx" , 0 , CONF_DEF_TOP_LEFT_X);
|
||||
} else {
|
||||
report (RPT_WARNING, "CURSES: topleftx must between 0 and 255. Using default value %d.\n",CONF_DEF_TOP_LEFT_X);
|
||||
}
|
||||
if (0<=config_get_int ( DriverName , "toplefty" , 0 , CONF_DEF_TOP_LEFT_Y) && config_get_int ( DriverName , "toplefty" , 0 , CONF_DEF_TOP_LEFT_Y) <= 255) {
|
||||
screen_begy = config_get_int ( DriverName , "toplefty" , 0 , CONF_DEF_TOP_LEFT_Y);
|
||||
if (0<=drvthis->config_get_int ( drvthis->name , "toplefty" , 0 , CONF_DEF_TOP_LEFT_Y) && drvthis->config_get_int ( drvthis->name , "toplefty" , 0 , CONF_DEF_TOP_LEFT_Y) <= 255) {
|
||||
screen_begy = drvthis->config_get_int ( drvthis->name , "toplefty" , 0 , CONF_DEF_TOP_LEFT_Y);
|
||||
} else {
|
||||
report (RPT_WARNING, "CURSES: toplefty must between 0 and 255. Using default value %d.\n",CONF_DEF_TOP_LEFT_Y);
|
||||
}
|
||||
@@ -302,8 +320,8 @@ curses_drv_init (struct lcd_logical_driver *driver, char *args)
|
||||
intrflush (stdscr, FALSE);
|
||||
keypad (stdscr, TRUE);
|
||||
|
||||
lcd_win = newwin(curses_drv->hgt + 2,
|
||||
curses_drv->wid + 2,
|
||||
lcd_win = newwin(height + 2,
|
||||
width + 2,
|
||||
screen_begy,
|
||||
screen_begx);
|
||||
|
||||
@@ -325,38 +343,41 @@ curses_drv_init (struct lcd_logical_driver *driver, char *args)
|
||||
current_border_pair = 3;
|
||||
}
|
||||
|
||||
curses_drv_clear ();
|
||||
curses_drv_clear (drvthis);
|
||||
|
||||
driver->daemonize = 0; // don't daemonize...
|
||||
// Set variables for server
|
||||
drvthis->api_version = api_version;
|
||||
drvthis->stay_in_foreground = &stay_in_foreground;
|
||||
drvthis->supports_multiple = &supports_multiple;
|
||||
|
||||
// Override output functions...
|
||||
driver->clear = curses_drv_clear;
|
||||
driver->string = curses_drv_string;
|
||||
driver->chr = curses_drv_chr;
|
||||
driver->vbar = curses_drv_vbar;
|
||||
//driver->init_vbar = NULL;
|
||||
driver->hbar = curses_drv_hbar;
|
||||
//driver->init_hbar = NULL;
|
||||
driver->num = curses_drv_num;
|
||||
driver->init_num = curses_drv_init_num;
|
||||
// Set the functions the driver supports
|
||||
drvthis->init = curses_drv_init;
|
||||
drvthis->close = curses_drv_close;
|
||||
drvthis->width = curses_drv_width;
|
||||
drvthis->height = curses_drv_height;
|
||||
drvthis->clear = curses_drv_clear;
|
||||
drvthis->flush = curses_drv_flush;
|
||||
drvthis->string = curses_drv_string;
|
||||
drvthis->chr = curses_drv_chr;
|
||||
|
||||
driver->init = curses_drv_init;
|
||||
driver->close = curses_drv_close;
|
||||
driver->flush = curses_drv_flush;
|
||||
driver->flush_box = curses_drv_flush_box;
|
||||
//driver->contrast = NULL;
|
||||
driver->backlight = curses_drv_backlight;
|
||||
//driver->set_char = NULL;
|
||||
driver->icon = curses_drv_icon;
|
||||
driver->draw_frame = curses_drv_draw_frame;
|
||||
drvthis->old_vbar = curses_drv_vbar;
|
||||
//drvthis->init_vbar = NULL;
|
||||
drvthis->old_hbar = curses_drv_hbar;
|
||||
//drvthis->init_hbar = NULL;
|
||||
drvthis->num = curses_drv_num;
|
||||
//drvthis->init_num = curses_drv_init_num;
|
||||
|
||||
driver->getkey = curses_drv_getkey;
|
||||
driver->heartbeat = curses_drv_heartbeat;
|
||||
drvthis->backlight = curses_drv_backlight;
|
||||
//drvthis->set_char = NULL;
|
||||
drvthis->old_icon = curses_drv_icon; // NEEDS TO BE CHANGED !
|
||||
|
||||
drvthis->getkey = curses_drv_getkey;
|
||||
drvthis->heartbeat = curses_drv_heartbeat;
|
||||
|
||||
// Change the character used for "..."
|
||||
ELLIPSIS = '~';
|
||||
|
||||
return 200; // 200 is arbitrary. (must be 1 or more)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -383,8 +404,8 @@ curses_drv_wborder (WINDOW *win) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
curses_drv_close ()
|
||||
MODULE_EXPORT void
|
||||
curses_drv_close (Driver *drvthis)
|
||||
{
|
||||
// Note that the program leaves a screen on
|
||||
// the display to be left behind after closing;
|
||||
@@ -397,62 +418,69 @@ curses_drv_close ()
|
||||
move (0, 0);
|
||||
endwin ();
|
||||
curs_set(1);
|
||||
}
|
||||
|
||||
if (curses_drv->framebuf != NULL)
|
||||
free (curses_drv->framebuf);
|
||||
|
||||
curses_drv->framebuf = NULL;
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display width
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
curses_drv_width (Driver *drvthis)
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display height
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
curses_drv_height (Driver *drvthis)
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clears the LCD screen
|
||||
//
|
||||
void
|
||||
curses_drv_clear ()
|
||||
MODULE_EXPORT void
|
||||
curses_drv_clear (Driver *drvthis)
|
||||
{
|
||||
wbkgdset(lcd_win, COLOR_PAIR(current_color_pair) | ' ');
|
||||
curses_drv_wborder (lcd_win);
|
||||
werase (lcd_win);
|
||||
}
|
||||
|
||||
#define ValidX(x) { if ((x) > curses_drv->wid) { (x) = curses_drv->wid; } else (x) = (x) < 1 ? 1 : x; }
|
||||
#define ValidY(y) { if ((y) > curses_drv->hgt) { (y) = curses_drv->hgt; } else (y) = (y) < 1 ? 1 : y; }
|
||||
#define ValidX(x) { if ((x) > width) { (x) = width; } else (x) = (x) < 1 ? 1 : x; }
|
||||
#define ValidY(y) { if ((y) > height) { (y) = height; } else (y) = (y) < 1 ? 1 : y; }
|
||||
|
||||
void
|
||||
curses_drv_backlight (int on)
|
||||
MODULE_EXPORT void
|
||||
curses_drv_backlight (Driver *drvthis, int promille)
|
||||
{
|
||||
if (curses_backlight_state == on)
|
||||
if (curses_backlight_state == promille)
|
||||
return;
|
||||
|
||||
// no backlight: pairs 2, 3
|
||||
// backlight: pairs 4, 5
|
||||
|
||||
switch (on) {
|
||||
case 0:
|
||||
curses_backlight_state = 0;
|
||||
current_color_pair = 2;
|
||||
current_border_pair = 3;
|
||||
break;
|
||||
case 1:
|
||||
curses_backlight_state = 1;
|
||||
current_color_pair = 4;
|
||||
current_border_pair = 5;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
curses_backlight_state = promille;
|
||||
|
||||
if (promille) {
|
||||
current_color_pair = 4;
|
||||
current_border_pair = 5;
|
||||
}
|
||||
else {
|
||||
current_color_pair = 2;
|
||||
current_border_pair = 3;
|
||||
}
|
||||
|
||||
curses_drv_clear();
|
||||
curses_drv_clear(drvthis);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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).
|
||||
//
|
||||
void
|
||||
curses_drv_string (int x, int y, char *string)
|
||||
MODULE_EXPORT void
|
||||
curses_drv_string (Driver *drvthis, int x, int y, char *string)
|
||||
{
|
||||
//int i;
|
||||
unsigned char *p;
|
||||
@@ -483,8 +511,8 @@ curses_drv_string (int x, int y, char *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,4).
|
||||
//
|
||||
void
|
||||
curses_drv_chr (int x, int y, char c)
|
||||
MODULE_EXPORT void
|
||||
curses_drv_chr (Driver *drvthis, int x, int y, char c)
|
||||
{
|
||||
int ch;
|
||||
|
||||
@@ -504,7 +532,7 @@ curses_drv_chr (int x, int y, char c)
|
||||
|
||||
if ((ch = getch ()) != ERR)
|
||||
if (ch == 0x0C) {
|
||||
curses_drv_restore_screen();
|
||||
curses_drv_restore_screen(drvthis);
|
||||
ungetch(ch);
|
||||
}
|
||||
|
||||
@@ -514,8 +542,8 @@ curses_drv_chr (int x, int y, char c)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets up for big numbers.
|
||||
//
|
||||
void
|
||||
curses_drv_init_num ()
|
||||
MODULE_EXPORT void
|
||||
curses_drv_init_num (Driver *drvthis)
|
||||
{
|
||||
;
|
||||
}
|
||||
@@ -523,47 +551,47 @@ curses_drv_init_num ()
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Writes a big number.
|
||||
//
|
||||
void
|
||||
curses_drv_num (int x, int num)
|
||||
MODULE_EXPORT void
|
||||
curses_drv_num (Driver *drvthis, int x, int num)
|
||||
{
|
||||
int y, dx;
|
||||
|
||||
for (y = 1; y < 5; y++)
|
||||
for (dx = 0; dx < 3; dx++)
|
||||
curses_drv_chr (x + dx, y, num_icon[num][y-1][dx]);
|
||||
curses_drv_chr (drvthis, x + dx, y, num_icon[num][y-1][dx]);
|
||||
// printf("%1d",num);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a vertical bar; erases entire column onscreen.
|
||||
//
|
||||
void
|
||||
curses_drv_vbar (int x, int len)
|
||||
MODULE_EXPORT void
|
||||
curses_drv_vbar (Driver *drvthis, int x, int len)
|
||||
{
|
||||
int y;
|
||||
char map[] = { ACS_S9, ACS_S9, ACS_S7, ACS_S7, ACS_S3, ACS_S3, ACS_S1, ACS_S1 };
|
||||
|
||||
ValidX(x);
|
||||
|
||||
#define MAX_LINES (curses_drv->cellhgt * curses_drv->hgt)
|
||||
#define MAX_LINES (LCD_DEFAULT_CELLHEIGHT * height)
|
||||
|
||||
len = len > (MAX_LINES - 1) ? (MAX_LINES - 1) : len;
|
||||
len = len < 0 ? 0 : len;
|
||||
|
||||
// len is the length of the bar (in pixels/scanlines)
|
||||
// y is one character line (cellhgt pixels/scanlines)
|
||||
// y is one character line (cellheight pixels/scanlines)
|
||||
|
||||
for (y = curses_drv->hgt; y > 0 && len > 0; y--) {
|
||||
for (y = height; y > 0 && len > 0; y--) {
|
||||
|
||||
if (len >= curses_drv->cellhgt) {
|
||||
if (len >= LCD_DEFAULT_CELLHEIGHT) {
|
||||
// write a "full" block to the screen...
|
||||
//curses_drv_chr (x, y, '8');
|
||||
curses_drv_chr (x, y, ACS_BLOCK);
|
||||
len -= curses_drv->cellhgt;
|
||||
curses_drv_chr (drvthis, x, y, ACS_BLOCK);
|
||||
len -= LCD_DEFAULT_CELLHEIGHT;
|
||||
}
|
||||
else {
|
||||
// write a partial block...
|
||||
curses_drv_chr (x, y, map[len-1]);
|
||||
curses_drv_chr (drvthis, x, y, map[len-1]);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -577,16 +605,16 @@ curses_drv_vbar (int x, int len)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
void
|
||||
curses_drv_hbar (int x, int y, int len)
|
||||
MODULE_EXPORT void
|
||||
curses_drv_hbar (Driver *drvthis, int x, int y, int len)
|
||||
{
|
||||
for (; x <= curses_drv->wid && len > 0; x++) {
|
||||
if (len >= curses_drv->cellwid)
|
||||
curses_drv_chr (x, y, '=');
|
||||
for (; x <= width && len > 0; x++) {
|
||||
if (len >= LCD_DEFAULT_CELLWIDTH)
|
||||
curses_drv_chr (drvthis, x, y, '=');
|
||||
else
|
||||
curses_drv_chr (x, y, '-');
|
||||
curses_drv_chr (drvthis, x, y, '-');
|
||||
|
||||
len -= curses_drv->cellwid;
|
||||
len -= LCD_DEFAULT_CELLWIDTH;
|
||||
}
|
||||
|
||||
// move(y-1, x-1);
|
||||
@@ -596,8 +624,8 @@ curses_drv_hbar (int x, int y, int len)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets character 0 to an icon...
|
||||
//
|
||||
void
|
||||
curses_drv_icon (int which, char dest)
|
||||
MODULE_EXPORT void
|
||||
curses_drv_icon (Driver *drvthis, int which, char dest)
|
||||
{
|
||||
if (dest == 0)
|
||||
switch (which) {
|
||||
@@ -617,8 +645,8 @@ curses_drv_icon (int which, char dest)
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Does the heartbeat...
|
||||
//
|
||||
void
|
||||
curses_drv_heartbeat (int type)
|
||||
MODULE_EXPORT void
|
||||
curses_drv_heartbeat (Driver *drvthis, int type)
|
||||
{
|
||||
static int timer = 0;
|
||||
int whichIcon;
|
||||
@@ -633,13 +661,13 @@ curses_drv_heartbeat (int type)
|
||||
|
||||
// This defines a custom character EVERY time...
|
||||
// not efficient... is this necessary?
|
||||
curses_drv_icon (whichIcon, 0);
|
||||
curses_drv_icon (drvthis, whichIcon, 0);
|
||||
|
||||
// Put character on screen...
|
||||
curses_drv_chr (curses_drv->wid, 1, 0);
|
||||
curses_drv_chr (drvthis, width, 1, 0);
|
||||
|
||||
// change display...
|
||||
curses_drv_flush ();
|
||||
curses_drv_flush (drvthis);
|
||||
}
|
||||
|
||||
timer++;
|
||||
@@ -649,26 +677,14 @@ curses_drv_heartbeat (int type)
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Flushes all output to the lcd...
|
||||
//
|
||||
void
|
||||
curses_drv_flush ()
|
||||
{
|
||||
curses_drv_draw_frame (curses_drv->framebuf);
|
||||
}
|
||||
|
||||
void
|
||||
curses_drv_flush_box (int lft, int top, int rgt, int bot)
|
||||
{
|
||||
curses_drv_flush ();
|
||||
}
|
||||
|
||||
void
|
||||
curses_drv_draw_frame (char *dat)
|
||||
MODULE_EXPORT void
|
||||
curses_drv_flush (Driver *drvthis)
|
||||
{
|
||||
int c;
|
||||
|
||||
if ((c = getch ()) != ERR)
|
||||
if (c == 0x0C) {
|
||||
curses_drv_restore_screen();
|
||||
curses_drv_restore_screen(drvthis);
|
||||
ungetch (c);
|
||||
}
|
||||
|
||||
@@ -676,8 +692,9 @@ curses_drv_draw_frame (char *dat)
|
||||
wrefresh (lcd_win);
|
||||
}
|
||||
|
||||
char
|
||||
curses_drv_getkey ()
|
||||
|
||||
MODULE_EXPORT char
|
||||
curses_drv_getkey (Driver *drvthis)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -685,7 +702,7 @@ curses_drv_getkey ()
|
||||
|
||||
switch(i) {
|
||||
case 0x0C:
|
||||
curses_drv_restore_screen();
|
||||
curses_drv_restore_screen(drvthis);
|
||||
return 0;
|
||||
break;
|
||||
case KEY_LEFT:
|
||||
@@ -710,7 +727,8 @@ curses_drv_getkey ()
|
||||
}
|
||||
|
||||
void
|
||||
curses_drv_restore_screen () {
|
||||
curses_drv_restore_screen (Driver *drvthis) {
|
||||
|
||||
erase();
|
||||
refresh();
|
||||
#ifdef CURSES_HAS_REDRAWWIN
|
||||
|
||||
+22
-19
@@ -1,31 +1,34 @@
|
||||
#ifndef LCD_CURSES_H
|
||||
#define LCD_CURSES_H
|
||||
|
||||
extern lcd_logical_driver *curses_drv;
|
||||
#include "lcd.h"
|
||||
|
||||
int curses_drv_init (struct lcd_logical_driver *driver, char *args);
|
||||
void curses_drv_backlight (int on);
|
||||
void curses_drv_close ();
|
||||
void curses_drv_clear ();
|
||||
void curses_drv_flush ();
|
||||
void curses_drv_string (int x, int y, char string[]);
|
||||
void curses_drv_chr (int x, int y, char c);
|
||||
void curses_drv_vbar (int x, int len);
|
||||
void curses_drv_hbar (int x, int y, int len);
|
||||
void curses_drv_icon (int which, char dest);
|
||||
void curses_drv_flush ();
|
||||
void curses_drv_flush_box (int lft, int top, int rgt, int bot);
|
||||
void curses_drv_draw_frame (char *dat);
|
||||
char curses_drv_getkey ();
|
||||
void curses_drv_init_num ();
|
||||
void curses_drv_num (int x, int num);
|
||||
void curses_drv_heartbeat (int type);
|
||||
int curses_drv_init (Driver * drvthis, char *args);
|
||||
MODULE_EXPORT void curses_drv_close (Driver *drvthis);
|
||||
MODULE_EXPORT int curses_drv_width (Driver *drvthis);
|
||||
MODULE_EXPORT int curses_drv_height (Driver *drvthis);
|
||||
MODULE_EXPORT void curses_drv_clear (Driver *drvthis);
|
||||
MODULE_EXPORT void curses_drv_flush (Driver *drvthis);
|
||||
MODULE_EXPORT void curses_drv_string (Driver *drvthis, int x, int y, char string[]);
|
||||
MODULE_EXPORT void curses_drv_chr (Driver *drvthis, int x, int y, char c);
|
||||
|
||||
MODULE_EXPORT void curses_drv_vbar (Driver *drvthis, int x, int len);
|
||||
MODULE_EXPORT void curses_drv_hbar (Driver *drvthis, int x, int y, int len);
|
||||
MODULE_EXPORT void curses_drv_num (Driver *drvthis, int x, int num);
|
||||
MODULE_EXPORT void curses_drv_heartbeat (Driver *drvthis, int type);
|
||||
MODULE_EXPORT void curses_drv_icon (Driver *drvthis, int which, char dest);
|
||||
|
||||
MODULE_EXPORT void curses_drv_backlight (Driver *drvthis, int on);
|
||||
|
||||
MODULE_EXPORT char curses_drv_getkey (Driver *drvthis);
|
||||
|
||||
MODULE_EXPORT void curses_drv_init_num (Driver *drvthis);
|
||||
|
||||
/*Default settings for config file parsing*/
|
||||
#define CONF_DEF_FOREGR "blue"
|
||||
#define CONF_DEF_BACKGR "cyan"
|
||||
#define CONF_DEF_BACKLIGHT "red"
|
||||
#define CONF_DEF_SIZE "20x4"
|
||||
#define CONF_DEF_SIZE "20x4" // currently not used, LCD_DEFAULT_WIDTH etc. is used
|
||||
#define CONF_DEF_TOP_LEFT_X 7
|
||||
#define CONF_DEF_TOP_LEFT_Y 7
|
||||
|
||||
|
||||
+139
-122
@@ -6,9 +6,28 @@
|
||||
#include <string.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "lcd.h"
|
||||
#include "debug.h"
|
||||
#include "shared/report.h"
|
||||
#include "report.h"
|
||||
|
||||
|
||||
// Variables
|
||||
static char *framebuf = NULL;
|
||||
static int width = LCD_DEFAULT_WIDTH;
|
||||
static int height = LCD_DEFAULT_HEIGHT;
|
||||
|
||||
|
||||
// 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 = "debug_";
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// For Debugging Output //////////////////////////////
|
||||
@@ -17,86 +36,127 @@
|
||||
// TODO: somehow allow access to the driver->framebuffer to each
|
||||
// function...
|
||||
|
||||
static lcd_logical_driver *debug_drv;
|
||||
|
||||
int
|
||||
debug_init (struct lcd_logical_driver *driver, char *args)
|
||||
debug_init (Driver *drvthis, char *args)
|
||||
{
|
||||
report (RPT_INFO, "debug_init()");
|
||||
|
||||
debug_drv = driver;
|
||||
framebuf = malloc (width * height);
|
||||
|
||||
debug_clear ();
|
||||
debug_clear (drvthis);
|
||||
|
||||
driver->daemonize = 0;
|
||||
// Set variables for server
|
||||
drvthis->api_version = api_version;
|
||||
drvthis->stay_in_foreground = &stay_in_foreground;
|
||||
drvthis->supports_multiple = &supports_multiple;
|
||||
|
||||
driver->clear = debug_clear;
|
||||
driver->string = debug_string;
|
||||
driver->chr = debug_chr;
|
||||
driver->vbar = debug_vbar;
|
||||
driver->hbar = debug_hbar;
|
||||
driver->init_num = debug_init_num;
|
||||
driver->num = debug_num;
|
||||
// Set the functions the driver supports
|
||||
drvthis->clear = debug_clear;
|
||||
drvthis->string = debug_string;
|
||||
drvthis->chr = debug_chr;
|
||||
drvthis->old_vbar = debug_vbar;
|
||||
drvthis->old_hbar = debug_hbar;
|
||||
drvthis->init_num = debug_init_num;
|
||||
drvthis->num = debug_num;
|
||||
|
||||
driver->init = debug_init;
|
||||
driver->close = debug_close;
|
||||
driver->flush = debug_flush;
|
||||
driver->flush_box = debug_flush_box;
|
||||
driver->contrast = debug_contrast;
|
||||
driver->backlight = debug_backlight;
|
||||
driver->set_char = debug_set_char;
|
||||
driver->icon = debug_icon;
|
||||
driver->init_vbar = debug_init_vbar;
|
||||
driver->init_hbar = debug_init_hbar;
|
||||
driver->draw_frame = debug_draw_frame;
|
||||
drvthis->init = debug_init;
|
||||
drvthis->close = debug_close;
|
||||
drvthis->width = debug_width;
|
||||
drvthis->height = debug_height;
|
||||
drvthis->flush = debug_flush;
|
||||
drvthis->set_contrast = debug_set_contrast;
|
||||
drvthis->backlight = debug_backlight;
|
||||
drvthis->set_char = debug_set_char;
|
||||
drvthis->old_icon = debug_icon;
|
||||
drvthis->init_vbar = debug_init_vbar;
|
||||
drvthis->init_hbar = debug_init_hbar;
|
||||
|
||||
driver->getkey = debug_getkey;
|
||||
drvthis->getkey = debug_getkey;
|
||||
|
||||
return 200; // 200 is arbitrary. (must be 1 or more)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
debug_close ()
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Closes the driver
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
debug_close (Driver *drvthis)
|
||||
{
|
||||
report (RPT_INFO, "debug_close()");
|
||||
|
||||
if (debug_drv->framebuf) {
|
||||
report (RPT_DEBUG, "frame buffer: %010X", (int) debug_drv->framebuf);
|
||||
free (debug_drv->framebuf);
|
||||
}
|
||||
if(framebuf) free (framebuf);
|
||||
framebuf = NULL;
|
||||
}
|
||||
|
||||
debug_drv->framebuf = NULL;
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display width
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
debug_width (Driver *drvthis)
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display height
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
debug_height (Driver *drvthis)
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clears the LCD screen
|
||||
//
|
||||
void
|
||||
debug_clear ()
|
||||
MODULE_EXPORT void
|
||||
debug_clear (Driver *drvthis)
|
||||
{
|
||||
report (RPT_INFO, "clear()");
|
||||
|
||||
memset (debug_drv->framebuf, ' ', debug_drv->wid * debug_drv->hgt);
|
||||
memset (framebuf, ' ', width * height);
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Flushes all output to the lcd...
|
||||
//
|
||||
void
|
||||
debug_flush ()
|
||||
MODULE_EXPORT void
|
||||
debug_flush (Driver *drvthis)
|
||||
{
|
||||
int i, j;
|
||||
char out[LCD_MAX_WIDTH];
|
||||
|
||||
report (RPT_INFO, "flush()");
|
||||
|
||||
debug_drv->draw_frame ();
|
||||
for (i = 0; i < width; i++) {
|
||||
out[i] = '-';
|
||||
}
|
||||
out[width] = 0;
|
||||
//report (RPT_DEBUG, "+%s+", out);
|
||||
|
||||
for (i = 0; i < height; i++) {
|
||||
for (j = 0; j < width; j++) {
|
||||
out[j] = framebuf[j + (i * width)];
|
||||
}
|
||||
out[width] = 0;
|
||||
//report (RPT_DEBUG, "|%s|", out);
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i < width; i++) {
|
||||
out[i] = '-';
|
||||
}
|
||||
out[width] = 0;
|
||||
//report (RPT_DEBUG, "+%s+", out);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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).
|
||||
//
|
||||
void
|
||||
debug_string (int x, int y, char string[])
|
||||
MODULE_EXPORT void
|
||||
debug_string (Driver *drvthis, int x, int y, char string[])
|
||||
{
|
||||
|
||||
int i;
|
||||
@@ -106,7 +166,7 @@ debug_string (int x, int y, char string[])
|
||||
y --; x --; // Convert 1-based coords to 0-based...
|
||||
|
||||
for (i = 0; string[i]; i++) {
|
||||
debug_drv->framebuf[(y * debug_drv->wid) + x + i] = string[i];
|
||||
framebuf[(y * width) + x + i] = string[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,54 +174,53 @@ debug_string (int x, int y, char 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,4).
|
||||
//
|
||||
void
|
||||
debug_chr (int x, int y, char c)
|
||||
MODULE_EXPORT void
|
||||
debug_chr (Driver *drvthis, int x, int y, char c)
|
||||
{
|
||||
report (RPT_DEBUG, "char(%i,%i,%c)", x, y, c);
|
||||
|
||||
x--; y--;
|
||||
debug_drv->framebuf[(y * debug_drv->wid) + x] = c;
|
||||
framebuf[(y * width) + x] = c;
|
||||
}
|
||||
|
||||
int
|
||||
debug_contrast (int contrast)
|
||||
MODULE_EXPORT void
|
||||
debug_set_contrast (Driver *drvthis, int promille)
|
||||
{
|
||||
report (RPT_INFO, "contrast(%i)", contrast);
|
||||
return 0;
|
||||
report (RPT_INFO, "set_contrast(%i)", promille);
|
||||
}
|
||||
|
||||
void
|
||||
debug_backlight (int on)
|
||||
MODULE_EXPORT void
|
||||
debug_backlight (Driver *drvthis, int on)
|
||||
{
|
||||
report (RPT_INFO, "backlight(%i)", on);
|
||||
}
|
||||
|
||||
void
|
||||
debug_init_vbar ()
|
||||
MODULE_EXPORT void
|
||||
debug_init_vbar (Driver *drvthis)
|
||||
{
|
||||
report (LOG_INFO, "init_vbar()");
|
||||
report (RPT_INFO, "init_vbar()");
|
||||
}
|
||||
|
||||
void
|
||||
debug_init_hbar ()
|
||||
MODULE_EXPORT void
|
||||
debug_init_hbar (Driver *drvthis)
|
||||
{
|
||||
report (RPT_INFO, "init_hbar()");
|
||||
}
|
||||
|
||||
void
|
||||
debug_init_num ()
|
||||
MODULE_EXPORT void
|
||||
debug_init_num (Driver *drvthis)
|
||||
{
|
||||
report (RPT_INFO, "init_bignum()");
|
||||
}
|
||||
|
||||
void
|
||||
debug_num (int x, int num)
|
||||
MODULE_EXPORT void
|
||||
debug_num (Driver *drvthis, int x, int num)
|
||||
{
|
||||
report (RPT_INFO, "big number(%i,%i)", x, num);
|
||||
}
|
||||
|
||||
void
|
||||
debug_set_char (int n, char *dat)
|
||||
MODULE_EXPORT void
|
||||
debug_set_char (Driver *drvthis, int n, char *dat)
|
||||
{
|
||||
report (RPT_INFO, "set_char(%i,data)", n);
|
||||
}
|
||||
@@ -169,17 +228,17 @@ debug_set_char (int n, char *dat)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a vertical bar; erases entire column onscreen.
|
||||
//
|
||||
void
|
||||
debug_vbar (int x, int len)
|
||||
MODULE_EXPORT void
|
||||
debug_vbar (Driver *drvthis, int x, int len)
|
||||
{
|
||||
int y;
|
||||
|
||||
report (RPT_INFO, "vbar(%i,%i)", x, len);
|
||||
|
||||
for (y = debug_drv->hgt; y > 0 && len > 0; y--) {
|
||||
debug_chr (x, y, '|');
|
||||
for (y = height; y > 0 && len > 0; y--) {
|
||||
debug_chr (drvthis, x, y, '|');
|
||||
|
||||
len -= debug_drv->cellhgt;
|
||||
len -= LCD_DEFAULT_CELLHEIGHT;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -187,15 +246,15 @@ debug_vbar (int x, int len)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
void
|
||||
debug_hbar (int x, int y, int len)
|
||||
MODULE_EXPORT void
|
||||
debug_hbar (Driver *drvthis, int x, int y, int len)
|
||||
{
|
||||
report (RPT_INFO, "hbar(%i,%i,%i)", x, y, len);
|
||||
|
||||
for (; x < debug_drv->wid && len > 0; x++) {
|
||||
debug_chr (x, y, '-');
|
||||
for (; x < width && len > 0; x++) {
|
||||
debug_chr (drvthis, x, y, '-');
|
||||
|
||||
len -= debug_drv->cellwid;
|
||||
len -= LCD_DEFAULT_CELLWIDTH;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -203,59 +262,17 @@ debug_hbar (int x, int y, int len)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets character 0 to an icon...
|
||||
//
|
||||
void
|
||||
debug_icon (int which, char dest)
|
||||
MODULE_EXPORT void
|
||||
debug_icon (Driver *drvthis, int which, char dest)
|
||||
{
|
||||
report (RPT_INFO, "icon(%i,%i", which, dest);
|
||||
}
|
||||
|
||||
void
|
||||
debug_flush_box (int lft, int top, int rgt, int bot)
|
||||
{
|
||||
report (RPT_INFO, "flush_box(%i,%i,%i,%i)", lft, top, rgt, bot);
|
||||
|
||||
debug_flush ();
|
||||
}
|
||||
|
||||
void
|
||||
debug_draw_frame (char *dat)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
char out[LCD_MAX_WIDTH];
|
||||
|
||||
report (RPT_INFO, "draw_frame(data)");
|
||||
|
||||
if (!dat)
|
||||
return;
|
||||
|
||||
// report (RPT_DEBUG, "Frame (%ix%i): %s", debug_drv->wid, debug_drv->hgt, dat);
|
||||
|
||||
for (i = 0; i < debug_drv->wid; i++) {
|
||||
out[i] = '-';
|
||||
}
|
||||
out[debug_drv->wid] = 0;
|
||||
//report (RPT_DEBUG, "+%s+", out);
|
||||
|
||||
for (i = 0; i < debug_drv->hgt; i++) {
|
||||
for (j = 0; j < debug_drv->wid; j++) {
|
||||
out[j] = dat[j + (i * debug_drv->wid)];
|
||||
}
|
||||
out[debug_drv->wid] = 0;
|
||||
//report (RPT_DEBUG, "|%s|", out);
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i < debug_drv->wid; i++) {
|
||||
out[i] = '-';
|
||||
}
|
||||
out[debug_drv->wid] = 0;
|
||||
//report (RPT_DEBUG, "+%s+", out);
|
||||
|
||||
}
|
||||
|
||||
char
|
||||
debug_getkey ()
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Return a keypress
|
||||
//
|
||||
MODULE_EXPORT char
|
||||
debug_getkey (Driver *drvthis)
|
||||
{
|
||||
report (RPT_INFO, "getkey()");
|
||||
return 0;
|
||||
|
||||
+26
-19
@@ -1,24 +1,31 @@
|
||||
#ifndef LCD_DEBUG_H
|
||||
#define LCD_DEBUG_H
|
||||
|
||||
int debug_init (struct lcd_logical_driver *driver, char *args);
|
||||
void debug_close ();
|
||||
void debug_clear ();
|
||||
void debug_flush ();
|
||||
void debug_string (int x, int y, char string[]);
|
||||
void debug_chr (int x, int y, char c);
|
||||
int debug_contrast (int contrast);
|
||||
void debug_backlight (int on);
|
||||
void debug_init_vbar ();
|
||||
void debug_init_hbar ();
|
||||
void debug_init_num ();
|
||||
void debug_vbar (int x, int len);
|
||||
void debug_hbar (int x, int y, int len);
|
||||
void debug_num (int x, int num);
|
||||
void debug_set_char (int n, char *dat);
|
||||
void debug_icon (int which, char dest);
|
||||
void debug_flush_box (int lft, int top, int rgt, int bot);
|
||||
void debug_draw_frame (char *dat);
|
||||
char debug_getkey ();
|
||||
#include "lcd.h"
|
||||
|
||||
int debug_init (Driver *drvthis, char *args);
|
||||
MODULE_EXPORT void debug_close (Driver *drvthis);
|
||||
MODULE_EXPORT int debug_width (Driver *drvthis);
|
||||
MODULE_EXPORT int debug_height (Driver *drvthis);
|
||||
MODULE_EXPORT void debug_clear (Driver *drvthis);
|
||||
MODULE_EXPORT void debug_flush (Driver *drvthis);
|
||||
MODULE_EXPORT void debug_string (Driver *drvthis, int x, int y, char string[]);
|
||||
MODULE_EXPORT void debug_chr (Driver *drvthis, int x, int y, char c);
|
||||
|
||||
MODULE_EXPORT void debug_vbar (Driver *drvthis, int x, int len);
|
||||
MODULE_EXPORT void debug_hbar (Driver *drvthis, int x, int y, int len);
|
||||
MODULE_EXPORT void debug_num (Driver *drvthis, int x, int num);
|
||||
MODULE_EXPORT void debug_icon (Driver *drvthis, int which, char dest);
|
||||
|
||||
MODULE_EXPORT void debug_set_char (Driver *drvthis, int n, char *dat);
|
||||
|
||||
MODULE_EXPORT void debug_set_contrast (Driver *drvthis, int promille);
|
||||
MODULE_EXPORT void debug_backlight (Driver *drvthis, int promille);
|
||||
|
||||
MODULE_EXPORT char debug_getkey (Driver *drvthis);
|
||||
|
||||
MODULE_EXPORT void debug_init_vbar (Driver *drvthis);
|
||||
MODULE_EXPORT void debug_init_hbar (Driver *drvthis);
|
||||
MODULE_EXPORT void debug_init_num (Driver *drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
+197
-168
@@ -40,34 +40,40 @@ static unsigned char CGRAM[8] = { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0
|
||||
//////////////////// Matrix Orbital Graphical Driver /////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
lcd_logical_driver *glk;
|
||||
|
||||
static unsigned char * screen_contents = NULL ;
|
||||
int fontselected = 0 ;
|
||||
int gpo_count = 0 ;
|
||||
static int fontselected = 0 ;
|
||||
static int gpo_count = 0 ;
|
||||
|
||||
static char *framebuf = NULL;
|
||||
static int width = 0;
|
||||
static int height = 0;
|
||||
static int cellwidth = LCD_DEFAULT_CELLWIDTH;
|
||||
static int cellheight = LCD_DEFAULT_CELLHEIGHT;
|
||||
static int contrast;
|
||||
|
||||
// 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 = "glk_";
|
||||
|
||||
// TODO: Get lcd.framebuf to properly work as whatever driver is running...
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// init() should set up any device-specific stuff, and
|
||||
// point all the function pointers.
|
||||
int glk_init(struct lcd_logical_driver *driver, char *args)
|
||||
int
|
||||
glk_init(Driver *drvthis, char *args)
|
||||
{
|
||||
char * argv[64];
|
||||
int argc;
|
||||
char * device = "/dev/lcd" ;
|
||||
int contrast = 140;
|
||||
speed_t speed = B19200 ;
|
||||
|
||||
int i ;
|
||||
int width ;
|
||||
int height ;
|
||||
contrast = 560;
|
||||
|
||||
// printf("glk_init()\n");
|
||||
|
||||
glk = driver;
|
||||
|
||||
argc = get_args( argv, args, 64 );
|
||||
for( i = 0 ; i < argc; ++i ) {
|
||||
if( 0 == strcmp( argv[i], "-d")
|
||||
@@ -120,7 +126,7 @@ int glk_init(struct lcd_logical_driver *driver, char *args)
|
||||
"LCDproc Matrix-Orbital GLK Graphical LCD driver\n"
|
||||
"\n"
|
||||
"-d, --device select the serial device to use [/dev/lcd]\n"
|
||||
"-c, --contrast set the initial contrast value [140]\n"
|
||||
"-c, --contrast set the initial contrast value [560]\n"
|
||||
"-s, --speed set the serial port speed [19200]\n"
|
||||
"-h, --help display this help text\n"
|
||||
);
|
||||
@@ -168,22 +174,17 @@ int glk_init(struct lcd_logical_driver *driver, char *args)
|
||||
return( -1 );
|
||||
};
|
||||
};
|
||||
driver->wid = width ;
|
||||
driver->hgt = height ;
|
||||
|
||||
// You must use driver->framebuf here, but may use lcd.framebuf later.
|
||||
if(!driver->framebuf) {
|
||||
driver->framebuf = malloc(driver->wid * driver->hgt);
|
||||
};
|
||||
screen_contents = malloc( driver->wid * driver->hgt );
|
||||
framebuf = malloc(width * height);
|
||||
screen_contents = malloc( width * height );
|
||||
|
||||
if(driver->framebuf == NULL || screen_contents == NULL ) {
|
||||
if(framebuf == NULL || screen_contents == NULL ) {
|
||||
fprintf( stderr, "glk: Unable to allocate memory for screen buffers\n" );
|
||||
glk_close();
|
||||
glk_close(drvthis);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(driver->framebuf, ' ', driver->wid*driver->hgt);
|
||||
memset(framebuf, ' ', width*height);
|
||||
|
||||
// glk_clear();
|
||||
// glkputl( PortFD, GLKCommand, 0x58, EOF );
|
||||
@@ -203,70 +204,92 @@ int glk_init(struct lcd_logical_driver *driver, char *args)
|
||||
glkputl( PortFD, GLKCommand, 0x7e, 1, GLKCommand, 0x41, EOF );
|
||||
|
||||
// Set contrast
|
||||
glk_contrast( contrast );
|
||||
glk_set_contrast( drvthis, contrast );
|
||||
|
||||
driver->cellwid = 5;
|
||||
driver->cellhgt = 8;
|
||||
|
||||
driver->clear = glk_clear;
|
||||
driver->string = glk_string;
|
||||
driver->chr = glk_chr;
|
||||
driver->vbar = glk_vbar;
|
||||
driver->init_vbar = glk_init_vbar;
|
||||
driver->hbar = glk_hbar;
|
||||
driver->init_hbar = glk_init_hbar;
|
||||
driver->num = glk_num ;
|
||||
driver->init_num = glk_init_num ;
|
||||
|
||||
driver->init = glk_init;
|
||||
driver->close = glk_close;
|
||||
driver->flush = glk_flush;
|
||||
driver->flush_box = glk_flush_box;
|
||||
driver->contrast = glk_contrast;
|
||||
driver->backlight = glk_backlight;
|
||||
driver->output = glk_output;
|
||||
driver->set_char = glk_set_char;
|
||||
driver->icon = glk_icon;
|
||||
driver->draw_frame = glk_draw_frame;
|
||||
// Set variables for server
|
||||
drvthis->api_version = api_version;
|
||||
drvthis->stay_in_foreground = &stay_in_foreground;
|
||||
drvthis->supports_multiple = &supports_multiple;
|
||||
|
||||
driver->getkey = glk_getkey;
|
||||
|
||||
|
||||
return 200; // 200 is arbitrary. (must be 1 or more)
|
||||
// Set the functions the driver supports
|
||||
drvthis->clear = glk_clear;
|
||||
drvthis->string = glk_string;
|
||||
drvthis->chr = glk_chr;
|
||||
drvthis->old_vbar = glk_vbar;
|
||||
drvthis->init_vbar = glk_init_vbar;
|
||||
drvthis->old_hbar = glk_hbar;
|
||||
drvthis->init_hbar = glk_init_hbar;
|
||||
drvthis->num = glk_num ;
|
||||
drvthis->init_num = glk_init_num ;
|
||||
|
||||
drvthis->init = glk_init;
|
||||
drvthis->close = glk_close;
|
||||
drvthis->flush = glk_flush;
|
||||
drvthis->get_contrast = glk_get_contrast;
|
||||
drvthis->set_contrast = glk_set_contrast;
|
||||
drvthis->backlight = glk_backlight;
|
||||
drvthis->output = glk_output;
|
||||
drvthis->set_char = glk_set_char;
|
||||
drvthis->old_icon = glk_icon;
|
||||
|
||||
drvthis->getkey = glk_getkey;
|
||||
|
||||
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.
|
||||
|
||||
void glk_close()
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Close the driver
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
glk_close(Driver *drvthis)
|
||||
{
|
||||
if(glk->framebuf != NULL) free(glk->framebuf);
|
||||
|
||||
glk->framebuf = NULL;
|
||||
|
||||
glkclose( PortFD ) ;
|
||||
|
||||
if(framebuf) free(framebuf);
|
||||
framebuf = NULL;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display width
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
glk_width (Driver *drvthis)
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display height
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
glk_height (Driver *drvthis)
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clears the LCD screen
|
||||
//
|
||||
#define CLEARCOUNT (1000000)
|
||||
static int clearcount = 0 ;
|
||||
void glk_clear_forced()
|
||||
void glk_clear_forced(Driver *drvthis)
|
||||
{
|
||||
// puts( "REALLY CLEARING the display" );
|
||||
clearcount = CLEARCOUNT ;
|
||||
glkputl( PortFD, GLKCommand, 0x58, EOF );
|
||||
memset(screen_contents, ' ', glk->wid*glk->hgt);
|
||||
memset(screen_contents, ' ', width*height);
|
||||
}
|
||||
void glk_clear()
|
||||
MODULE_EXPORT void
|
||||
glk_clear(Driver *drvthis)
|
||||
{
|
||||
// puts( "glk_clear( )" );
|
||||
memset(glk->framebuf, ' ', glk->wid*glk->hgt);
|
||||
memset(framebuf, ' ', width*height);
|
||||
if( --clearcount < 0 ) {
|
||||
glk_clear_forced( );
|
||||
glk_clear_forced(drvthis);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -274,10 +297,47 @@ void glk_clear()
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Flushes all output to the lcd...
|
||||
//
|
||||
void glk_flush()
|
||||
MODULE_EXPORT void
|
||||
glk_flush(Driver *drvthis)
|
||||
{
|
||||
// puts( "glk_flush( )" );
|
||||
glk->draw_frame(glk->framebuf);
|
||||
char * p ;
|
||||
char * q ;
|
||||
int x, y ;
|
||||
int xs ;
|
||||
char * ps = NULL ;
|
||||
|
||||
// printf( "flush()\n" );
|
||||
|
||||
p = framebuf ;
|
||||
q = screen_contents ;
|
||||
|
||||
for( y = 0 ; y < height ; ++y ) {
|
||||
xs = -1 ; /* XStart not set */
|
||||
for( x = 0 ; x < width ; ++x ) {
|
||||
if( *q == *p && xs >= 0 ) {
|
||||
/* Write accumulated string */
|
||||
glkputl( PortFD, GLKCommand, 0x79, xs*6+1, y*8, EOF );
|
||||
glkputa( PortFD, x - xs, ps );
|
||||
// printf( "draw_frame: Writing at (%d,%d) for %d\n", xs, y, x-xs );
|
||||
xs = -1 ;
|
||||
} else if( *q != *p && xs < 0 ) {
|
||||
/* Start new string of changes */
|
||||
ps = p ;
|
||||
xs = x ;
|
||||
};
|
||||
*q++ = *p++ ; /* Update screen_contents from framebuf */
|
||||
};
|
||||
if( xs >= 0 ) {
|
||||
/* Write accumulated line */
|
||||
glkputl( PortFD, GLKCommand, 0x79, xs*6+1, y*8, EOF );
|
||||
glkputa( PortFD, width - xs, ps );
|
||||
// printf( "draw_frame: Writing at (%d,%d) for %d\n", xs, y, width-xs );
|
||||
};
|
||||
|
||||
}; /* For y */
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
@@ -285,18 +345,19 @@ void glk_flush()
|
||||
// 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).
|
||||
//
|
||||
void glk_string(int x, int y, char string[])
|
||||
MODULE_EXPORT void
|
||||
glk_string(Driver *drvthis, int x, int y, char string[])
|
||||
{
|
||||
char * p ;
|
||||
|
||||
// printf( "glk_string( %d, %d, \"%s\" )\n", x, y, string );
|
||||
|
||||
if( x > glk->wid || y > glk->hgt ) {
|
||||
if( x > width || y > height ) {
|
||||
return ;
|
||||
};
|
||||
|
||||
for( p = string ; *p && x <= glk->wid ; ++x, ++p ) {
|
||||
glk_chr( x, y, *p );
|
||||
for( p = string ; *p && x <= width ; ++x, ++p ) {
|
||||
glk_chr( drvthis, x, y, *p );
|
||||
};
|
||||
|
||||
}
|
||||
@@ -305,7 +366,8 @@ void glk_string(int x, int y, char 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,4).
|
||||
//
|
||||
void glk_chr(int x, int y, char c)
|
||||
MODULE_EXPORT void
|
||||
glk_chr(Driver *drvthis, int x, int y, char c)
|
||||
{
|
||||
int myc = (unsigned char) c ;
|
||||
x -= 1; // Convert 1-based coords to 0-based...
|
||||
@@ -319,7 +381,7 @@ void glk_chr(int x, int y, char c)
|
||||
/* Set font metrics */
|
||||
glkputl( PortFD, GLKCommand, 0x32, 1, 0, 1, 1, 32, EOF );
|
||||
/* Clear the screen */
|
||||
glk_clear_forced( );
|
||||
glk_clear_forced(drvthis);
|
||||
};
|
||||
|
||||
if( myc >= 0 && myc <= 15 ) {
|
||||
@@ -335,9 +397,22 @@ void glk_chr(int x, int y, char c)
|
||||
fprintf( stderr, "Attempt to write %d to (%d,%d)\n", myc, x, y );
|
||||
myc = 133 ;
|
||||
};
|
||||
|
||||
glk->framebuf[(y*glk->wid) + x] = myc;
|
||||
|
||||
framebuf[(y*width) + x] = myc;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
glk_get_contrast(Driver *drvthis)
|
||||
{
|
||||
return contrast;
|
||||
}
|
||||
|
||||
|
||||
@@ -345,22 +420,26 @@ void glk_chr(int x, int y, char c)
|
||||
// Sets the contrast of the display. Value is 0-255, where 140 is
|
||||
// what I consider "just right".
|
||||
//
|
||||
int glk_contrast(int contrast)
|
||||
MODULE_EXPORT void
|
||||
glk_set_contrast(Driver *drvthis, int promille)
|
||||
{
|
||||
static int saved_contrast = 140 ;
|
||||
// Check it
|
||||
if( contrast < 0 || contrast > 1000 )
|
||||
return;
|
||||
|
||||
if( contrast > 0 && contrast < 256 ) {
|
||||
saved_contrast = contrast ;
|
||||
// Store it
|
||||
contrast = promille;
|
||||
|
||||
// Do it
|
||||
// printf("Contrast: %i\n", contrast);
|
||||
glkputl( PortFD, GLKCommand, 0x50, contrast, EOF );
|
||||
};
|
||||
return( saved_contrast );
|
||||
glkputl( PortFD, GLKCommand, 0x50, (int) ((long)promille * 255 / 1000), EOF );
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Turns the lcd backlight on or off...
|
||||
//
|
||||
void glk_backlight(int on)
|
||||
MODULE_EXPORT void
|
||||
glk_backlight(Driver *drvthis, int on)
|
||||
{
|
||||
if(on) {
|
||||
// printf("Backlight ON\n");
|
||||
@@ -373,8 +452,8 @@ void glk_backlight(int on)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Sets general purpose outputs on or off
|
||||
void
|
||||
glk_output(int on)
|
||||
MODULE_EXPORT void
|
||||
glk_output(Driver *drvthis, int on)
|
||||
{
|
||||
if( gpo_count < 2 ) {
|
||||
if( on ) { glkputl( PortFD, GLKCommand, 'W', EOF );
|
||||
@@ -395,7 +474,8 @@ glk_output(int on)
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Tells the driver to get ready for vertical bargraphs.
|
||||
//
|
||||
void glk_init_vbar()
|
||||
MODULE_EXPORT void
|
||||
glk_init_vbar(Driver *drvthis)
|
||||
{
|
||||
// printf("Vertical bars.\n");
|
||||
}
|
||||
@@ -403,7 +483,8 @@ void glk_init_vbar()
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Tells the driver to get ready for horizontal bargraphs.
|
||||
//
|
||||
void glk_init_hbar()
|
||||
MODULE_EXPORT void
|
||||
glk_init_hbar(Driver *drvthis)
|
||||
{
|
||||
// printf("Horizontal bars.\n");
|
||||
}
|
||||
@@ -411,7 +492,8 @@ void glk_init_hbar()
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Tells the driver to get ready for big numbers, if possible.
|
||||
//
|
||||
void glk_init_num()
|
||||
MODULE_EXPORT void
|
||||
glk_init_num(Driver *drvthis)
|
||||
{
|
||||
// printf("Big Numbers.\n");
|
||||
if( fontselected != 3 ) {
|
||||
@@ -421,23 +503,25 @@ void glk_init_num()
|
||||
/* Set font metrics */
|
||||
glkputl( PortFD, GLKCommand, 0x32, 1, 0, 1, 1, 32, EOF );
|
||||
/* Clear the screen */
|
||||
glk_clear_forced( );
|
||||
glk_clear_forced(drvthis);
|
||||
};
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Draws a big (4-row) number.
|
||||
//
|
||||
void glk_num(int x, int num)
|
||||
MODULE_EXPORT void
|
||||
glk_num(Driver *drvthis, int x, int num)
|
||||
{
|
||||
// printf("BigNum(%i, %i)\n", x, num);
|
||||
glk->framebuf[x-1] = num + '0' ;
|
||||
framebuf[x-1] = num + '0' ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Changes the font data of character n.
|
||||
//
|
||||
void glk_set_char(int n, char *dat)
|
||||
MODULE_EXPORT void
|
||||
glk_set_char(Driver *drvthis, int n, char *dat)
|
||||
{
|
||||
printf("Set Character %i\n", n);
|
||||
}
|
||||
@@ -445,15 +529,16 @@ void glk_set_char(int n, char *dat)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a vertical bar, from the bottom of the screen up.
|
||||
//
|
||||
void glk_vbar(int x, int len)
|
||||
MODULE_EXPORT void
|
||||
glk_vbar(Driver *drvthis, int x, int len)
|
||||
{
|
||||
int y = glk->hgt ;
|
||||
int y = height ;
|
||||
|
||||
// printf( "glk_vbar( %d, %d )\n", x, len );
|
||||
while( len > glk->cellhgt ) {
|
||||
glk_chr( x, y, 255 );
|
||||
while( len > cellheight ) {
|
||||
glk_chr( drvthis, x, y, 255 );
|
||||
--y ;
|
||||
len -= glk->cellhgt ;
|
||||
len -= cellheight ;
|
||||
};
|
||||
|
||||
if( y >= 0 ) {
|
||||
@@ -468,23 +553,24 @@ void glk_vbar(int x, int len)
|
||||
case 6 : lastc = 143 ; break ;
|
||||
default: lastc = 133 ; break ;
|
||||
};
|
||||
glk_chr( x, y, lastc );
|
||||
glk_chr( drvthis, x, y, lastc );
|
||||
};
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
void glk_hbar(int x, int y, int len)
|
||||
MODULE_EXPORT void
|
||||
glk_hbar(Driver *drvthis, int x, int y, int len)
|
||||
{
|
||||
// printf( "glk_hbar( %d, %d, %d )\n", x, y, len );
|
||||
while( len > glk->cellwid ) {
|
||||
glk_chr( x, y, 255 );
|
||||
while( len > cellwidth ) {
|
||||
glk_chr( drvthis, x, y, 255 );
|
||||
++x ;
|
||||
len -= glk->cellwid ;
|
||||
len -= cellwidth ;
|
||||
};
|
||||
|
||||
if( x <= glk->wid ) {
|
||||
if( x <= width ) {
|
||||
int lastc ;
|
||||
switch( len ) {
|
||||
case 0 : lastc = ' ' ; break ;
|
||||
@@ -494,7 +580,7 @@ void glk_hbar(int x, int y, int len)
|
||||
case 4 : lastc = 137 ; break ;
|
||||
default: lastc = 133 ; break ;
|
||||
};
|
||||
glk_chr( x, y, lastc );
|
||||
glk_chr( drvthis, x, y, lastc );
|
||||
};
|
||||
}
|
||||
|
||||
@@ -502,7 +588,8 @@ void glk_hbar(int x, int y, int len)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets character 0 to an icon...
|
||||
//
|
||||
void glk_icon(int which, char dest)
|
||||
MODULE_EXPORT void
|
||||
glk_icon(Driver *drvthis, int which, char dest)
|
||||
{
|
||||
unsigned char old, new ;
|
||||
unsigned char * p ;
|
||||
@@ -529,11 +616,11 @@ void glk_icon(int which, char dest)
|
||||
|
||||
old = CGRAM[(int)dest] ;
|
||||
CGRAM[(int)dest] = new ;
|
||||
p = glk->framebuf ;
|
||||
p = framebuf ;
|
||||
q = screen_contents ;
|
||||
|
||||
/* Replace all old icons with new icon in new frame */
|
||||
for( count = glk->wid * glk->hgt ; count ; --count ) {
|
||||
for( count = width * height ; count ; --count ) {
|
||||
if( *q == old ) {
|
||||
// printf( "icon %d to %d at %d\n", old, new, q - screen_contents );
|
||||
*p = new ;
|
||||
@@ -545,77 +632,19 @@ void glk_icon(int which, char dest)
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Send a rectangular area to the display.
|
||||
//
|
||||
// I've just called glk_flush() because there's not much point yet
|
||||
// in flushing less than the entire framebuffer.
|
||||
//
|
||||
void glk_flush_box(int lft, int top, int rgt, int bot)
|
||||
{
|
||||
// printf("glk_flush_box( %d, %d, %d, %d )\n", lft, top, rgt, bot );
|
||||
glk_flush( );
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Draws the framebuffer on the display.
|
||||
//
|
||||
// The commented-out code is from the text driver.
|
||||
//
|
||||
void glk_draw_frame(char *dat)
|
||||
{
|
||||
char * p ;
|
||||
char * q ;
|
||||
int x, y ;
|
||||
int xs ;
|
||||
char * ps = NULL ;
|
||||
|
||||
// printf( "glk_draw_frame( %p ) glk->framebuf = %p\n", dat, glk->framebuf );
|
||||
|
||||
p = glk->framebuf ;
|
||||
q = screen_contents ;
|
||||
|
||||
for( y = 0 ; y < glk->hgt ; ++y ) {
|
||||
xs = -1 ; /* XStart not set */
|
||||
for( x = 0 ; x < glk->wid ; ++x ) {
|
||||
if( *q == *p && xs >= 0 ) {
|
||||
/* Write accumulated string */
|
||||
glkputl( PortFD, GLKCommand, 0x79, xs*6+1, y*8, EOF );
|
||||
glkputa( PortFD, x - xs, ps );
|
||||
// printf( "draw_frame: Writing at (%d,%d) for %d\n", xs, y, x-xs );
|
||||
xs = -1 ;
|
||||
} else if( *q != *p && xs < 0 ) {
|
||||
/* Start new string of changes */
|
||||
ps = p ;
|
||||
xs = x ;
|
||||
};
|
||||
*q++ = *p++ ; /* Update screen_contents from glk->framebuf */
|
||||
};
|
||||
if( xs >= 0 ) {
|
||||
/* Write accumulated line */
|
||||
glkputl( PortFD, GLKCommand, 0x79, xs*6+1, y*8, EOF );
|
||||
glkputa( PortFD, glk->wid - xs, ps );
|
||||
// printf( "draw_frame: Writing at (%d,%d) for %d\n", xs, y, glk->wid-xs );
|
||||
};
|
||||
|
||||
}; /* For y */
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Tries to read a character from an input device...
|
||||
//
|
||||
// Return 0 for "nothing available".
|
||||
//
|
||||
char glk_getkey()
|
||||
MODULE_EXPORT char
|
||||
glk_getkey(Driver *drvthis)
|
||||
{
|
||||
int c ;
|
||||
static int key = -1 ;
|
||||
static struct timeval lastkey ;
|
||||
struct timeval now ;
|
||||
|
||||
|
||||
// puts( "glk_getkey( )" );
|
||||
|
||||
c = glkgetc( PortFD );
|
||||
|
||||
+22
-108
@@ -1,119 +1,33 @@
|
||||
#ifndef GLK_H
|
||||
#define GLK_H
|
||||
|
||||
/********************************************************************
|
||||
How to make a driver for LCDproc
|
||||
#include "lcd.h"
|
||||
|
||||
Note: Insert the name of your driver in place of the phrase "new_driver".
|
||||
|
||||
1. Copy drv_base.c and drv_base.h to new_driver.c and new_driver.h.
|
||||
int glk_init(Driver *drvthis, char *args);
|
||||
MODULE_EXPORT void glk_close(Driver *drvthis);
|
||||
MODULE_EXPORT int glk_width(Driver *drvthis);
|
||||
MODULE_EXPORT int glk_height(Driver *drvthis);
|
||||
MODULE_EXPORT void glk_clear(Driver *drvthis);
|
||||
MODULE_EXPORT void glk_flush(Driver *drvthis);
|
||||
MODULE_EXPORT void glk_string(Driver *drvthis, int x, int y, char string[]);
|
||||
MODULE_EXPORT void glk_chr(Driver *drvthis, int x, int y, char c);
|
||||
|
||||
2. Decide which functions you want to override, which ones you want
|
||||
to leave alone, and which ones you don't want at all. If you
|
||||
write your own driver functions, they will get called when
|
||||
appropriate. Or, you can let the default driver "drv_base"
|
||||
handle a function for you. But, if you really don't want a
|
||||
function, you can completely prevent your driver from providing
|
||||
it. This is discussed in step 5.
|
||||
|
||||
2.1. Remove all functions which you don't want to override, and the
|
||||
ones you don't want at all.
|
||||
MODULE_EXPORT void glk_vbar(Driver *drvthis, int x, int len);
|
||||
MODULE_EXPORT void glk_hbar(Driver *drvthis, int x, int y, int len);
|
||||
MODULE_EXPORT void glk_num(Driver *drvthis, int x, int num);
|
||||
MODULE_EXPORT void glk_icon(Driver *drvthis, int which, char dest);
|
||||
|
||||
3. Rename all functions from "drv_base_*" to "new_driver_*".
|
||||
MODULE_EXPORT void glk_set_char(Driver *drvthis, int n, char *dat);
|
||||
|
||||
4. Write the new driver functions.
|
||||
Be sure to do one of the following in/for your new_driver_close():
|
||||
- free the framebuffer lcd.framebuf
|
||||
- let the default driver handle close()
|
||||
- call drv_base_close()
|
||||
This will ensure that the frame buffer gets freed.
|
||||
MODULE_EXPORT int glk_get_contrast(Driver *drvthis);
|
||||
MODULE_EXPORT void glk_set_contrast(Driver *drvthis, int promille);
|
||||
MODULE_EXPORT void glk_backlight(Driver *drvthis, int on);
|
||||
MODULE_EXPORT void glk_output(Driver *drvthis, int on);
|
||||
|
||||
5. Register your functions in your new_driver_init(), like the following:
|
||||
driver->clear = new_driver_clear; // We want to handle this one
|
||||
driver->string = (void *)-1; // Leave this to the default
|
||||
driver->getkey = NULL; // This should never get called
|
||||
|
||||
The convention here is to set NULL for all the functions which
|
||||
your driver doesn't handle (and which you don't want the default
|
||||
functions to be called for). Or, set -1 to indicate that the
|
||||
driver should support the function but can use the default
|
||||
behavior in drv_base.c. Or, to indicate that your driver should
|
||||
handle a function, just set it like clear() above.
|
||||
|
||||
6. Add the driver to lcd.c, in the physical drivers section, protected
|
||||
by an #ifdef like the rest of the drivers are.
|
||||
|
||||
7. Add your driver to the Makefile, and Makefile.config, in the same
|
||||
style as the existing ones.
|
||||
|
||||
|
||||
Notes:
|
||||
|
||||
Don't call lcd.whatever() functions within your driver. This causes
|
||||
a lot of potentially puzzling problems.
|
||||
|
||||
However, feel free to access lcd.framebuf in your driver (but not in
|
||||
your init() function!). It will always point to the frame buffer
|
||||
you should be writing to. This will usually be your own frame
|
||||
buffer, but could potentially be another frame buffer, if another
|
||||
driver wants to access your functions.
|
||||
|
||||
Your driver will be provided with a frame buffer which contains one
|
||||
byte per character on the LCD. The default is a 20x4, so that's 80
|
||||
bytes. You can free this and reallocate it to something else if you
|
||||
need to. A graphical driver may want to do this, for example.
|
||||
|
||||
If you don't set a function pointer, it will default to NULL, since
|
||||
they get nullified before the driver's init() is called.
|
||||
|
||||
Assume that your driver may be added or removed dynamically, and
|
||||
that more than one instance may exist at a time. In other words, it
|
||||
should init and close cleanly, and not depend on global variables.
|
||||
|
||||
Special arguments will be passed through the "args" variable to your
|
||||
_init() function. This is just a string, and you determine the
|
||||
syntax of it. Please document the syntax so that it can easily be
|
||||
included in the lcdproc config file. I suggest arguments such as
|
||||
"port=0x378" or "-device /dev/ttyS0". These come directly from the
|
||||
lcdproc server config file, so they should be human-readable. An
|
||||
example may look like this:
|
||||
|
||||
# Set up two MtxOrb LCD's and a curses display on VT 2
|
||||
Driver MtxOrb -device /dev/ttyS0 -keypad on
|
||||
Driver curses -color off -size 20x4 -vt 2
|
||||
Driver MtxOrb -device /dev/ttyS3 -size 20x2 -keypad off
|
||||
# Before you ask, no, not all of these options are implemented yet.
|
||||
|
||||
Also, the driver API (if it can be called that) may change soon.
|
||||
There seem to be several functions which just don't do anything
|
||||
important... and there are other potential improvements too.
|
||||
|
||||
And... When in doubt, look at how the other drivers do it. :)
|
||||
|
||||
******************************************************************/
|
||||
|
||||
extern lcd_logical_driver *glk;
|
||||
|
||||
int glk_init(struct lcd_logical_driver *driver, char *args);
|
||||
void glk_close();
|
||||
void glk_clear();
|
||||
void glk_flush();
|
||||
void glk_string(int x, int y, char string[]);
|
||||
void glk_chr(int x, int y, char c);
|
||||
int glk_contrast(int contrast);
|
||||
void glk_backlight(int on);
|
||||
void glk_output(int on);
|
||||
void glk_vbar(int x, int len);
|
||||
void glk_init_vbar();
|
||||
void glk_hbar(int x, int y, int len);
|
||||
void glk_init_hbar();
|
||||
void glk_num(int x, int num);
|
||||
void glk_init_num();
|
||||
void glk_set_char(int n, char *dat);
|
||||
void glk_icon(int which, char dest);
|
||||
void glk_flush_box(int lft, int top, int rgt, int bot);
|
||||
void glk_draw_frame(char *dat);
|
||||
char glk_getkey();
|
||||
MODULE_EXPORT char glk_getkey(Driver *drvthis);
|
||||
|
||||
MODULE_EXPORT void glk_init_vbar(Driver *drvthis);
|
||||
MODULE_EXPORT void glk_init_hbar(Driver *drvthis);
|
||||
MODULE_EXPORT void glk_init_num(Driver *drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
*/
|
||||
|
||||
#include "hd44780-4bit.h"
|
||||
#include "hd44780.h"
|
||||
#include "hd44780-low.h"
|
||||
#include "lpt-port.h"
|
||||
|
||||
#include "port.h"
|
||||
@@ -76,9 +76,9 @@
|
||||
// HD44780_senddata
|
||||
// HD44780_readkeypad
|
||||
|
||||
void lcdstat_HD44780_senddata (unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lcdstat_HD44780_backlight (unsigned char state);
|
||||
unsigned char lcdstat_HD44780_readkeypad (unsigned int YData);
|
||||
void lcdstat_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lcdstat_HD44780_backlight (PrivateData *p, unsigned char state);
|
||||
unsigned char lcdstat_HD44780_readkeypad (PrivateData *p, unsigned int YData);
|
||||
|
||||
#define RS 0x10
|
||||
#define RW 0x20
|
||||
@@ -88,88 +88,86 @@ unsigned char lcdstat_HD44780_readkeypad (unsigned int YData);
|
||||
#define BL 0x20
|
||||
// note that the above bits are all meant for the data port of LPT
|
||||
|
||||
static unsigned char EnMask[] = { EN1, EN2, EN3, STRB, LF, INIT, SEL };
|
||||
static const unsigned char EnMask[] = { EN1, EN2, EN3, STRB, LF, INIT, SEL };
|
||||
|
||||
#define ALLEXT (STRB|LF|INIT|SEL)
|
||||
// The above bits are on the control port of LPT
|
||||
|
||||
static unsigned int lptPort;
|
||||
static char stuckinputs = 0; // if an input line is stuck, it will be ignored
|
||||
static char backlight_bit = 0; // default to low to enable three displays
|
||||
|
||||
// initialisation function
|
||||
int
|
||||
hd_init_4bit (HD44780_functions * hd44780_functions, lcd_logical_driver * driver, char *args, unsigned int port)
|
||||
hd_init_4bit (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData*) drvthis->private_data;
|
||||
HD44780_functions *hd44780_functions = p->hd44780_functions;
|
||||
|
||||
int enableLines = EN1 | EN2;
|
||||
|
||||
// Reserve the port registers
|
||||
lptPort = port;
|
||||
port_access(lptPort);
|
||||
port_access(lptPort+1);
|
||||
port_access(lptPort+2);
|
||||
port_access(p->port);
|
||||
port_access(p->port+1);
|
||||
port_access(p->port+2);
|
||||
|
||||
hd44780_functions->senddata = lcdstat_HD44780_senddata;
|
||||
hd44780_functions->backlight = lcdstat_HD44780_backlight;
|
||||
hd44780_functions->readkeypad = lcdstat_HD44780_readkeypad;
|
||||
|
||||
// powerup the lcd now
|
||||
if (extIF) {
|
||||
if (p->extIF) {
|
||||
enableLines |= EN3;
|
||||
port_out (lptPort + 2, 0 ^ OUTMASK);
|
||||
port_out (p->port + 2, 0 ^ OUTMASK);
|
||||
}
|
||||
port_out (lptPort, 0x03);
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
port_out (p->port, 0x03);
|
||||
if( p->delayBus ) hd44780_functions->uPause (p, 1);
|
||||
|
||||
port_out (lptPort, enableLines | 0x03);
|
||||
if (extIF)
|
||||
port_out (lptPort + 2, ALLEXT ^ OUTMASK);
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
port_out (lptPort, 0x03);
|
||||
if (extIF)
|
||||
port_out (lptPort + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause (4100);
|
||||
port_out (p->port, enableLines | 0x03);
|
||||
if (p->extIF)
|
||||
port_out (p->port + 2, ALLEXT ^ OUTMASK);
|
||||
if( p->delayBus ) hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, 0x03);
|
||||
if (p->extIF)
|
||||
port_out (p->port + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause (p, 4100);
|
||||
|
||||
port_out (lptPort, enableLines | 0x03);
|
||||
if (extIF)
|
||||
port_out (lptPort + 2, ALLEXT ^ OUTMASK);
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
port_out (lptPort, 0x03);
|
||||
if (extIF)
|
||||
port_out (lptPort + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause (100);
|
||||
port_out (p->port, enableLines | 0x03);
|
||||
if (p->extIF)
|
||||
port_out (p->port + 2, ALLEXT ^ OUTMASK);
|
||||
if( p->delayBus ) hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, 0x03);
|
||||
if (p->extIF)
|
||||
port_out (p->port + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause (p, 100);
|
||||
|
||||
port_out (lptPort, enableLines | 0x03);
|
||||
if (extIF)
|
||||
port_out (lptPort + 2, ALLEXT ^ OUTMASK);
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
port_out (lptPort, 0x03);
|
||||
if (extIF)
|
||||
port_out (lptPort + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause (40);
|
||||
port_out (p->port, enableLines | 0x03);
|
||||
if (p->extIF)
|
||||
port_out (p->port + 2, ALLEXT ^ OUTMASK);
|
||||
if( p->delayBus ) hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, 0x03);
|
||||
if (p->extIF)
|
||||
port_out (p->port + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause (p, 40);
|
||||
|
||||
// now in 8-bit mode... set 4-bit mode
|
||||
port_out (lptPort, 0x02);
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
port_out (p->port, 0x02);
|
||||
if( p->delayBus ) hd44780_functions->uPause (p, 1);
|
||||
|
||||
port_out (lptPort, enableLines | 0x02);
|
||||
if (extIF)
|
||||
port_out (lptPort + 2, ALLEXT ^ OUTMASK);
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
port_out (lptPort, 0x02);
|
||||
if (extIF)
|
||||
port_out (lptPort + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause (40);
|
||||
port_out (p->port, enableLines | 0x02);
|
||||
if (p->extIF)
|
||||
port_out (p->port + 2, ALLEXT ^ OUTMASK);
|
||||
if( p->delayBus ) hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, 0x02);
|
||||
if (p->extIF)
|
||||
port_out (p->port + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause (p, 40);
|
||||
|
||||
// Set up two-line, small character (5x8) mode
|
||||
hd44780_functions->senddata (0, RS_INSTR, FUNCSET | TWOLINE | SMALLCHAR );
|
||||
hd44780_functions->uPause (40);
|
||||
hd44780_functions->senddata (p, 0, RS_INSTR, FUNCSET | TWOLINE | SMALLCHAR );
|
||||
hd44780_functions->uPause (p, 40);
|
||||
|
||||
common_init ();
|
||||
common_init (p);
|
||||
|
||||
if (have_keypad) {
|
||||
if (p->have_keypad) {
|
||||
// Remember which input lines are stuck
|
||||
stuckinputs = lcdstat_HD44780_readkeypad (0);
|
||||
p->stuckinputs = lcdstat_HD44780_readkeypad (p, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -177,7 +175,7 @@ hd_init_4bit (HD44780_functions * hd44780_functions, lcd_logical_driver * driver
|
||||
|
||||
// lcdstat_HD44780_senddata
|
||||
void
|
||||
lcdstat_HD44780_senddata (unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
lcdstat_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
{
|
||||
unsigned char enableLines = 0, portControl = 0;
|
||||
unsigned char h = (ch >> 4) & 0x0f; // high and low nibbles
|
||||
@@ -188,7 +186,7 @@ lcdstat_HD44780_senddata (unsigned char displayID, unsigned char flags, unsigned
|
||||
else //if (flags == RS_DATA)
|
||||
portControl = RS;
|
||||
|
||||
portControl |= backlight_bit;
|
||||
portControl |= p->backlight_bit;
|
||||
|
||||
if (displayID <= 3) {
|
||||
if (displayID == 0)
|
||||
@@ -196,64 +194,64 @@ lcdstat_HD44780_senddata (unsigned char displayID, unsigned char flags, unsigned
|
||||
else
|
||||
enableLines = EnMask[displayID - 1];
|
||||
|
||||
port_out (lptPort, portControl | h);
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
port_out (lptPort, enableLines | portControl | h);
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
port_out (lptPort, portControl | h);
|
||||
port_out (p->port, portControl | h);
|
||||
if( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, enableLines | portControl | h);
|
||||
if( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, portControl | h);
|
||||
|
||||
port_out (lptPort, portControl | l);
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
port_out (lptPort, enableLines | portControl | l);
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
port_out (lptPort, portControl | l);
|
||||
port_out (p->port, portControl | l);
|
||||
if( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, enableLines | portControl | l);
|
||||
if( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, portControl | l);
|
||||
}
|
||||
|
||||
if (extIF && (displayID == 0 || displayID >= 4)) {
|
||||
if (p->extIF && (displayID == 0 || displayID >= 4)) {
|
||||
if (displayID == 0)
|
||||
enableLines = ALLEXT;
|
||||
else
|
||||
enableLines = EnMask[(displayID - 1)];
|
||||
|
||||
port_out (lptPort, portControl | h);
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
port_out (lptPort + 2, enableLines ^ OUTMASK);
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
port_out (lptPort + 2, 0 ^ OUTMASK);
|
||||
port_out (p->port, portControl | h);
|
||||
if( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port + 2, enableLines ^ OUTMASK);
|
||||
if( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port + 2, 0 ^ OUTMASK);
|
||||
|
||||
port_out (lptPort, portControl | l);
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
port_out (lptPort + 2, enableLines ^ OUTMASK);
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
port_out (lptPort + 2, 0 ^ OUTMASK);
|
||||
port_out (p->port, portControl | l);
|
||||
if( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port + 2, enableLines ^ OUTMASK);
|
||||
if( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port + 2, 0 ^ OUTMASK);
|
||||
}
|
||||
}
|
||||
|
||||
void lcdstat_HD44780_backlight (unsigned char state)
|
||||
void lcdstat_HD44780_backlight (PrivateData *p, unsigned char state)
|
||||
{
|
||||
backlight_bit = (state?0:0x20); // D5 line
|
||||
p->backlight_bit = (state?0:0x20); // D5 line
|
||||
|
||||
port_out (lptPort, backlight_bit);
|
||||
port_out (p->port, p->backlight_bit);
|
||||
}
|
||||
|
||||
unsigned char lcdstat_HD44780_readkeypad (unsigned int YData)
|
||||
unsigned char lcdstat_HD44780_readkeypad (PrivateData *p, unsigned int YData)
|
||||
{
|
||||
unsigned char readval;
|
||||
|
||||
// 10 bits output or 6 bits if >=3 displays
|
||||
// Convert the positive logic to the negative logic on the LPT port
|
||||
port_out (lptPort, ~YData & 0x003F );
|
||||
if (!extIF) {
|
||||
port_out (lptPort + 2, ( ((~YData & 0x03C0) << 6 )) ^ OUTMASK);
|
||||
port_out (p->port, ~YData & 0x003F );
|
||||
if (!p->extIF) {
|
||||
port_out (p->port + 2, ( ((~YData & 0x03C0) << 6 )) ^ OUTMASK);
|
||||
}
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
if( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
|
||||
// Read inputs
|
||||
readval = ~ port_in (lptPort + 1) ^ INMASK;
|
||||
readval = ~ port_in (p->port + 1) ^ INMASK;
|
||||
|
||||
// Put port back into idle state for backlight
|
||||
port_out (lptPort, backlight_bit);
|
||||
port_out (p->port, p->backlight_bit);
|
||||
|
||||
// And convert value back.
|
||||
return ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) ) & ~stuckinputs;
|
||||
return ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) ) & ~p->stuckinputs;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#ifndef HD_LCDSTAT_H
|
||||
#define HD_LCDSTAT_H
|
||||
|
||||
#include "lcd.h" /* for lcd_logical_driver */
|
||||
#include "hd44780-low.h" /* for HD44780_functions */
|
||||
#include "lcd.h" /* for Driver */
|
||||
|
||||
// initialise this particular driver
|
||||
int hd_init_4bit (HD44780_functions * hd44780_functions, lcd_logical_driver * driver, char *args, unsigned int port);
|
||||
int hd_init_4bit (Driver *drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -17,31 +17,20 @@
|
||||
#include "hd44780-winamp.h"
|
||||
// add new connection type header files here
|
||||
|
||||
enum connectionType { HD_4bit, HD_8bit, HD_serialLpt, HD_winamp,
|
||||
// add new connection types here
|
||||
|
||||
HD_unknown
|
||||
};
|
||||
|
||||
static struct ConnectionMapping {
|
||||
enum connectionType type;
|
||||
char *connectionTypeStr;
|
||||
int (*init_fn) (HD44780_functions * hd44780_functions, lcd_logical_driver * driver, char *args, unsigned int port);
|
||||
const char *helpMsg;
|
||||
} connectionMapping[] = {
|
||||
static const ConnectionMapping connectionMapping[] = {
|
||||
// connectionType enumerator
|
||||
// string to identify connection on command line
|
||||
// your initialisation function
|
||||
// help string for your particular connection
|
||||
{
|
||||
HD_4bit, "4bit", hd_init_4bit, "\t-e\t--extended\tEnable three or more displays\n"}, {
|
||||
HD_8bit, "8bit", hd_init_ext8bit, "\tnone\n"}, {
|
||||
HD_serialLpt, "serialLpt", hd_init_serialLpt, "\tnone\n"}, {
|
||||
HD_winamp, "winamp", hd_init_winamp, "\t-e\t--extended\tEnable three or more displays\n"},
|
||||
"4bit", hd_init_4bit, "\tnone\n"}, {
|
||||
"8bit", hd_init_ext8bit, "\tnone\n"}, {
|
||||
"serialLpt", hd_init_serialLpt, "\tnone\n"}, {
|
||||
"winamp", hd_init_winamp, "\tnone\n"},
|
||||
// add new connection types and their string specifier here
|
||||
// default, end of structure element (do not delete)
|
||||
{
|
||||
HD_unknown, "", NULL, ""}
|
||||
NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
*/
|
||||
|
||||
#include "hd44780-ext8bit.h"
|
||||
#include "hd44780.h"
|
||||
#include "hd44780-low.h"
|
||||
#include "lpt-port.h"
|
||||
|
||||
#include "port.h"
|
||||
@@ -67,57 +67,55 @@
|
||||
// HD44780_senddata
|
||||
// HD44780_readkeypad
|
||||
|
||||
void lcdtime_HD44780_senddata (unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lcdtime_HD44780_backlight (unsigned char state);
|
||||
unsigned char lcdtime_HD44780_readkeypad (unsigned int YData);
|
||||
void lcdtime_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lcdtime_HD44780_backlight (PrivateData *p, unsigned char state);
|
||||
unsigned char lcdtime_HD44780_readkeypad (PrivateData *p, unsigned int YData);
|
||||
|
||||
#define RS STRB
|
||||
#define RW LF
|
||||
#define EN1 INIT
|
||||
#define BL SEL
|
||||
|
||||
static unsigned int lptPort;
|
||||
static char stuckinputs = 0; // if an input line is stuck, it will be ignored
|
||||
static char backlight_bit = 0;
|
||||
|
||||
static int semid;
|
||||
|
||||
// initialise the driver
|
||||
int
|
||||
hd_init_ext8bit (HD44780_functions * hd44780_functions, lcd_logical_driver * driver, char *args, unsigned int port)
|
||||
hd_init_ext8bit (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData*) drvthis->private_data;
|
||||
HD44780_functions *hd44780_functions = p->hd44780_functions;
|
||||
|
||||
semid = sem_get ();
|
||||
|
||||
// Reserve the port registers
|
||||
lptPort = port;
|
||||
port_access(lptPort);
|
||||
port_access(lptPort+1);
|
||||
port_access(lptPort+2);
|
||||
port_access(p->port);
|
||||
port_access(p->port+1);
|
||||
port_access(p->port+2);
|
||||
|
||||
hd44780_functions->senddata = lcdtime_HD44780_senddata;
|
||||
hd44780_functions->backlight = lcdtime_HD44780_backlight;
|
||||
hd44780_functions->readkeypad = lcdtime_HD44780_readkeypad;
|
||||
|
||||
// setup the lcd in 8 bit mode
|
||||
hd44780_functions->senddata (0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||
hd44780_functions->uPause (4100);
|
||||
hd44780_functions->senddata (0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||
hd44780_functions->uPause (100);
|
||||
hd44780_functions->senddata (0, RS_INSTR, FUNCSET | IF_8BIT | TWOLINE | SMALLCHAR);
|
||||
hd44780_functions->uPause (40);
|
||||
hd44780_functions->senddata (p, 0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||
hd44780_functions->uPause (p, 4100);
|
||||
hd44780_functions->senddata (p, 0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||
hd44780_functions->uPause (p, 100);
|
||||
hd44780_functions->senddata (p, 0, RS_INSTR, FUNCSET | IF_8BIT | TWOLINE | SMALLCHAR);
|
||||
hd44780_functions->uPause (p, 40);
|
||||
|
||||
common_init ();
|
||||
common_init (p);
|
||||
|
||||
if (have_keypad) {
|
||||
if (p->have_keypad) {
|
||||
// Remember which input lines are stuck
|
||||
stuckinputs = lcdtime_HD44780_readkeypad (0);
|
||||
p->stuckinputs = lcdtime_HD44780_readkeypad (p, 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// lcdtime_HD44780_senddata
|
||||
void
|
||||
lcdtime_HD44780_senddata (unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
lcdtime_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
{
|
||||
unsigned char enableLines = 0, portControl;
|
||||
|
||||
@@ -129,28 +127,28 @@ lcdtime_HD44780_senddata (unsigned char displayID, unsigned char flags, unsigned
|
||||
else //if (iflags == RS_DATA)
|
||||
portControl = RS;
|
||||
|
||||
portControl |= backlight_bit;
|
||||
portControl |= p->backlight_bit;
|
||||
|
||||
sem_wait (semid);
|
||||
port_out (lptPort + 2, portControl ^ OUTMASK);
|
||||
port_out (lptPort, ch);
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
port_out (lptPort + 2, (enableLines|portControl) ^ OUTMASK);
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
port_out (lptPort + 2, portControl ^ OUTMASK);
|
||||
port_out (p->port + 2, portControl ^ OUTMASK);
|
||||
port_out (p->port, ch);
|
||||
if( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port + 2, (enableLines|portControl) ^ OUTMASK);
|
||||
if( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port + 2, portControl ^ OUTMASK);
|
||||
sem_signal (semid);
|
||||
}
|
||||
|
||||
void lcdtime_HD44780_backlight (unsigned char state)
|
||||
void lcdtime_HD44780_backlight (PrivateData *p, unsigned char state)
|
||||
{
|
||||
backlight_bit = (state?0:SEL);
|
||||
p->backlight_bit = (state?0:SEL);
|
||||
|
||||
// Semaphores not needed because backlight will not go together with
|
||||
// the bacrgraph anyway...
|
||||
port_out (lptPort + 2, backlight_bit ^ OUTMASK);
|
||||
port_out (p->port + 2, p->backlight_bit ^ OUTMASK);
|
||||
}
|
||||
|
||||
unsigned char lcdtime_HD44780_readkeypad (unsigned int YData)
|
||||
unsigned char lcdtime_HD44780_readkeypad (PrivateData *p, unsigned int YData)
|
||||
{
|
||||
unsigned char readval;
|
||||
|
||||
@@ -158,19 +156,19 @@ unsigned char lcdtime_HD44780_readkeypad (unsigned int YData)
|
||||
|
||||
// 10 bits output or 8 bits if >=3 displays
|
||||
// Convert the positive logic to the negative logic on the LPT port
|
||||
port_out (lptPort, ~YData & 0x00FF );
|
||||
if (!extIF) {
|
||||
port_out (lptPort + 2, ( ((~YData & 0x0100) >> 8) | ((~YData & 0x0200) >> 6)) ^ OUTMASK);
|
||||
port_out (p->port, ~YData & 0x00FF );
|
||||
if (!p->extIF) {
|
||||
port_out (p->port + 2, ( ((~YData & 0x0100) >> 8) | ((~YData & 0x0200) >> 6)) ^ OUTMASK);
|
||||
}
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
if( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
|
||||
// Read inputs
|
||||
readval = ~ port_in (lptPort + 1) ^ INMASK;
|
||||
readval = ~ port_in (p->port + 1) ^ INMASK;
|
||||
|
||||
// Put port back into idle state for backlight
|
||||
port_out (lptPort, backlight_bit ^ OUTMASK);
|
||||
port_out (p->port, p->backlight_bit ^ OUTMASK);
|
||||
sem_signal (semid);
|
||||
|
||||
// And convert value back.
|
||||
return ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) ) & ~stuckinputs;
|
||||
return ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) ) & ~p->stuckinputs;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#ifndef HD_EXT8BIT_H
|
||||
#define HD_EXT8BIT_H
|
||||
|
||||
#include "lcd.h" /* for lcd_logical_driver */
|
||||
#include "hd44780-low.h" /* for HD44780_functions */
|
||||
#include "lcd.h" /* for Driver */
|
||||
|
||||
// initialise this particular driver
|
||||
int hd_init_ext8bit (HD44780_functions * hd44780_functions, lcd_logical_driver * driver, char *args, unsigned int port);
|
||||
int hd_init_ext8bit (Driver *driver);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,40 +6,124 @@
|
||||
|
||||
enum ifWidth { IF_4bit, IF_8bit };
|
||||
|
||||
//void common_init (enum ifWidth ifwidth);
|
||||
void common_init ();
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#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
|
||||
|
||||
|
||||
//struct hwDependentFns;
|
||||
|
||||
// Maximum sizes of the keypad
|
||||
// DO NOT CHANGE THESE 2 VALUES, unless you change the functions too
|
||||
#define KEYPAD_MAXX 5
|
||||
#define KEYPAD_MAXY 11
|
||||
|
||||
typedef struct ConnectionMapping {
|
||||
char *name;
|
||||
int (*init_fn) (Driver *drvthis);
|
||||
const char *helpMsg;
|
||||
} ConnectionMapping;
|
||||
|
||||
typedef struct driver_private_data {
|
||||
|
||||
unsigned int port;
|
||||
|
||||
int width, height;
|
||||
int cellwidth, cellheight;
|
||||
|
||||
// The framebuffer
|
||||
char *framebuf;
|
||||
|
||||
// For incremental updates store last lcd contents
|
||||
char *lcd_contents;
|
||||
|
||||
// Connection type data
|
||||
int connectiontype_index;
|
||||
struct hwDependentFns *hd44780_functions;
|
||||
|
||||
// spanList[line number] = display line number is in
|
||||
int *spanList;
|
||||
int numLines;
|
||||
|
||||
// dispVOffset is a cumulative sized array of line numbers for each display.
|
||||
// use this to determine the vertical positioning on a given display
|
||||
int *dispVOffset;
|
||||
int numDisplays;
|
||||
|
||||
// dispSizes is the vertical size of each display. This is the same as the
|
||||
// input span list but is kept to save some cpu cycles.
|
||||
int *dispSizes;
|
||||
|
||||
// Keypad, backlight extended interface and delay options
|
||||
char have_keypad; // off by default
|
||||
char have_backlight; // off by default
|
||||
char extIF; // off by default
|
||||
int delayMult; // Delay multiplier for slow displays
|
||||
char delayBus; // Delay if the computer can send data too fast over
|
||||
// its bus to LPT port
|
||||
|
||||
// keyMapDirect contains an array of the ascii-codes that should be generated
|
||||
// when a directly connected key is pressed (not in matrix).
|
||||
char *keyMapDirect[KEYPAD_MAXX];
|
||||
|
||||
// keyMapMatrix contrains an array with arrays of the ascii-codes that should be generated
|
||||
// when a key in the matrix is pressed.
|
||||
char *keyMapMatrix[KEYPAD_MAXY][KEYPAD_MAXX];
|
||||
|
||||
char pressed_key;
|
||||
int pressed_key_repetitions;
|
||||
struct timeval pressed_key_time;
|
||||
|
||||
int stuckinputs;
|
||||
|
||||
int backlight_bit;
|
||||
|
||||
} PrivateData;
|
||||
|
||||
// Structures holding pointers to HD44780 specific functions
|
||||
typedef struct hwDependentFns {
|
||||
// microsec pauses
|
||||
void (*uPause) (int microSecondsTenths);
|
||||
void (*uPause) (PrivateData *p, int usecs);
|
||||
|
||||
// Senddata to the LCD
|
||||
// dispID - display to send data to (0 = all displays)
|
||||
// flags - data or instruction command (RS_DATA | RS_INSTR)
|
||||
// ch - character to display or instruction value
|
||||
void (*senddata) (unsigned char dispID, unsigned char flags, unsigned char ch);
|
||||
void (*senddata) (PrivateData *p, unsigned char dispID, unsigned char flags, unsigned char ch);
|
||||
|
||||
// Switch the backlight on or off
|
||||
// state - to be or not to be on
|
||||
void (*backlight) (unsigned char state);
|
||||
void (*backlight) (PrivateData *p, unsigned char state);
|
||||
|
||||
// Read the keypad
|
||||
// Ydata - the up to 11 bits that should be put on the Y side of the matrix
|
||||
// return - the up to 5 bits that are read out on the X side of the matrix
|
||||
unsigned char (*readkeypad) (unsigned int Ydata);
|
||||
unsigned char (*readkeypad) (PrivateData *p, unsigned int Ydata);
|
||||
|
||||
// Scan the keypad and return a scancode.
|
||||
// The code is the Yvalue in the high nibble and the Xvalue in the low nibble.
|
||||
// A subdriver should do only one of two things:
|
||||
// - set readkeypad; or
|
||||
// - override scankeypad.
|
||||
unsigned char (*scankeypad) ();
|
||||
unsigned char (*scankeypad) (PrivateData *p);
|
||||
|
||||
|
||||
} HD44780_functions; /* for want of a better name :-) */
|
||||
|
||||
extern HD44780_functions *hd44780_functions;
|
||||
|
||||
void common_init (PrivateData *p);
|
||||
|
||||
|
||||
// commands for senddata
|
||||
#define RS_DATA 0x00
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
*/
|
||||
|
||||
#include "hd44780-serialLpt.h"
|
||||
#include "hd44780.h"
|
||||
#include "hd44780-low.h"
|
||||
#include "lpt-port.h"
|
||||
|
||||
#include "port.h"
|
||||
@@ -60,12 +60,12 @@
|
||||
#include <errno.h>
|
||||
|
||||
// Hardware specific functions
|
||||
void lcdserLpt_HD44780_senddata (unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lcdserLpt_HD44780_backlight (unsigned char state);
|
||||
void lcdserLpt_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lcdserLpt_HD44780_backlight (PrivateData *p, unsigned char state);
|
||||
|
||||
unsigned char lcdserLpt_HD44780_scankeypad ();
|
||||
void rawshift (unsigned char r);
|
||||
void shiftreg (unsigned char displayID, unsigned char r);
|
||||
unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p);
|
||||
void rawshift (PrivateData *p, unsigned char r);
|
||||
void shiftreg (PrivateData *p, unsigned char displayID, unsigned char r);
|
||||
|
||||
#define RS 32
|
||||
#define LCDDATA 8
|
||||
@@ -73,50 +73,46 @@ void shiftreg (unsigned char displayID, unsigned char r);
|
||||
#define EN1 4
|
||||
#define EN2 32
|
||||
|
||||
static unsigned int lptPort;
|
||||
static char backlight_bit = 0;
|
||||
|
||||
// Initialisation
|
||||
int
|
||||
hd_init_serialLpt (HD44780_functions * hd44780_functions, lcd_logical_driver * driver, char *args, unsigned int port)
|
||||
hd_init_serialLpt (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData*) drvthis->private_data;
|
||||
HD44780_functions *hd44780_functions = p->hd44780_functions;
|
||||
unsigned char enableLines = EN1 | EN2;
|
||||
|
||||
// Reserve the port registers
|
||||
lptPort = port;
|
||||
port_access(lptPort);
|
||||
port_access(lptPort+1);
|
||||
port_access(lptPort+2);
|
||||
port_access(p->port);
|
||||
port_access(p->port+1);
|
||||
port_access(p->port+2);
|
||||
|
||||
hd44780_functions->senddata = lcdserLpt_HD44780_senddata;
|
||||
hd44780_functions->backlight = lcdserLpt_HD44780_backlight;
|
||||
hd44780_functions->scankeypad = lcdserLpt_HD44780_scankeypad;
|
||||
|
||||
// setup the lcd in 4 bit mode
|
||||
shiftreg (enableLines, 3);
|
||||
hd44780_functions->uPause (15000);
|
||||
shiftreg (p, enableLines, 3);
|
||||
hd44780_functions->uPause (p, 15000);
|
||||
|
||||
shiftreg (enableLines, 3);
|
||||
hd44780_functions->uPause (5000);
|
||||
shiftreg (p, enableLines, 3);
|
||||
hd44780_functions->uPause (p, 5000);
|
||||
|
||||
shiftreg (enableLines, 3);
|
||||
hd44780_functions->uPause (100);
|
||||
shiftreg (p, enableLines, 3);
|
||||
hd44780_functions->uPause (p, 150);
|
||||
|
||||
shiftreg (enableLines, 3);
|
||||
hd44780_functions->uPause (100);
|
||||
shiftreg (p, enableLines, 2);
|
||||
hd44780_functions->uPause (p, 100);
|
||||
|
||||
shiftreg (enableLines, 2);
|
||||
hd44780_functions->uPause (100);
|
||||
hd44780_functions->senddata (p, 0, RS_INSTR, FUNCSET | IF_4BIT | TWOLINE | SMALLCHAR);
|
||||
hd44780_functions->uPause (p, 40);
|
||||
|
||||
hd44780_functions->senddata (0, RS_INSTR, FUNCSET | IF_4BIT | TWOLINE | SMALLCHAR);
|
||||
|
||||
common_init ();
|
||||
common_init (p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
lcdserLpt_HD44780_senddata (unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
lcdserLpt_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
{
|
||||
unsigned char enableLines;
|
||||
unsigned char portControl = 0;
|
||||
@@ -134,24 +130,24 @@ lcdserLpt_HD44780_senddata (unsigned char displayID, unsigned char flags, unsign
|
||||
else
|
||||
portControl = 0;
|
||||
|
||||
shiftreg (enableLines, portControl | h);
|
||||
shiftreg (enableLines, portControl | l);
|
||||
shiftreg (p, enableLines, portControl | h);
|
||||
shiftreg (p, enableLines, portControl | l);
|
||||
|
||||
// Restore line status for backlight
|
||||
port_out (lptPort, backlight_bit );
|
||||
port_out (p->port, p->backlight_bit );
|
||||
}
|
||||
|
||||
void
|
||||
lcdserLpt_HD44780_backlight (unsigned char state)
|
||||
lcdserLpt_HD44780_backlight (PrivateData *p, unsigned char state)
|
||||
{
|
||||
// Store new state
|
||||
backlight_bit = (state?LCDDATA:0);
|
||||
p->backlight_bit = (state?LCDDATA:0);
|
||||
|
||||
// Set line status for backlight
|
||||
port_out (lptPort, backlight_bit );
|
||||
port_out (p->port, p->backlight_bit );
|
||||
}
|
||||
|
||||
unsigned char lcdserLpt_HD44780_scankeypad ()
|
||||
unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
|
||||
{
|
||||
// Unfortunately just bit shifting does not work with the 2-wire version...
|
||||
|
||||
@@ -162,36 +158,41 @@ unsigned char lcdserLpt_HD44780_scankeypad ()
|
||||
int i;
|
||||
unsigned int scancode = 0;
|
||||
|
||||
// While scanning the keypad, the 2-wire version executes the 0xFF
|
||||
// command. This command sets the cursor position, so it's harmless.
|
||||
// While scanning the keypad, the 2-wire version will place the
|
||||
// character 0xFF on the current cursor position. Therefor we fisrt
|
||||
// set the cursor position to -1, so it's harmless.
|
||||
// I could not prevent this, while staying compatible with both
|
||||
// wiring versions.
|
||||
|
||||
// Clear the shiftregister, needed for 3-wire version
|
||||
rawshift(0);
|
||||
hd44780_functions->uPause (2);
|
||||
rawshift(p, 0);
|
||||
p->hd44780_functions->uPause (p, 1);
|
||||
|
||||
readval = ~ port_in (lptPort + 1) ^ INMASK;
|
||||
readval = ~ port_in (p->port + 1) ^ INMASK;
|
||||
inputs_zero = ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) );
|
||||
|
||||
if( inputs_zero == 0 ) {
|
||||
// No keys were pressed
|
||||
|
||||
// Restore line status for backlight.
|
||||
port_out (lptPort, backlight_bit );
|
||||
port_out (p->port, p->backlight_bit );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Set cursor position to -1
|
||||
p->hd44780_functions->senddata (p, 0, RS_INSTR, POSITION | 127);
|
||||
p->hd44780_functions->uPause (p, 40);
|
||||
|
||||
// Scan the keypad while sending the first half of the command (high nibble)
|
||||
for (i = 7; i >= 0; i--) { /* MSB first */
|
||||
port_out (lptPort, LCDDATA); /*set up data */
|
||||
port_out (lptPort, LCDDATA | LCDCLOCK); /*rising edge of clock */
|
||||
port_out (p->port, LCDDATA); /*set up data */
|
||||
port_out (p->port, LCDDATA | LCDCLOCK); /*rising edge of clock */
|
||||
|
||||
hd44780_functions->uPause (2);
|
||||
p->hd44780_functions->uPause (p, 2);
|
||||
|
||||
if( !scancode ) {
|
||||
// Read input line(s)
|
||||
readval = ~ port_in (lptPort + 1) ^ INMASK;
|
||||
readval = ~ port_in (p->port + 1) ^ INMASK;
|
||||
keybits = ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) );
|
||||
if( keybits != inputs_zero ) {
|
||||
shiftingbit = 1;
|
||||
@@ -207,40 +208,40 @@ unsigned char lcdserLpt_HD44780_scankeypad ()
|
||||
}
|
||||
|
||||
// Wait for 2-wire version to clear the latch...
|
||||
hd44780_functions->uPause (6);
|
||||
p->hd44780_functions->uPause (p, 6);
|
||||
|
||||
// And again for the second half of the command (low nibble).
|
||||
// Needed for 2-wire version.
|
||||
rawshift (0xFF);
|
||||
rawshift (p, 0xFF);
|
||||
|
||||
// Wait for 2-wire version to clear the latch...
|
||||
hd44780_functions->uPause (6);
|
||||
p->hd44780_functions->uPause (p, 6);
|
||||
|
||||
// Restore line status for backlight.
|
||||
port_out (lptPort, backlight_bit );
|
||||
port_out (p->port, p->backlight_bit );
|
||||
|
||||
return scancode;
|
||||
}
|
||||
|
||||
/* this function sends r out onto the shift register */
|
||||
void
|
||||
rawshift (unsigned char r)
|
||||
rawshift (PrivateData *p, unsigned char r)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 7; i >= 0; i--) { /* MSB first */
|
||||
port_out (lptPort, ((r >> i) & 1) * LCDDATA); /*set up data */
|
||||
port_out (lptPort, (((r >> i) & 1) * LCDDATA) | LCDCLOCK); /*rising edge of clock */
|
||||
port_out (p->port, ((r >> i) & 1) * LCDDATA); /*set up data */
|
||||
port_out (p->port, (((r >> i) & 1) * LCDDATA) | LCDCLOCK); /*rising edge of clock */
|
||||
}
|
||||
}
|
||||
|
||||
// enableLines = value on parallel port to toggle the correct display
|
||||
void
|
||||
shiftreg (unsigned char enableLines, unsigned char r)
|
||||
shiftreg (PrivateData *p, unsigned char enableLines, unsigned char r)
|
||||
{
|
||||
rawshift (r | 0x80); // highest bit always set to 1 for Clear for 2-wire version
|
||||
port_out (lptPort, enableLines); // latch it, to correct display
|
||||
hd44780_functions->uPause (1);
|
||||
port_out (lptPort, 0); // for 3-wire version
|
||||
hd44780_functions->uPause (5); // wait for 2-wire version to clear the latch...
|
||||
rawshift (p, r | 0x80); // highest bit always set to 1 for Clear for 2-wire version
|
||||
port_out (p->port, enableLines); // latch it, to correct display
|
||||
p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, 0); // for 3-wire version
|
||||
p->hd44780_functions->uPause (p, 5); // wait for 2-wire version to clear the latch...
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#ifndef HD_SERIALLPT_H
|
||||
#define HD_SERIALLPT_H
|
||||
|
||||
#include "lcd.h" /* for lcd_logical_driver */
|
||||
#include "hd44780-low.h" /* for HD44780_functions */
|
||||
#include "lcd.h" /* for Driver */
|
||||
|
||||
// initialise this particular driver
|
||||
int hd_init_serialLpt (HD44780_functions * hd44780_functions, lcd_logical_driver * driver, char *args, unsigned int port);
|
||||
int hd_init_serialLpt (Driver *drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
*/
|
||||
|
||||
#include "hd44780-winamp.h"
|
||||
#include "hd44780.h"
|
||||
#include "hd44780-low.h"
|
||||
#include "lpt-port.h"
|
||||
|
||||
#include "port.h"
|
||||
@@ -74,9 +74,9 @@
|
||||
// HD44780_senddata
|
||||
// HD44780_readkeypad
|
||||
|
||||
void lcdwinamp_HD44780_senddata (unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lcdwinamp_HD44780_backlight (unsigned char state);
|
||||
unsigned char lcdwinamp_HD44780_readkeypad (unsigned int YData);
|
||||
void lcdwinamp_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lcdwinamp_HD44780_backlight (PrivateData *p, unsigned char state);
|
||||
unsigned char lcdwinamp_HD44780_readkeypad (PrivateData *p, unsigned int YData);
|
||||
|
||||
#define EN1 STRB
|
||||
#define EN2 SEL
|
||||
@@ -85,41 +85,45 @@ unsigned char lcdwinamp_HD44780_readkeypad (unsigned int YData);
|
||||
#define RS INIT
|
||||
#define BL SEL
|
||||
|
||||
static unsigned char EnMask[] = { EN1, EN2, EN3 };
|
||||
|
||||
static unsigned int lptPort;
|
||||
static char stuckinputs = 0; // if an input line is stuck, it will be ignored
|
||||
static char backlight_bit = 0; // default to low to enable two displays
|
||||
static const unsigned char EnMask[] = { EN1, EN2, EN3 };
|
||||
|
||||
// initialise the driver
|
||||
int
|
||||
hd_init_winamp (HD44780_functions * hd44780_functions, lcd_logical_driver * driver, char *args, unsigned int port)
|
||||
hd_init_winamp (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData*) drvthis->private_data;
|
||||
HD44780_functions *hd44780_functions = p->hd44780_functions;
|
||||
|
||||
// Reserve the port registers
|
||||
lptPort = port;
|
||||
port_access(lptPort);
|
||||
port_access(lptPort+1);
|
||||
port_access(lptPort+2);
|
||||
port_access(p->port);
|
||||
port_access(p->port+1);
|
||||
port_access(p->port+2);
|
||||
|
||||
hd44780_functions->senddata = lcdwinamp_HD44780_senddata;
|
||||
hd44780_functions->backlight = lcdwinamp_HD44780_backlight;
|
||||
hd44780_functions->readkeypad = lcdwinamp_HD44780_readkeypad;
|
||||
|
||||
// setup the lcd in 8 bit mode
|
||||
hd44780_functions->senddata (0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||
hd44780_functions->uPause (4100);
|
||||
hd44780_functions->senddata (0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||
hd44780_functions->uPause (100);
|
||||
hd44780_functions->senddata (0, RS_INSTR, FUNCSET | IF_8BIT | TWOLINE | SMALLCHAR);
|
||||
hd44780_functions->uPause (40);
|
||||
hd44780_functions->senddata (p, 0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||
hd44780_functions->uPause (p, 4100);
|
||||
hd44780_functions->senddata (p, 0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||
hd44780_functions->uPause (p, 100);
|
||||
hd44780_functions->senddata (p, 0, RS_INSTR, FUNCSET | IF_8BIT | TWOLINE | SMALLCHAR);
|
||||
hd44780_functions->uPause (p, 40);
|
||||
|
||||
common_init (p);
|
||||
|
||||
if (p->have_keypad) {
|
||||
// Remember which input lines are stuck
|
||||
p->stuckinputs = lcdwinamp_HD44780_readkeypad (p, 0);
|
||||
}
|
||||
|
||||
common_init ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// lcdwinamp_HD44780_senddata
|
||||
void
|
||||
lcdwinamp_HD44780_senddata (unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
lcdwinamp_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
{
|
||||
unsigned char enableLines = 0, portControl;
|
||||
|
||||
@@ -128,25 +132,25 @@ lcdwinamp_HD44780_senddata (unsigned char displayID, unsigned char flags, unsign
|
||||
else
|
||||
portControl = 0;
|
||||
|
||||
portControl |= backlight_bit;
|
||||
portControl |= p->backlight_bit;
|
||||
|
||||
if (displayID == 0)
|
||||
enableLines = EnMask[0] | EnMask[1] | ((extIF) ? EnMask[2] : 0);
|
||||
enableLines = EnMask[0] | EnMask[1] | ((p->extIF) ? EnMask[2] : 0);
|
||||
else
|
||||
enableLines = EnMask[displayID - 1];
|
||||
|
||||
// 40 nS setup time for RS valid to EN high, so set RS
|
||||
port_out (lptPort + 2, portControl ^ OUTMASK);
|
||||
port_out (p->port + 2, portControl ^ OUTMASK);
|
||||
|
||||
// Output the actual data
|
||||
port_out (lptPort, ch);
|
||||
port_out (p->port, ch);
|
||||
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
if( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
|
||||
// then set EN high
|
||||
port_out (lptPort + 2, (enableLines|portControl) ^ OUTMASK);
|
||||
port_out (p->port + 2, (enableLines|portControl) ^ OUTMASK);
|
||||
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
if( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
|
||||
// 80 nS setup from valid data to EN low will be met without any delay
|
||||
// unless you are running a REALLY FAST ISA bus (like 75 MHZ!)
|
||||
@@ -155,34 +159,34 @@ lcdwinamp_HD44780_senddata (unsigned char displayID, unsigned char flags, unsign
|
||||
// ABOVE TEXT ignored now, using delays if delayBus is specified
|
||||
|
||||
// Set EN low and we're done...
|
||||
port_out (lptPort + 2, portControl ^ OUTMASK);
|
||||
port_out (p->port + 2, portControl ^ OUTMASK);
|
||||
|
||||
// 10 nS data hold time provided by the length of ISA write for EN
|
||||
}
|
||||
|
||||
void lcdwinamp_HD44780_backlight (unsigned char state)
|
||||
void lcdwinamp_HD44780_backlight (PrivateData *p, unsigned char state)
|
||||
{
|
||||
backlight_bit = (state?0:nSEL);
|
||||
p->backlight_bit = (state?0:nSEL);
|
||||
|
||||
port_out (lptPort + 2, backlight_bit ^ OUTMASK);
|
||||
port_out (p->port + 2, p->backlight_bit ^ OUTMASK);
|
||||
}
|
||||
|
||||
unsigned char lcdwinamp_HD44780_readkeypad (unsigned int YData)
|
||||
unsigned char lcdwinamp_HD44780_readkeypad (PrivateData *p, unsigned int YData)
|
||||
{
|
||||
unsigned char readval;
|
||||
|
||||
// 8 bits output
|
||||
// Convert the positive logic to the negative logic on the LPT port
|
||||
port_out (lptPort, ~YData & 0x00FF );
|
||||
port_out (p->port, ~YData & 0x00FF );
|
||||
|
||||
if( delayBus ) hd44780_functions->uPause (1);
|
||||
if( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
|
||||
// Read inputs
|
||||
readval = ~ port_in (lptPort + 1) ^ INMASK;
|
||||
readval = ~ port_in (p->port + 1) ^ INMASK;
|
||||
|
||||
// Set output back to idle state for backlight
|
||||
port_out (lptPort + 2, backlight_bit ^ OUTMASK );
|
||||
port_out (p->port + 2, p->backlight_bit ^ OUTMASK );
|
||||
|
||||
// And convert value back.
|
||||
return ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) ) & ~stuckinputs;
|
||||
return ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) ) & ~p->stuckinputs;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
#ifndef HD_WINAMP_H
|
||||
#define HD_WINAMP_H
|
||||
|
||||
#include "lcd.h" /* for lcd_logical_driver */
|
||||
#include "hd44780-low.h" /* for HD44780_functions */
|
||||
#include "lcd.h" /* for Driver */
|
||||
|
||||
// initialise this particular driver, args is probably not used but keep
|
||||
// for consistency
|
||||
int hd_init_winamp (HD44780_functions * hd44780_functions, lcd_logical_driver * driver, char *args, unsigned int port);
|
||||
// initialise this particular driver
|
||||
int hd_init_winamp (Driver *drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
+374
-327
File diff suppressed because it is too large
Load Diff
+22
-26
@@ -16,33 +16,29 @@
|
||||
#ifndef HD44780_H
|
||||
#define HD44780_H
|
||||
|
||||
// Maximum sizes of the keypad
|
||||
// DO NOT CHANGE THESE 2 VALUES, unless you change the functions too
|
||||
#define KEYPAD_MAXX 5
|
||||
#define KEYPAD_MAXY 11
|
||||
int HD44780_init (struct lcd_logical_driver *driver, char *args);
|
||||
MODULE_EXPORT void HD44780_close (Driver *drvthis);
|
||||
MODULE_EXPORT int HD44780_width (Driver *drvthis);
|
||||
MODULE_EXPORT int HD44780_height (Driver *drvthis);
|
||||
MODULE_EXPORT void HD44780_clear (Driver *drvthis);
|
||||
MODULE_EXPORT void HD44780_flush (Driver *drvthis);
|
||||
MODULE_EXPORT void HD44780_string (Driver *drvthis, int x, int y, char *s);
|
||||
MODULE_EXPORT void HD44780_chr (Driver *drvthis, int x, int y, char ch);
|
||||
|
||||
extern char have_keypad; // non-zero if the keypad code is activated
|
||||
extern char have_backlight; // non-zero if we can control the backlight
|
||||
extern char extIF; // non-zero if we should control > 2 LCDs
|
||||
extern char delayBus; // non-zero if axtra delays for the bus speed
|
||||
// should be inserted.
|
||||
MODULE_EXPORT void HD44780_vbar (Driver *drvthis, int x, int len);
|
||||
MODULE_EXPORT void HD44780_hbar (Driver *drvthis, int x, int y, int len);
|
||||
MODULE_EXPORT void HD44780_num (Driver *drvthis, int x, int num);
|
||||
MODULE_EXPORT void HD44780_heartbeat (Driver *drvthis, int type);
|
||||
MODULE_EXPORT void HD44780_icon (Driver *drvthis, int which, char dest);
|
||||
|
||||
int HD44780_init (struct lcd_logical_driver *driver, char *args);
|
||||
/* The following methods can all be hidden. They are used through function ptrs
|
||||
void HD44780_close();
|
||||
void HD44780_flush();
|
||||
void HD44780_flush_box(int lft, int top, int rgt, int bot);
|
||||
int HD44780_contrast(int contrast);
|
||||
void HD44780_backlight(int on);
|
||||
void HD44780_init_vbar();
|
||||
void HD44780_init_hbar();
|
||||
void HD44780_vbar(int x, int len);
|
||||
void HD44780_hbar(int x, int y, int len);
|
||||
void HD44780_init_num();
|
||||
void HD44780_num(int x, int num);
|
||||
void HD44780_set_char(int n, char *dat);
|
||||
void HD44780_icon(int which, char dest);
|
||||
void HD44780_draw_frame(char *dat);
|
||||
*/
|
||||
MODULE_EXPORT void HD44780_set_char (Driver *drvthis, int n, char *dat);
|
||||
|
||||
MODULE_EXPORT void HD44780_backlight (Driver *drvthis, int on);
|
||||
|
||||
MODULE_EXPORT char HD44780_getkey (Driver *drvthis);
|
||||
|
||||
MODULE_EXPORT void HD44780_init_vbar (Driver *drvthis);
|
||||
MODULE_EXPORT void HD44780_init_hbar (Driver *drvthis);
|
||||
MODULE_EXPORT void HD44780_init_num (Driver *drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
+38
-35
@@ -21,26 +21,25 @@
|
||||
#include <sys/errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <linux/joystick.h>
|
||||
#ifndef JSIOCGNAME
|
||||
#define JSIOCGNAME(len) _IOC(_IOC_READ, 'j', 0x13, len) /* get identifier string */
|
||||
#endif
|
||||
|
||||
#include "shared/debug.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "lcd.h"
|
||||
#include "joy.h"
|
||||
#include "report.h"
|
||||
#include "shared/str.h"
|
||||
|
||||
#define NAME_LENGTH 128
|
||||
#define JOY_DEFAULT_DEVICE "/dev/js0"
|
||||
|
||||
#include "lcd.h"
|
||||
#include "joy.h"
|
||||
|
||||
lcd_logical_driver *joy;
|
||||
|
||||
int fd;
|
||||
extern int debug_level;
|
||||
|
||||
struct js_event js;
|
||||
|
||||
@@ -49,25 +48,30 @@ char buttons = 2;
|
||||
int jsversion = 0x000800;
|
||||
char jsname[NAME_LENGTH] = "Unknown";
|
||||
|
||||
int *axis;
|
||||
int *button;
|
||||
int *axis = NULL;
|
||||
int *button = NULL;
|
||||
|
||||
// Configured for a Gravis Gamepad (2 axis, 4 button)
|
||||
char *axismap = "EFGHIJKLMNOPQRST";
|
||||
char *buttonmap = "BDACEFGHIJKLMNOP";
|
||||
|
||||
// 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 = "joy_";
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// init() should set up any device-specific stuff, and
|
||||
// point all the function pointers.
|
||||
int
|
||||
joy_init (struct lcd_logical_driver *driver, char *args)
|
||||
joy_init (Driver *drvthis, char *args)
|
||||
{
|
||||
char device[256];
|
||||
char *argv[64];
|
||||
int argc, i;
|
||||
|
||||
joy = driver;
|
||||
|
||||
strcpy (device, JOY_DEFAULT_DEVICE);
|
||||
|
||||
argc = get_args (argv, args, 64);
|
||||
@@ -101,8 +105,14 @@ joy_init (struct lcd_logical_driver *driver, char *args)
|
||||
|
||||
}
|
||||
|
||||
driver->getkey = joy_getkey;
|
||||
driver->close = joy_close;
|
||||
// Set variables for server
|
||||
drvthis->api_version = api_version;
|
||||
drvthis->stay_in_foreground = &stay_in_foreground;
|
||||
drvthis->supports_multiple = &supports_multiple;
|
||||
|
||||
// Set the functions the driver supports
|
||||
drvthis->getkey = joy_getkey;
|
||||
drvthis->close = joy_close;
|
||||
|
||||
if ((fd = open (device, O_RDONLY)) < 0)
|
||||
return -1;
|
||||
@@ -113,40 +123,33 @@ joy_init (struct lcd_logical_driver *driver, char *args)
|
||||
ioctl (fd, JSIOCGBUTTONS, &buttons);
|
||||
ioctl (fd, JSIOCGNAME (NAME_LENGTH), jsname);
|
||||
|
||||
if (debug_level > 2) {
|
||||
syslog(LOG_DEBUG, "Joystick (%s) has %d axes and %d buttons. Driver version is %d.%d.%d.\n",
|
||||
jsname, axes, buttons,
|
||||
jsversion >> 16, (jsversion >> 8) & 0xff, jsversion & 0xff);
|
||||
}
|
||||
report (RPT_NOTICE, "Joystick (%s) has %d axes and %d buttons. Driver version is %d.%d.%d.\n",
|
||||
jsname, axes, buttons,
|
||||
jsversion >> 16, (jsversion >> 8) & 0xff, jsversion & 0xff);
|
||||
|
||||
if ((axis = calloc (axes, sizeof (int))) == NULL) {
|
||||
syslog(LOG_ERR, "joystick: could not allocate memory for axes");
|
||||
report (RPT_ERR, "joystick: could not allocate memory for axes");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((button = calloc (buttons, sizeof (char))) == NULL) {
|
||||
syslog(LOG_ERR, "joystick: could not allocate memory for buttons");
|
||||
report (RPT_ERR, "joystick: could not allocate memory for buttons");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd; // 200 is arbitrary. (must be 1 or more)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
joy_close ()
|
||||
MODULE_EXPORT void
|
||||
joy_close (Driver *drvthis)
|
||||
{
|
||||
if (joy->framebuf != NULL)
|
||||
free (joy->framebuf);
|
||||
|
||||
close (fd);
|
||||
|
||||
joy->framebuf = NULL;
|
||||
|
||||
// Why do I have so much trouble getting memory freed without segfaults??
|
||||
// Use gdb and find out :) In preliminary testing, this seemed to work...
|
||||
|
||||
if (axis) free(axis);
|
||||
if (button) free(button);
|
||||
if(axis) free(axis);
|
||||
if(button) free(button);
|
||||
|
||||
}
|
||||
|
||||
@@ -155,8 +158,8 @@ joy_close ()
|
||||
//
|
||||
// Return 0 for "nothing available".
|
||||
//
|
||||
char
|
||||
joy_getkey ()
|
||||
MODULE_EXPORT char
|
||||
joy_getkey (Driver *drvthis)
|
||||
{
|
||||
int i;
|
||||
int err;
|
||||
@@ -165,7 +168,7 @@ joy_getkey ()
|
||||
return 0;
|
||||
} else
|
||||
if (err != sizeof (struct js_event)) {
|
||||
syslog(LOG_ERR, "error reading joystick input");
|
||||
report(RPT_ERR, "error reading joystick input");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#ifndef LCD_JOY_H
|
||||
#define LCD_JOY_H
|
||||
|
||||
extern lcd_logical_driver *joy;
|
||||
#include "lcd.h"
|
||||
|
||||
int joy_init (struct lcd_logical_driver *driver, char *args);
|
||||
void joy_close ();
|
||||
char joy_getkey ();
|
||||
int joy_init (Driver *drvthis, char *args);
|
||||
MODULE_EXPORT void joy_close (Driver *drvthis);
|
||||
|
||||
MODULE_EXPORT char joy_getkey (Driver *drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
+144
-119
@@ -26,18 +26,17 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NCURSES_H
|
||||
# include <ncurses.h>
|
||||
#else
|
||||
# include <curses.h>
|
||||
#endif
|
||||
//#ifdef HAVE_NCURSES_H
|
||||
//# include <ncurses.h>
|
||||
//#else
|
||||
//# include <curses.h>
|
||||
//#endif
|
||||
|
||||
#include "shared/str.h"
|
||||
#include "shared/debug.h"
|
||||
#include "lcd.h"
|
||||
#include "lb216.h"
|
||||
#include "drv_base.h"
|
||||
#include "render.h"
|
||||
#include "shared/str.h"
|
||||
#include "report.h"
|
||||
//#include "drv_base.h"
|
||||
|
||||
static int custom=0;
|
||||
typedef enum {
|
||||
@@ -47,20 +46,30 @@ typedef enum {
|
||||
beat = 8 } custom_type;
|
||||
|
||||
|
||||
|
||||
static int fd;
|
||||
static char *framebuf = NULL;
|
||||
static int width = LCD_DEFAULT_WIDTH;
|
||||
static int height = LCD_DEFAULT_HEIGHT;
|
||||
static int cellwidth = LCD_DEFAULT_CELLWIDTH;
|
||||
static int cellheight = LCD_DEFAULT_CELLHEIGHT;
|
||||
|
||||
static void LB216_hidecursor();
|
||||
static void LB216_reboot();
|
||||
|
||||
// TODO: Get rid of this variable?
|
||||
lcd_logical_driver *LB216;
|
||||
// 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 = "LB216_";
|
||||
|
||||
|
||||
// TODO: Get the frame buffers working right
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Opens com port and sets baud correctly...
|
||||
//
|
||||
int LB216_init(lcd_logical_driver *driver, char *args)
|
||||
int
|
||||
LB216_init(Driver * drvthis, char *args)
|
||||
{
|
||||
char *argv[64];
|
||||
int argc;
|
||||
@@ -71,8 +80,8 @@ int LB216_init(lcd_logical_driver *driver, char *args)
|
||||
|
||||
char device[256] = "/dev/lcd";
|
||||
int speed=B9600;
|
||||
int backlight_brightness = 255;
|
||||
|
||||
LB216 = driver;
|
||||
|
||||
//debug("LB216_init: Args(all): %s\n", args);
|
||||
|
||||
@@ -153,6 +162,7 @@ int LB216_init(lcd_logical_driver *driver, char *args)
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Set up io port correctly, and open it...
|
||||
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
if (fd == -1)
|
||||
@@ -184,12 +194,11 @@ int LB216_init(lcd_logical_driver *driver, char *args)
|
||||
// Do it...
|
||||
tcsetattr(fd, TCSANOW, &portset);
|
||||
|
||||
|
||||
// Make sure the frame buffer is there...
|
||||
if (!LB216->framebuf)
|
||||
LB216->framebuf = (unsigned char *)
|
||||
malloc (LB216->wid * LB216->hgt);
|
||||
memset (LB216->framebuf, ' ', LB216->wid * LB216->hgt);
|
||||
if (framebuf)
|
||||
framebuf = (unsigned char *)
|
||||
malloc (width * height);
|
||||
memset (framebuf, ' ', width * height);
|
||||
|
||||
// Set display-specific stuff..
|
||||
if(reboot)
|
||||
@@ -200,36 +209,34 @@ int LB216_init(lcd_logical_driver *driver, char *args)
|
||||
}
|
||||
sleep(1);
|
||||
LB216_hidecursor();
|
||||
LB216_backlight(backlight_brightness);
|
||||
LB216_backlight(drvthis, backlight_brightness);
|
||||
|
||||
// Set the functions the driver supports...
|
||||
// Set variables for server
|
||||
drvthis->api_version = api_version;
|
||||
drvthis->stay_in_foreground = &stay_in_foreground;
|
||||
drvthis->supports_multiple = &supports_multiple;
|
||||
|
||||
driver->clear = LB216_clear;
|
||||
driver->string = LB216_string;
|
||||
driver->chr = LB216_chr;
|
||||
driver->vbar = LB216_vbar;
|
||||
driver->init_vbar = LB216_init_vbar;
|
||||
driver->hbar = LB216_hbar;
|
||||
driver->init_hbar = LB216_init_hbar;
|
||||
//driver->num = NULL;
|
||||
//driver->init_num = NULL;
|
||||
// Set the functions the driver supports
|
||||
drvthis->clear = LB216_clear;
|
||||
drvthis->string = LB216_string;
|
||||
drvthis->chr = LB216_chr;
|
||||
drvthis->old_vbar = LB216_vbar;
|
||||
drvthis->init_vbar = LB216_init_vbar;
|
||||
drvthis->old_hbar = LB216_hbar;
|
||||
drvthis->init_hbar = LB216_init_hbar;
|
||||
//drvthis->num = NULL;
|
||||
//drvthis->init_num = NULL;
|
||||
|
||||
driver->init = LB216_init;
|
||||
driver->close = LB216_close;
|
||||
driver->flush = LB216_flush;
|
||||
//driver->flush_box = NULL;
|
||||
//driver->contrast = NULL;
|
||||
driver->backlight = LB216_backlight;
|
||||
driver->set_char = LB216_set_char;
|
||||
driver->icon = LB216_icon;
|
||||
driver->draw_frame = LB216_draw_frame;
|
||||
drvthis->init = LB216_init;
|
||||
drvthis->close = LB216_close;
|
||||
drvthis->width = LB216_width;
|
||||
drvthis->height = LB216_height;
|
||||
drvthis->flush = LB216_flush;
|
||||
drvthis->backlight = LB216_backlight;
|
||||
drvthis->set_char = LB216_set_char;
|
||||
drvthis->old_icon = LB216_icon;
|
||||
|
||||
LB216->cellwid = 5;
|
||||
LB216->cellhgt = 8;
|
||||
|
||||
debug("LB216: foo!\n");
|
||||
|
||||
return fd;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -237,28 +244,66 @@ int LB216_init(lcd_logical_driver *driver, char *args)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clean-up
|
||||
//
|
||||
void LB216_close()
|
||||
MODULE_EXPORT void
|
||||
LB216_close(Driver * drvthis)
|
||||
{
|
||||
close (fd);
|
||||
|
||||
if(LB216->framebuf) free(LB216->framebuf);
|
||||
if(framebuf) free(framebuf);
|
||||
framebuf = NULL;
|
||||
}
|
||||
|
||||
LB216->framebuf = NULL;
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display width
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
LB216_width (Driver *drvthis)
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display height
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
LB216_height (Driver *drvthis)
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clears the LCD screen
|
||||
//
|
||||
void
|
||||
LB216_clear ()
|
||||
MODULE_EXPORT void
|
||||
LB216_clear (Driver * drvthis)
|
||||
{
|
||||
memset (LB216->framebuf, ' ', LB216->wid * LB216->hgt);
|
||||
|
||||
memset (framebuf, ' ', width * height);
|
||||
}
|
||||
|
||||
void LB216_flush()
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Flushes the framebuffer to the LCD
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
LB216_flush(Driver * drvthis)
|
||||
{
|
||||
LB216_draw_frame(LB216->framebuf);
|
||||
char out[LCD_MAX_WIDTH * LCD_MAX_HEIGHT];
|
||||
int i,j;
|
||||
|
||||
snprintf (out, sizeof(out), "%c%c", 254,80);
|
||||
write(fd, out, 2);
|
||||
|
||||
for(j=0; j<height; j++) {
|
||||
if (j>=2) {
|
||||
snprintf (out, sizeof(out),"%c%c",254,148+(64*(j-2)));
|
||||
} else {
|
||||
snprintf (out, sizeof(out),"%c%c",254,128+(64*(j)));
|
||||
}
|
||||
write(fd, out, 2);
|
||||
for(i=0; i<width; i++) {
|
||||
write(fd, framebuf + i+(j*width), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -267,13 +312,14 @@ void LB216_flush()
|
||||
// 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).
|
||||
//
|
||||
void LB216_chr(int x, int y, char c)
|
||||
MODULE_EXPORT void
|
||||
LB216_chr(Driver * drvthis, int x, int y, char c)
|
||||
{
|
||||
//y--;
|
||||
// x--;
|
||||
|
||||
//if(c < 32 && c >= 0) c += 128;
|
||||
// LB216->framebuf[(y*LB216->wid) + x] = c;
|
||||
// framebuf[(y*width) + x] = c;
|
||||
|
||||
// char chr[1];
|
||||
// snprintf (chr, sizeof(chr), "%c", c);
|
||||
@@ -282,7 +328,7 @@ void LB216_chr(int x, int y, char c)
|
||||
char chr[2];
|
||||
chr[0] = c;
|
||||
chr[1] = 0;
|
||||
LB216_string (x, y, chr);
|
||||
LB216_string (drvthis, x, y, chr);
|
||||
}
|
||||
|
||||
|
||||
@@ -290,7 +336,8 @@ void LB216_chr(int x, int y, char c)
|
||||
// Sets the backlight on or off -- can be done quickly for
|
||||
// an intermediate brightness...
|
||||
//
|
||||
void LB216_backlight(int on)
|
||||
MODULE_EXPORT void
|
||||
LB216_backlight(Driver * drvthis, int on)
|
||||
{
|
||||
char out[4];
|
||||
if(on)
|
||||
@@ -326,36 +373,8 @@ static void LB216_reboot()
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Blasts a single frame onscreen, to the lcd...
|
||||
//
|
||||
// Input is a character array, sized LB216->wid*LB216->hgt
|
||||
//
|
||||
void LB216_draw_frame(char *dat)
|
||||
{
|
||||
char out[LCD_MAX_WIDTH * LCD_MAX_HEIGHT];
|
||||
int i,j;
|
||||
|
||||
if(!dat) return;
|
||||
|
||||
snprintf (out, sizeof(out), "%c%c", 254,80);
|
||||
write(fd, out, 2);
|
||||
|
||||
for(j=0; j<LB216->hgt; j++) {
|
||||
if (j>=2) {
|
||||
snprintf (out, sizeof(out),"%c%c",254,148+(64*(j-2)));
|
||||
} else {
|
||||
snprintf (out, sizeof(out),"%c%c",254,128+(64*(j)));
|
||||
}
|
||||
write(fd, out, 2);
|
||||
for(i=0; i<LB216->wid; i++) {
|
||||
snprintf (out, sizeof(out),"%c",dat[i+(j*LB216->wid)]);
|
||||
write(fd, out, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LB216_string (int x, int y, char string[])
|
||||
MODULE_EXPORT void
|
||||
LB216_string (Driver * drvthis, int x, int y, char string[])
|
||||
{
|
||||
int i;
|
||||
char c;
|
||||
@@ -369,7 +388,7 @@ void LB216_string (int x, int y, char string[])
|
||||
{
|
||||
case '\254': c = '#'; break;
|
||||
}
|
||||
LB216->framebuf[(y*LB216->wid) + x+i] = c;
|
||||
framebuf[(y*width) + x+i] = c;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -377,7 +396,8 @@ void LB216_string (int x, int y, char string[])
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets up for vertical bars. Call before LB216->vbar()
|
||||
//
|
||||
void LB216_init_vbar()
|
||||
MODULE_EXPORT void
|
||||
LB216_init_vbar(Driver * drvthis)
|
||||
{
|
||||
char a[] = {
|
||||
0,0,0,0,0,
|
||||
@@ -451,13 +471,13 @@ void LB216_init_vbar()
|
||||
};
|
||||
|
||||
if(custom!=vbar) {
|
||||
LB216_set_char(1,a);
|
||||
LB216_set_char(2,b);
|
||||
LB216_set_char(3,c);
|
||||
LB216_set_char(4,d);
|
||||
LB216_set_char(5,e);
|
||||
LB216_set_char(6,f);
|
||||
LB216_set_char(7,g);
|
||||
LB216_set_char(drvthis, 1,a);
|
||||
LB216_set_char(drvthis, 2,b);
|
||||
LB216_set_char(drvthis, 3,c);
|
||||
LB216_set_char(drvthis, 4,d);
|
||||
LB216_set_char(drvthis, 5,e);
|
||||
LB216_set_char(drvthis, 6,f);
|
||||
LB216_set_char(drvthis, 7,g);
|
||||
custom=vbar;
|
||||
}
|
||||
}
|
||||
@@ -465,7 +485,8 @@ void LB216_init_vbar()
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Inits horizontal bars...
|
||||
//
|
||||
void LB216_init_hbar()
|
||||
MODULE_EXPORT void
|
||||
LB216_init_hbar(Driver * drvthis)
|
||||
{
|
||||
|
||||
char a[] = {
|
||||
@@ -520,11 +541,11 @@ void LB216_init_hbar()
|
||||
};
|
||||
|
||||
if(custom!=hbar) {
|
||||
LB216_set_char(1,a);
|
||||
LB216_set_char(2,b);
|
||||
LB216_set_char(3,c);
|
||||
LB216_set_char(4,d);
|
||||
LB216_set_char(5,e);
|
||||
LB216_set_char(drvthis, 1,a);
|
||||
LB216_set_char(drvthis, 2,b);
|
||||
LB216_set_char(drvthis, 3,c);
|
||||
LB216_set_char(drvthis, 4,d);
|
||||
LB216_set_char(drvthis, 5,e);
|
||||
custom=hbar;
|
||||
}
|
||||
}
|
||||
@@ -532,18 +553,19 @@ void LB216_init_hbar()
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a vertical bar...
|
||||
//
|
||||
void LB216_vbar(int x, int len)
|
||||
MODULE_EXPORT void
|
||||
LB216_vbar(Driver * drvthis, int x, int len)
|
||||
{
|
||||
char map[9] = {32, 1, 2, 3, 4, 5, 6, 7, 255 };
|
||||
|
||||
|
||||
int y;
|
||||
for(y=LB216->hgt; y > 0 && len>0; y--)
|
||||
for(y=height; y > 0 && len>0; y--)
|
||||
{
|
||||
if(len >= LB216->cellhgt) LB216_chr(x, y, 255);
|
||||
else LB216_chr(x, y, map[len]);
|
||||
if(len >= cellheight) LB216_chr(drvthis, x, y, 255);
|
||||
else LB216_chr(drvthis, x, y, map[len]);
|
||||
|
||||
len -= LB216->cellhgt;
|
||||
len -= cellheight;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -551,17 +573,18 @@ void LB216_vbar(int x, int len)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
void LB216_hbar(int x, int y, int len)
|
||||
MODULE_EXPORT void
|
||||
LB216_hbar(Driver * drvthis, int x, int y, int len)
|
||||
{
|
||||
char map[7] = { 32, 1, 2, 3, 4, 5 };
|
||||
|
||||
for(; x<=LB216->wid && len>0; x++)
|
||||
for(; x<=width && len>0; x++)
|
||||
{
|
||||
if(len >= LB216->cellwid) LB216_chr(x,y,map[5]);
|
||||
else LB216_chr(x, y, map[len]);
|
||||
if(len >= cellwidth) LB216_chr(drvthis, x,y,map[5]);
|
||||
else LB216_chr(drvthis, x, y, map[len]);
|
||||
|
||||
//printf ("%d,",len);
|
||||
len -= LB216->cellwid;
|
||||
len -= cellwidth;
|
||||
|
||||
}
|
||||
// printf ("\n");
|
||||
@@ -576,7 +599,8 @@ void LB216_hbar(int x, int y, int len)
|
||||
//
|
||||
// The input is just an array of characters...
|
||||
//
|
||||
void LB216_set_char(int n, char *dat)
|
||||
MODULE_EXPORT void
|
||||
LB216_set_char(Driver * drvthis, int n, char *dat)
|
||||
{
|
||||
char out[4];
|
||||
int row, col;
|
||||
@@ -589,20 +613,21 @@ void LB216_set_char(int n, char *dat)
|
||||
snprintf (out, sizeof(out), "%c%c", 254, n);
|
||||
write(fd, out, 2);
|
||||
|
||||
for(row=0; row<LB216->cellhgt; row++)
|
||||
for(row=0; row<cellheight; row++)
|
||||
{
|
||||
letter = 1;
|
||||
for(col=0; col<LB216->cellwid; col++)
|
||||
for(col=0; col<cellwidth; col++)
|
||||
{
|
||||
letter <<= 1;
|
||||
letter |= (dat[(row*LB216->cellwid) + col] > 0);
|
||||
letter |= (dat[(row*cellwidth) + col] > 0);
|
||||
}
|
||||
snprintf (out, sizeof(out),"%c",letter);
|
||||
write(fd, out, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void LB216_icon(int which, char dest)
|
||||
MODULE_EXPORT void
|
||||
LB216_icon(Driver * drvthis, int which, char dest)
|
||||
{
|
||||
char icons[3][8*8] = {
|
||||
{
|
||||
@@ -641,5 +666,5 @@ void LB216_icon(int which, char dest)
|
||||
};
|
||||
|
||||
if(custom==bign) custom=beat;
|
||||
LB216_set_char(dest, &icons[which][0]);
|
||||
LB216_set_char(drvthis, dest, &icons[which][0]);
|
||||
}
|
||||
|
||||
+21
-18
@@ -1,25 +1,28 @@
|
||||
#ifndef LB216_H
|
||||
#define LB216_H
|
||||
|
||||
#include "lcd.h"
|
||||
|
||||
extern lcd_logical_driver *LB216;
|
||||
int LB216_init(Driver * drvthis, char *device);
|
||||
MODULE_EXPORT void LB216_close(Driver * drvthis);
|
||||
MODULE_EXPORT int LB216_width (Driver *drvthis);
|
||||
MODULE_EXPORT int LB216_height (Driver *drvthis);
|
||||
MODULE_EXPORT void LB216_clear (Driver * drvthis);
|
||||
MODULE_EXPORT void LB216_flush(Driver * drvthis);
|
||||
MODULE_EXPORT void LB216_string (Driver * drvthis, int x, int y, char string[]);
|
||||
MODULE_EXPORT void LB216_chr(Driver * drvthis, int x, int y, char c) ;
|
||||
|
||||
int LB216_init(lcd_logical_driver *driver, char *device);
|
||||
void LB216_clear ();
|
||||
void LB216_close();
|
||||
void LB216_string (int x, int y, char string[]);
|
||||
void LB216_flush();
|
||||
void LB216_flush_box(int lft, int top, int rgt, int bot);
|
||||
void LB216_chr(int x, int y, char c) ;
|
||||
void LB216_backlight(int on);
|
||||
void LB216_init_vbar();
|
||||
void LB216_init_hbar();
|
||||
void LB216_vbar(int x, int len);
|
||||
void LB216_hbar(int x, int y, int len);
|
||||
void LB216_init_num();
|
||||
void LB216_num(int x, int num);
|
||||
void LB216_set_char(int n, char *dat);
|
||||
void LB216_icon(int which, char dest);
|
||||
void LB216_draw_frame(char *dat);
|
||||
MODULE_EXPORT void LB216_vbar(Driver * drvthis, int x, int len);
|
||||
MODULE_EXPORT void LB216_hbar(Driver * drvthis, int x, int y, int len);
|
||||
MODULE_EXPORT void LB216_num(Driver * drvthis, int x, int num);
|
||||
MODULE_EXPORT void LB216_icon(Driver * drvthis, int which, char dest);
|
||||
|
||||
MODULE_EXPORT void LB216_set_char(Driver * drvthis, int n, char *dat);
|
||||
|
||||
MODULE_EXPORT void LB216_backlight(Driver * drvthis, int on);
|
||||
|
||||
MODULE_EXPORT void LB216_init_vbar(Driver * drvthis);
|
||||
MODULE_EXPORT void LB216_init_hbar(Driver * drvthis);
|
||||
MODULE_EXPORT void LB216_init_num(Driver * drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
+22
-18
@@ -36,6 +36,7 @@
|
||||
|
||||
#include "lcd.h"
|
||||
|
||||
/*
|
||||
static int lcd_drv_init (lcd_logical_driver * driver, char *args);
|
||||
static void lcd_drv_close ();
|
||||
static void lcd_drv_clear ();
|
||||
@@ -59,6 +60,7 @@ static char lcd_drv_getkey ();
|
||||
static char lcd_drv_getkey_loop ();
|
||||
static char *lcd_drv_getinfo ();
|
||||
static void lcd_drv_heartbeat (int type);
|
||||
*/
|
||||
|
||||
/*
|
||||
* Add all of the driver's header files in...
|
||||
@@ -153,7 +155,8 @@ static void lcd_drv_heartbeat (int type);
|
||||
|
||||
// TODO: Make a Windows server, and clients...?
|
||||
|
||||
lcd_logical_driver lcd, *lcd_root = NULL, *lcd_ptr = NULL;
|
||||
//Driver *lcd_root = NULL;
|
||||
//Driver *lcd_ptr = NULL;
|
||||
|
||||
// TODO: Add multiple names for the same driver?
|
||||
//
|
||||
@@ -267,15 +270,20 @@ lcd_list_drivers (void) {
|
||||
//
|
||||
// This was eliminated; everything
|
||||
// done here is to be replaced by the use of lcd_add_driver()...
|
||||
|
||||
/*
|
||||
int
|
||||
lcd_init (char *args)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
// This sets up all of the "wrapper" driver functions
|
||||
// which call all of the drivers in turn.
|
||||
//
|
||||
|
||||
/*
|
||||
static int
|
||||
lcd_drv_init (struct lcd_logical_driver *driver, char *args)
|
||||
{
|
||||
@@ -379,6 +387,7 @@ lcd_drv_patch_init (struct lcd_logical_driver *driver)
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* This function can be replaced later with something
|
||||
@@ -386,6 +395,7 @@ lcd_drv_patch_init (struct lcd_logical_driver *driver)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
void *
|
||||
lcd_find_init (char *driver) {
|
||||
int i;
|
||||
@@ -401,11 +411,13 @@ lcd_find_init (char *driver) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// TODO: lcd_remove_driver()
|
||||
|
||||
struct lcd_logical_driver *
|
||||
/*
|
||||
Driver *
|
||||
lcd_allocate_driver () {
|
||||
struct lcd_logical_driver *driver;
|
||||
Driver *driver;
|
||||
//int driver_size;
|
||||
|
||||
// This bit of fakery allows us to use lcd as the first
|
||||
@@ -414,7 +426,7 @@ lcd_allocate_driver () {
|
||||
|
||||
#define FirstTime (lcd_ptr->framebuf == NULL)
|
||||
|
||||
if ((driver = malloc(sizeof(lcd_logical_driver))) == NULL) {
|
||||
if ((driver = malloc(sizeof(Driver))) == NULL) {
|
||||
syslog(LOG_ERR, "error allocating driver space!");
|
||||
return NULL;
|
||||
}
|
||||
@@ -432,6 +444,7 @@ lcd_allocate_driver () {
|
||||
// it. This is the function which calls, for example,
|
||||
// MtxOrb_init. The specifics come from the drivers[] array.
|
||||
|
||||
|
||||
static char (*main_getkey) () = NULL;
|
||||
|
||||
int
|
||||
@@ -507,19 +520,7 @@ lcd_add_driver (char *driver, char *args)
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// TODO: Put lcd_shutdown in the shutdown function...
|
||||
int
|
||||
lcd_shutdown ()
|
||||
{
|
||||
//lcd_logical_driver *driver;
|
||||
|
||||
// This does not shutdown any input sources;
|
||||
// is that sufficient?
|
||||
lcd_root->close ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// All functions below here call their respective driver functions...
|
||||
@@ -563,6 +564,7 @@ lcd_shutdown ()
|
||||
// lcd_drv_getkey ()
|
||||
// lcd_drv_getinfo ()
|
||||
|
||||
/*
|
||||
static void
|
||||
lcd_drv_close ()
|
||||
{
|
||||
@@ -686,9 +688,10 @@ lcd_drv_getkey ()
|
||||
// This loops through all defined getkeys, returning
|
||||
// the first input that it finds, if any.
|
||||
|
||||
|
||||
static char
|
||||
lcd_drv_getkey_loop () {
|
||||
lcd_logical_driver *driver;
|
||||
Driver *driver;
|
||||
char c;
|
||||
|
||||
if ((c = main_getkey()) != 0)
|
||||
@@ -708,3 +711,4 @@ lcd_drv_heartbeat (int type)
|
||||
;
|
||||
}
|
||||
|
||||
*/
|
||||
+169
-73
@@ -1,104 +1,200 @@
|
||||
/*
|
||||
* client.h
|
||||
* This file is part of LCDd, the lcdproc server.
|
||||
*
|
||||
* This file is released under the GNU General Public License. Refer to the
|
||||
* COPYING file distributed with this package.
|
||||
*
|
||||
* Copyright (c) 1999, William Ferrell, Scott Scriven
|
||||
* 2001, Joris Robijn
|
||||
*
|
||||
*
|
||||
* This file defines the LCDd-driver API
|
||||
* It is written to facilitate loadable driver modules.
|
||||
* There should be no further interaction between driver and server core
|
||||
* other that via this API.
|
||||
*
|
||||
* DO NOT MIX DRIVER ALLOCATED AND CORE ALLOCATED MEMORY.
|
||||
* With this I mean that the server core should NEVER WRITE in memory
|
||||
* allocated by the driver, and vice versa. Also the driver resp. core
|
||||
* should free or realloc the memory that it has allocated. You can always
|
||||
* simply copy a string if its data space is not 'yours'.
|
||||
*/
|
||||
|
||||
#ifndef LCD_H
|
||||
#define LCD_H
|
||||
|
||||
// Maximum supported sizes
|
||||
/* Maximum supported sizes */
|
||||
#define LCD_MAX_WIDTH 256
|
||||
#define LCD_MAX_HEIGHT 256
|
||||
|
||||
// Standard supported sizes
|
||||
#define LCD_STD_WIDTH 20
|
||||
#define LCD_STD_HEIGHT 4
|
||||
#define LCD_STD_CELL_WIDTH 5
|
||||
#define LCD_STD_CELL_HEIGHT 8
|
||||
/* Standard supported sizes */
|
||||
#define LCD_DEFAULT_WIDTH 20
|
||||
#define LCD_DEFAULT_HEIGHT 4
|
||||
#define LCD_DEFAULT_CELLWIDTH 5
|
||||
#define LCD_DEFAULT_CELLHEIGHT 8
|
||||
|
||||
void lcd_list_drivers (void);
|
||||
int lcd_init (char *args);
|
||||
int lcd_add_driver (char *driver, char *args);
|
||||
int lcd_shutdown ();
|
||||
/* Backlight data */
|
||||
#define BACKLIGHT_OFF 0
|
||||
#define BACKLIGHT_ON 1
|
||||
#define BACKLIGHT_WARNING 2
|
||||
#define BACKLIGHT_RED_ALERT 3
|
||||
|
||||
// Icons for icon function
|
||||
#define ICON_BLOCK_FILLED 0
|
||||
#define ICON_HEART_OPEN 8
|
||||
#define ICON_HEART_FILLED 9
|
||||
|
||||
/* Heartbeat data, taken from render.h */
|
||||
/* ??? What do all these mean ? */
|
||||
#define HEART_OFF 1
|
||||
#define HEART_ON 2
|
||||
#define HEART_OPEN 3
|
||||
#define HEARTBEAT_OFF HEART_OFF
|
||||
#define HEARTBEAT_ON HEART_ON
|
||||
#define HEARTBEAT_OPEN HEART_OPEN
|
||||
|
||||
/* Patterns for hbar / vbar */
|
||||
#define BAR_POS 0x001 /* default */
|
||||
#define BAR_NEG 0x002
|
||||
#define BAR_POS_AND_NEG 0x003
|
||||
#define BAR_PATTERN_FILLED 0x000
|
||||
#define BAR_PATTERN_OPEN 0x010
|
||||
#define BAR_PATTERN_STRIPED 0x020
|
||||
#define BAR_WITH_PERCENTAGE 0x100
|
||||
|
||||
/* Cursor types */
|
||||
#define CURSOR_OFF 0
|
||||
#define CURSOR_DEFAULT_ON 1
|
||||
#define CURSOR_BLOCK 4
|
||||
#define CURSOR_UNDER 5
|
||||
|
||||
/* What does the shared module handle look like on the current platform? */
|
||||
#define MODULE_HANDLE void*
|
||||
/* And how do we define the exported functions */
|
||||
#define MODULE_EXPORT static
|
||||
/* WHILE NOT MODULES static BECAUSE OTHERWISE WE HAVE MULTIPLE IDENTICAL SYMBOLS */
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Driver functions / info held here...
|
||||
//
|
||||
// Feel free to override any/all functions here with real driver
|
||||
// functions...
|
||||
//
|
||||
typedef struct lcd_logical_driver {
|
||||
// Size in cells of the LCD
|
||||
int wid, hgt;
|
||||
// Size of each LCD cell, in pixels
|
||||
int cellwid, cellhgt;
|
||||
// Frame buffer...
|
||||
char *framebuf;
|
||||
|
||||
// Daemonizable? Usually yes...
|
||||
int daemonize;
|
||||
/* Ancient variables */
|
||||
|
||||
// Pointer to next input function...
|
||||
//lcd_logical_driver *nextkey;
|
||||
void *nextkey;
|
||||
/* For explanation of variables and functions see docs/API-v0.5.txt */
|
||||
|
||||
// Functions which might be the same for all drivers...
|
||||
void (*clear) ();
|
||||
void (*string) (int x, int y, char lcd[]);
|
||||
/******** Variables in the driver module ********/
|
||||
/* The driver loader will look for symbols with these names ! */
|
||||
|
||||
void (*chr) (int x, int y, char c);
|
||||
void (*vbar) (int x, int len);
|
||||
void (*hbar) (int x, int y, int len);
|
||||
void (*init_num) ();
|
||||
void (*num) (int x, int num);
|
||||
char *api_version;
|
||||
int *stay_in_foreground; /* Does this driver require to be in foreground ? */
|
||||
int *supports_multiple; /* Does this driver support multiple instances ? */
|
||||
char *func_prefix; /* What should be prepended to the function names ? */
|
||||
|
||||
|
||||
/******** Functions in the driver module ********/
|
||||
/* The driver loader will look for symbols with these names ! */
|
||||
|
||||
/* Basic functions */
|
||||
int (*init) (struct lcd_logical_driver* drvthis, char *args);
|
||||
void (*close) (struct lcd_logical_driver* drvthis);
|
||||
int (*width) (struct lcd_logical_driver* drvthis);
|
||||
int (*height) (struct lcd_logical_driver* drvthis);
|
||||
void (*clear) (struct lcd_logical_driver* drvthis);
|
||||
void (*flush) (struct lcd_logical_driver* drvthis);
|
||||
void (*string) (struct lcd_logical_driver* drvthis, int x, int y, char *str);
|
||||
void (*chr) (struct lcd_logical_driver* drvthis, int x, int y, char c);
|
||||
|
||||
/* Extended functions */
|
||||
void (*vbar) (struct lcd_logical_driver* drvthis, int x, int y, int len, int promille, int pattern);
|
||||
void (*hbar) (struct lcd_logical_driver* drvthis, int x, int y, int len, int promille, int pattern);
|
||||
void (*num) (struct lcd_logical_driver* drvthis, int x, int num);
|
||||
void (*heartbeat) (struct lcd_logical_driver* drvthis, int state);
|
||||
void (*icon) (struct lcd_logical_driver* drvthis, int x, int y, int icon);
|
||||
void (*cursor) (struct lcd_logical_driver* drvthis, int x, int y, int state);
|
||||
|
||||
/* Userdef characters, are those still supported ? */
|
||||
void (*set_char) (struct lcd_logical_driver* drvthis, int n, char *dat);
|
||||
int (*get_free_chars) (struct lcd_logical_driver* drvthis);
|
||||
int (*cellwidth) (struct lcd_logical_driver* drvthis);
|
||||
int (*cellheight) (struct lcd_logical_driver* drvthis);
|
||||
|
||||
/* Hardware functions */
|
||||
int (*get_contrast) (struct lcd_logical_driver* drvthis);
|
||||
void (*set_contrast) (struct lcd_logical_driver* drvthis, int promille);
|
||||
int (*get_brightness) (struct lcd_logical_driver* drvthis, int state);
|
||||
void (*set_brightness) (struct lcd_logical_driver* drvthis, int state, int promille);
|
||||
void (*backlight) (struct lcd_logical_driver* drvthis, int on);
|
||||
void (*output) (struct lcd_logical_driver* drvthis, int state);
|
||||
|
||||
/* Key functions */
|
||||
char *(*get_key) (struct lcd_logical_driver* drvthis);
|
||||
/* Returns a string. Server cannot modify
|
||||
this string. */
|
||||
|
||||
char * (*get_info) ();
|
||||
|
||||
|
||||
/* OLD FUNCTIONS */
|
||||
void (*old_vbar) (struct lcd_logical_driver* drvthis, int x, int len);
|
||||
void (*old_hbar) (struct lcd_logical_driver* drvthis, int x, int y, int len);
|
||||
void (*old_icon) (struct lcd_logical_driver* drvthis, int which, char dest);
|
||||
/* THESE 3 TO BE REMOVED */
|
||||
|
||||
// Functions which should probably be implemented in each driver...
|
||||
int (*init) (struct lcd_logical_driver * driver, char *args);
|
||||
void (*close) ();
|
||||
void (*flush) ();
|
||||
void (*flush_box) (int lft, int top, int rgt, int bot);
|
||||
int (*contrast) (int contrast);
|
||||
void (*backlight) (int on);
|
||||
void (*output) (int on);
|
||||
void (*set_char) (int n, char *dat);
|
||||
void (*icon) (int which, char dest);
|
||||
void (*init_vbar) ();
|
||||
void (*init_hbar) ();
|
||||
void (*init_num) ();
|
||||
void (*draw_frame) ();
|
||||
void (*flush_box) (int lft, int top, int rgt, int bot);
|
||||
/* THESE 4 TO BE REMOVED */
|
||||
|
||||
// Returns 0 for "no key pressed", or (A-Z).
|
||||
/* Returns 0 for "no key pressed", or (A-Z). */
|
||||
char (*getkey) ();
|
||||
/* TO BE REMOVED, IS RENAMED AND CHANGED */
|
||||
|
||||
// Returns pointer to static string.
|
||||
char * (*getinfo) ();
|
||||
|
||||
// Puts up a heartbeat...
|
||||
void (*heartbeat) (int type);
|
||||
// more?
|
||||
/******** Variables in server core available for drivers ********/
|
||||
|
||||
// Config file functions, filled by server
|
||||
char (*config_get_bool) (char * sectionname, char * keyname,
|
||||
int skip, char default_value);
|
||||
int (*config_get_int) (char * sectionname, char * keyname,
|
||||
int skip, int default_value);
|
||||
double (*config_get_float) (char * sectionname, char * keyname,
|
||||
int skip, double default_value);
|
||||
char *(*config_get_string) (char * sectionname, char * keyname,
|
||||
int skip, char * default_value);
|
||||
// Returns a string in server memory space.
|
||||
// Copy this string.
|
||||
int (*config_has_section) (char *sectionname);
|
||||
int (*config_has_key) (char *sectionname, char *keyname);
|
||||
char * name; /* Name of this driver */
|
||||
char * filename; /* Filename of the shared module */
|
||||
|
||||
MODULE_HANDLE module_handle; /* The handle of the loaded shared module
|
||||
Is platform specific */
|
||||
|
||||
void * private_data; /* Filled by server by calling store_private_ptr()
|
||||
Driver should cast this to it's own
|
||||
private structure pointer */
|
||||
|
||||
|
||||
/******** Functions in server core available for drivers ********/
|
||||
|
||||
// Driver private data
|
||||
int (*store_private_ptr) (struct lcd_logical_driver * driver, void * private_data);
|
||||
void * private_data; // Filled by server by calling store_private_ptr()
|
||||
// Driver should cast this to it's own
|
||||
// private structure pointer
|
||||
/* Store the driver's private data */
|
||||
|
||||
} lcd_logical_driver;
|
||||
/* Configfile functions */
|
||||
/* See configfile.h for descriptions and usage. */
|
||||
|
||||
typedef struct lcd_physical_driver {
|
||||
unsigned char (*config_get_bool)( char *sectionname, char *keyname, int skip, unsigned char default_value );
|
||||
long int (*config_get_int) ( char *sectionname, char *keyname, int skip, long int default_value );
|
||||
double (*config_get_float) ( char *sectionname, char *keyname, int skip, double default_value );
|
||||
char *( *config_get_string) ( char *sectionname, char *keyname, int skip, char *default_value );
|
||||
int (*config_has_section) ( char *sectionname );
|
||||
int (*config_has_key) ( char *sectionname, char *keyname );
|
||||
|
||||
/* Reporting function */
|
||||
/* Easily usable by including drivers/report.h */
|
||||
void (*report) ( const int level, const char *format, .../*args*/ );
|
||||
|
||||
/* Display properties functions (for drivers that adapt to other loaded drivers) */
|
||||
int (*request_display_width) ();
|
||||
int (*request_display_height) ();
|
||||
|
||||
} Driver;
|
||||
|
||||
|
||||
void lcd_list_drivers (void); /* TO BE REMOVED WHEN WE HAVE LOADABLE MODULES */
|
||||
|
||||
typedef struct lcd_physical_driver { /* TO BE REMOVED WHEN WE HAVE LOADABLE MODULES */
|
||||
char *name;
|
||||
int (*init) (struct lcd_logical_driver * driver, char *device);
|
||||
} lcd_physical_driver;
|
||||
|
||||
//extern lcd_logical_driver lcd;
|
||||
extern lcd_logical_driver *lcd_ptr;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
// driver code or headers or something...
|
||||
#define MAX_CUSTOM_CHARS 16
|
||||
|
||||
/*
|
||||
ANY DRIVER SHOULD SIMPLY FREE ITS FRAMEBUFFER AT CLOSE()
|
||||
NO CHECKING FOR NULL NEEDED
|
||||
void
|
||||
free_framebuf (struct lcd_logical_driver *driver) {
|
||||
if (!driver)
|
||||
@@ -30,7 +33,10 @@ free_framebuf (struct lcd_logical_driver *driver) {
|
||||
|
||||
driver->framebuf = NULL;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
NEED TO BE ADAPTED TO NEW SITUATION
|
||||
void
|
||||
clear_framebuf (struct lcd_logical_driver *driver) {
|
||||
int framebuf_size;
|
||||
@@ -41,7 +47,10 @@ clear_framebuf (struct lcd_logical_driver *driver) {
|
||||
framebuf_size = driver->wid * driver->hgt;
|
||||
memset (driver->framebuf, ' ', framebuf_size);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
NEED TO BE ADAPTED TO NEW SITUATION
|
||||
int
|
||||
new_framebuf (struct lcd_logical_driver *driver, char *oldbuf) {
|
||||
int i;
|
||||
@@ -59,7 +68,10 @@ new_framebuf (struct lcd_logical_driver *driver, char *oldbuf) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
NEED TO BE ADAPTED TO NEW SITUATION
|
||||
void
|
||||
insert_str_framebuf (struct lcd_logical_driver *driver, int x, int y, char *string) {
|
||||
//int i;
|
||||
@@ -85,7 +97,10 @@ insert_str_framebuf (struct lcd_logical_driver *driver, int x, int y, char *stri
|
||||
pos = (driver->framebuf + (y * driver->wid) + x);
|
||||
strcpy(pos, buf);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
NEED TO BE ADAPTED TO NEW SITUATION
|
||||
void
|
||||
insert_chr_framebuf (struct lcd_logical_driver *driver, int x, int y, char c) {
|
||||
if (!driver)
|
||||
@@ -101,6 +116,7 @@ insert_chr_framebuf (struct lcd_logical_driver *driver, int x, int y, char c) {
|
||||
|
||||
driver->framebuf[(y * driver->wid) + x] = c;
|
||||
}
|
||||
*/
|
||||
|
||||
void
|
||||
output_heartbeat (struct lcd_logical_driver *driver, int type) {
|
||||
@@ -113,17 +129,26 @@ output_heartbeat (struct lcd_logical_driver *driver, int type) {
|
||||
|
||||
if (type == HEARTBEAT_ON) {
|
||||
// Set this to pulsate like a real heart beat...
|
||||
whichIcon = (! ((timer + 4) & 5));
|
||||
if ( (timer + 4) & 5 ) {
|
||||
whichIcon = ICON_HEART_OPEN;
|
||||
}
|
||||
else {
|
||||
whichIcon = ICON_HEART_FILLED;
|
||||
}
|
||||
|
||||
driver->icon (driver, driver->width(driver), 1, whichIcon);
|
||||
|
||||
/* OLD CODE
|
||||
// This defines a custom character EVERY time...
|
||||
// not efficient... is this necessary?
|
||||
driver->icon (whichIcon, 0);
|
||||
driver->icon (driver, whichIcon, 0);
|
||||
|
||||
// Put character on screen...
|
||||
driver->chr (driver->wid, 1, 0);
|
||||
driver->chr (driver, driver->wid, 1, 0);
|
||||
*/
|
||||
|
||||
// change display...
|
||||
driver->flush ();
|
||||
driver->flush (driver);
|
||||
}
|
||||
|
||||
timer++;
|
||||
|
||||
+142
-180
@@ -42,6 +42,11 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
# if TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
@@ -56,37 +61,24 @@
|
||||
#include "lcd.h"
|
||||
#include "lcdm001.h"
|
||||
#include "shared/str.h"
|
||||
#include "shared/report.h"
|
||||
#include "configfile.h"
|
||||
#include "render.h"
|
||||
#include "report.h"
|
||||
//#include "configfile.h"
|
||||
|
||||
// Moved here from lcdm001.h to reduce the number of warning.
|
||||
static void lcdm001_close ();
|
||||
static void lcdm001_clear ();
|
||||
static void lcdm001_flush ();
|
||||
static void lcdm001_string (int x, int y, char string[]);
|
||||
static void lcdm001_chr (int x, int y, char c);
|
||||
static void lcdm001_output (int on);
|
||||
static void lcdm001_vbar (int x, int len);
|
||||
static void lcdm001_hbar (int x, int y, int len);
|
||||
static void lcdm001_num (int x, int num);
|
||||
static void lcdm001_icon (int which, char dest);
|
||||
static void lcdm001_flush_box (int lft, int top, int rgt, int bot);
|
||||
static void lcdm001_draw_frame (char *dat);
|
||||
static char lcdm001_getkey ();
|
||||
// End of extract from lcdm001.h by David GLAUDE.
|
||||
static void lcdm001_heartbeat (int type);
|
||||
|
||||
#define NotEnoughArgs (i + 1 > argc)
|
||||
|
||||
lcd_logical_driver *lcdm001;
|
||||
int fd;
|
||||
static int clear = 1;
|
||||
static char icon_char = '@';
|
||||
static char pause_key = DOWN_KEY, back_key = LEFT_KEY, forward_key = RIGHT_KEY, main_menu_key = UP_KEY;
|
||||
static char *framebuf = NULL;
|
||||
static int width = LCD_DEFAULT_WIDTH;
|
||||
static int height = LCD_DEFAULT_HEIGHT;
|
||||
|
||||
// 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 = "lcdm001_";
|
||||
|
||||
/*this is really ugly ;) but works ;)*/
|
||||
static char num_icon [10][4][3] = {{{' ','_',' '}, /*0*/
|
||||
{'|',' ','|'},
|
||||
{'|','_','|'},
|
||||
@@ -127,27 +119,25 @@ static char num_icon [10][4][3] = {{{' ','_',' '}, /*0*/
|
||||
{'|','_','|'},
|
||||
{' ','_','|'},
|
||||
{' ',' ',' '}}};
|
||||
/*end of ugly code ;) Rene Wagner*/
|
||||
|
||||
static void lcdm001_cursorblink (int on);
|
||||
static void lcdm001_string (int x, int y, char *string);
|
||||
static char lcdm001_parse_keypad_setting ( char * sectionname, char * keyname, char * default_value );
|
||||
static void lcdm001_cursorblink (Driver *drvthis, int on);
|
||||
static char lcdm001_parse_keypad_setting ( Driver *drvthis, char * keyname, char * default_value );
|
||||
|
||||
#define ValidX(x) if ((x) > lcdm001->wid) { (x) = lcdm001->wid; } else (x) = (x) < 1 ? 1 : (x);
|
||||
#define ValidY(y) if ((y) > lcdm001->hgt) { (y) = lcdm001->hgt; } else (y) = (y) < 1 ? 1 : (y);
|
||||
#define ValidX(x) if ((x) > width) { (x) = width; } else (x) = (x) < 1 ? 1 : (x);
|
||||
#define ValidY(y) if ((y) > height) { (y) = height; } else (y) = (y) < 1 ? 1 : (y);
|
||||
|
||||
// Parse one key from the configfile
|
||||
static char lcdm001_parse_keypad_setting (char * sectionname, char * keyname, char * default_value)
|
||||
static char lcdm001_parse_keypad_setting (Driver *drvthis, char * keyname, char * default_value)
|
||||
{
|
||||
char return_val = 0;
|
||||
|
||||
if (strcmp( config_get_string ( sectionname, keyname, 0, default_value), "LeftKey")==0) {
|
||||
if (strcmp( drvthis->config_get_string ( drvthis->name, keyname, 0, default_value), "LeftKey")==0) {
|
||||
return_val=LEFT_KEY;
|
||||
} else if (strcmp( config_get_string ( sectionname, keyname, 0, default_value), "RightKey")==0) {
|
||||
} else if (strcmp( drvthis->config_get_string ( drvthis->name, keyname, 0, default_value), "RightKey")==0) {
|
||||
return_val=RIGHT_KEY;
|
||||
} else if (strcmp( config_get_string ( sectionname, keyname, 0, default_value), "UpKey")==0) {
|
||||
} else if (strcmp( drvthis->config_get_string ( drvthis->name, keyname, 0, default_value), "UpKey")==0) {
|
||||
return_val=UP_KEY;
|
||||
} else if (strcmp( config_get_string ( sectionname, keyname, 0, default_value), "DownKey")==0) {
|
||||
} else if (strcmp( drvthis->config_get_string ( drvthis->name, keyname, 0, default_value), "DownKey")==0) {
|
||||
return_val=DOWN_KEY;
|
||||
} else {
|
||||
report (RPT_WARNING, "LCDM001: Invalid config file setting for %s. Using default value %s.\n", keyname, default_value);
|
||||
@@ -164,10 +154,9 @@ static char lcdm001_parse_keypad_setting (char * sectionname, char * keyname, ch
|
||||
return return_val;
|
||||
}
|
||||
|
||||
// Set cursorblink on/off
|
||||
//
|
||||
/* Set cursorblink on/off */
|
||||
static void
|
||||
lcdm001_cursorblink (int on)
|
||||
lcdm001_cursorblink (Driver *drvthis, int on)
|
||||
{
|
||||
if (on) {
|
||||
write (fd, "~K1", 3);
|
||||
@@ -179,13 +168,14 @@ lcdm001_cursorblink (int on)
|
||||
}
|
||||
|
||||
|
||||
// TODO: Get lcd.framebuf to properly work as whatever driver is running...
|
||||
/* TODO: Get lcd.framebuf to properly work as whatever driver is running...*/
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// init() should set up any device-specific stuff, and
|
||||
// point all the function pointers.
|
||||
/*********************************************************************
|
||||
* init() should set up any device-specific stuff, and
|
||||
* point all the function pointers.
|
||||
*/
|
||||
int
|
||||
lcdm001_init (struct lcd_logical_driver *driver, char *args)
|
||||
lcdm001_init (Driver *drvthis, char *args)
|
||||
{
|
||||
char device[200];
|
||||
int speed=B38400;
|
||||
@@ -193,48 +183,28 @@ lcdm001_init (struct lcd_logical_driver *driver, char *args)
|
||||
|
||||
char out[5]="";
|
||||
|
||||
lcdm001 = driver;
|
||||
debug( RPT_INFO, "LCDM001: init(%p,%s)", drvthis, args );
|
||||
|
||||
debug( RPT_INFO, "LCDM001: init(%p,%s)", driver, args );
|
||||
framebuf = malloc (width * height);
|
||||
|
||||
driver->wid = 20;
|
||||
driver->hgt = 4;
|
||||
|
||||
// You must use driver->framebuf here, but may use lcd.framebuf later.
|
||||
if (!driver->framebuf) {
|
||||
driver->framebuf = malloc (driver->wid * driver->hgt);
|
||||
}
|
||||
|
||||
if (!driver->framebuf) {
|
||||
lcdm001_close ();
|
||||
if (!framebuf) {
|
||||
report(RPT_ERR, "\nError: unable to create LCDM001 framebuffer.\n");
|
||||
return -1;
|
||||
}
|
||||
// Debugging...
|
||||
// if(lcd.framebuf) printf("Frame buffer: %i\n", (int)lcd.framebuf);
|
||||
|
||||
memset (driver->framebuf, ' ', driver->wid * driver->hgt);
|
||||
// lcdm001_clear();
|
||||
|
||||
driver->cellwid = 5;
|
||||
driver->cellhgt = 8;
|
||||
|
||||
// TODO: replace DriverName with driver->name when that field exists.
|
||||
#define DriverName "lcdm001"
|
||||
memset (framebuf, ' ', width * height);
|
||||
|
||||
// READ CONFIG FILE:
|
||||
|
||||
// which serial device should be used
|
||||
strncpy(device, config_get_string ( DriverName , "Device" , 0 , "/dev/lcd"), sizeof(device));
|
||||
strncpy(device, drvthis->config_get_string ( drvthis->name , "Device" , 0 , "/dev/lcd"),sizeof(device));
|
||||
device[sizeof(device)-1]=0;
|
||||
report (RPT_INFO,"LCDM001: Using device: %s", device);
|
||||
|
||||
// keypad settings
|
||||
pause_key = lcdm001_parse_keypad_setting (DriverName, "PauseKey", "DownKey");
|
||||
back_key = lcdm001_parse_keypad_setting (DriverName, "BackKey", "LeftKey");
|
||||
forward_key = lcdm001_parse_keypad_setting (DriverName, "ForwardKey", "RightKey");
|
||||
main_menu_key = lcdm001_parse_keypad_setting (DriverName, "MainMenuKey", "UpKey");
|
||||
|
||||
pause_key = lcdm001_parse_keypad_setting (drvthis, "PauseKey", "DownKey");
|
||||
back_key = lcdm001_parse_keypad_setting (drvthis, "BackKey", "LeftKey");
|
||||
forward_key = lcdm001_parse_keypad_setting (drvthis, "ForwardKey", "RightKey");
|
||||
main_menu_key = lcdm001_parse_keypad_setting (drvthis, "MainMenuKey", "UpKey");
|
||||
|
||||
// Set up io port correctly, and open it...
|
||||
debug( RPT_DEBUG, "LCDM001: Opening serial device: %s", device);
|
||||
@@ -256,10 +226,10 @@ lcdm001_init (struct lcd_logical_driver *driver, char *args)
|
||||
}
|
||||
tcgetattr(fd, &portset);
|
||||
#ifdef HAVE_CFMAKERAW
|
||||
// The easy way
|
||||
/* The easy way: */
|
||||
cfmakeraw( &portset );
|
||||
#else
|
||||
// The hard way
|
||||
/* The hard way: */
|
||||
portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP
|
||||
| INLCR | IGNCR | ICRNL | IXON );
|
||||
portset.c_oflag &= ~OPOST;
|
||||
@@ -275,59 +245,60 @@ lcdm001_init (struct lcd_logical_driver *driver, char *args)
|
||||
// Reset and clear the LCDM001
|
||||
write (fd, "~C", 2);
|
||||
//Set cursorblink default
|
||||
lcdm001_cursorblink (DEFAULT_CURSORBLINK);
|
||||
lcdm001_cursorblink (drvthis, DEFAULT_CURSORBLINK);
|
||||
// Turn all LEDs off
|
||||
snprintf (out, sizeof(out), "\%cL%c%c", 126, 0, 0);
|
||||
write (fd, out, 4);
|
||||
|
||||
/*
|
||||
* Configure the display functions
|
||||
*/
|
||||
driver->daemonize = 1; // daemonize.
|
||||
// Set variables for server
|
||||
drvthis->api_version = api_version;
|
||||
drvthis->stay_in_foreground = &stay_in_foreground;
|
||||
drvthis->supports_multiple = &supports_multiple;
|
||||
|
||||
driver->clear = lcdm001_clear;
|
||||
driver->string = lcdm001_string;
|
||||
driver->chr = lcdm001_chr;
|
||||
driver->vbar =lcdm001_vbar;
|
||||
// Set the functions the driver supports
|
||||
drvthis->clear = lcdm001_clear;
|
||||
drvthis->width = lcdm001_width;
|
||||
drvthis->height = lcdm001_height;
|
||||
drvthis->string = lcdm001_string;
|
||||
drvthis->chr = lcdm001_chr;
|
||||
drvthis->old_vbar =lcdm001_vbar;
|
||||
//init_vbar is not needed
|
||||
driver->hbar = lcdm001_hbar;
|
||||
drvthis->old_hbar = lcdm001_hbar;
|
||||
//init_hbar is not needed
|
||||
driver->num = lcdm001_num;
|
||||
drvthis->num = lcdm001_num;
|
||||
//init_num is not needed
|
||||
|
||||
driver->init = lcdm001_init;
|
||||
driver->close = lcdm001_close;
|
||||
driver->flush = lcdm001_flush;
|
||||
driver->flush_box = lcdm001_flush_box;
|
||||
drvthis->init = lcdm001_init;
|
||||
drvthis->close = lcdm001_close;
|
||||
drvthis->flush = lcdm001_flush;
|
||||
//contrast and backlight are not implemented as
|
||||
//changing the contrast or the state of the backlight
|
||||
//is not supported by the device
|
||||
//Well ... you could make use of your screw driver and
|
||||
//Well ... you could make use of your screw drvthis and
|
||||
//soldering iron ;)
|
||||
driver->output = lcdm001_output;
|
||||
drvthis->output = lcdm001_output;
|
||||
//set_char is not implemented as custom chars are not
|
||||
//supported by the device
|
||||
driver->icon = lcdm001_icon;
|
||||
driver->draw_frame = lcdm001_draw_frame;
|
||||
drvthis->old_icon = lcdm001_icon;
|
||||
|
||||
driver->getkey = lcdm001_getkey;
|
||||
driver->heartbeat = lcdm001_heartbeat;
|
||||
drvthis->getkey = lcdm001_getkey;
|
||||
drvthis->heartbeat = lcdm001_heartbeat;
|
||||
|
||||
return fd;
|
||||
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.
|
||||
/* Below here, you may use either lcd.framebuf or driver->framebuf..
|
||||
* lcd.framebuf will be set to the appropriate buffer before calling
|
||||
* your driver.
|
||||
*/
|
||||
|
||||
static void
|
||||
lcdm001_close ()
|
||||
MODULE_EXPORT void
|
||||
lcdm001_close (Driver *drvthis)
|
||||
{
|
||||
char out[5];
|
||||
if (lcdm001->framebuf != NULL)
|
||||
free (lcdm001->framebuf);
|
||||
if(framebuf) free (framebuf);
|
||||
framebuf = NULL;
|
||||
|
||||
lcdm001->framebuf = NULL;
|
||||
//switch off all LEDs
|
||||
snprintf (out, sizeof(out), "\%cL%c%c", 126, 0, 0);
|
||||
write (fd, out, 4);
|
||||
@@ -336,14 +307,32 @@ lcdm001_close ()
|
||||
report (RPT_INFO, "LCDM001: closed");
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display width
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
lcdm001_width (Driver *drvthis)
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display height
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
lcdm001_height (Driver *drvthis)
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clears the LCD screen
|
||||
//
|
||||
static void
|
||||
lcdm001_clear ()
|
||||
MODULE_EXPORT void
|
||||
lcdm001_clear (Driver *drvthis)
|
||||
{
|
||||
if (lcdm001->framebuf != NULL)
|
||||
memset (lcdm001->framebuf, ' ', (lcdm001->wid * lcdm001->hgt));
|
||||
if (framebuf != NULL)
|
||||
memset (framebuf, ' ', (width * height));
|
||||
|
||||
write (fd, "~C", 2); // instant clear...
|
||||
clear = 1;
|
||||
@@ -354,38 +343,24 @@ lcdm001_clear ()
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Flushes all output to the lcd...
|
||||
//
|
||||
void
|
||||
lcdm001_flush ()
|
||||
MODULE_EXPORT void
|
||||
lcdm001_flush (Driver *drvthis)
|
||||
{
|
||||
lcdm001_draw_frame(lcdm001->framebuf);
|
||||
// Next 4 lines are moved from draw_frame (Joris)
|
||||
|
||||
//TODO: Check whether this is still correct
|
||||
|
||||
write(fd,framebuf,80);
|
||||
|
||||
debug (RPT_DEBUG, "LCDM001: frame buffer flushed");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Send a rectangular area to the display.
|
||||
//
|
||||
|
||||
static void
|
||||
lcdm001_flush_box (int lft, int top, int rgt, int bot)
|
||||
{
|
||||
int y;
|
||||
char out[LCD_MAX_WIDTH];
|
||||
|
||||
for (y = top; y <= bot; y++) {
|
||||
snprintf (out, sizeof(out), "%cP%c%c", 126, lft, y);
|
||||
write (fd, out, 4);
|
||||
write (fd, lcdm001->framebuf + (y * lcdm001->wid) + lft, rgt - lft + 1);
|
||||
}
|
||||
debug (RPT_DEBUG, "LCDM001: frame buffer box flushed");
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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).
|
||||
//
|
||||
static void
|
||||
lcdm001_chr (int x, int y, char c)
|
||||
MODULE_EXPORT void
|
||||
lcdm001_chr (Driver *drvthis, int x, int y, char c)
|
||||
{
|
||||
char buf[64]; // char out[10];
|
||||
int offset;
|
||||
@@ -400,8 +375,8 @@ lcdm001_chr (int x, int y, char c)
|
||||
// write to frame buffer
|
||||
y--; x--; // translate to 0-coords
|
||||
|
||||
offset = (y * lcdm001->wid) + x;
|
||||
lcdm001->framebuf[offset] = c;
|
||||
offset = (y * width) + x;
|
||||
framebuf[offset] = c;
|
||||
|
||||
snprintf(buf, sizeof(buf), "LCDM001: writing character %02X to position (%d,%d)", c, x, y);
|
||||
debug (RPT_DEBUG, buf);
|
||||
@@ -411,8 +386,8 @@ lcdm001_chr (int x, int y, char c)
|
||||
// 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).
|
||||
//
|
||||
static void
|
||||
lcdm001_string (int x, int y, char string[])
|
||||
MODULE_EXPORT void
|
||||
lcdm001_string (Driver *drvthis, int x, int y, char *string)
|
||||
{
|
||||
int offset, siz;
|
||||
|
||||
@@ -420,53 +395,53 @@ lcdm001_string (int x, int y, char string[])
|
||||
ValidY(y);
|
||||
|
||||
x--; y--; // Convert 1-based coords to 0-based...
|
||||
offset = (y * lcdm001->wid) + x;
|
||||
siz = (lcdm001->wid * lcdm001->hgt) - offset - 1;
|
||||
offset = (y * width) + x;
|
||||
siz = (width * height) - offset - 1;
|
||||
siz = siz > strlen(string) ? strlen(string) : siz;
|
||||
|
||||
memcpy(lcdm001->framebuf + offset, string, siz);
|
||||
memcpy(framebuf + offset, string, siz);
|
||||
|
||||
debug (RPT_DEBUG, "LCDM001: printed string at (%d,%d)", x, y);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Controls LEDs
|
||||
static void
|
||||
lcdm001_output (int on)
|
||||
MODULE_EXPORT void
|
||||
lcdm001_output (Driver *drvthis, int state)
|
||||
{
|
||||
char out[5];
|
||||
int one = 0, two = 0;
|
||||
|
||||
if (on<=255)
|
||||
if (state<=255)
|
||||
{
|
||||
one=on;
|
||||
one=state;
|
||||
two=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
one = on & 0xff;
|
||||
two = (on >> 8) & 0xff;
|
||||
one = state & 0xff;
|
||||
two = (state >> 8) & 0xff;
|
||||
}
|
||||
snprintf (out, sizeof(out), "~L%c%c",one,two);
|
||||
write(fd,out,4);
|
||||
|
||||
debug (RPT_DEBUG, "LCDM001: current LED state: %d", on);
|
||||
debug (RPT_DEBUG, "LCDM001: current LED state: %d", state);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a vertical bar, from the bottom of the screen up.
|
||||
//
|
||||
static void
|
||||
lcdm001_vbar(int x, int len)
|
||||
MODULE_EXPORT void
|
||||
lcdm001_vbar(Driver *drvthis, int x, int len)
|
||||
{
|
||||
int y = 4;
|
||||
|
||||
debug (RPT_DEBUG , "LCDM001: vertical bar at %d set to %d", x, len);
|
||||
|
||||
while (len >= 8)
|
||||
while (len >= LCD_DEFAULT_CELLHEIGHT)
|
||||
{
|
||||
lcdm001_chr(x, y, 0xFF);
|
||||
len -= 8;
|
||||
lcdm001_chr(drvthis, x, y, 0xFF);
|
||||
len -= LCD_DEFAULT_CELLHEIGHT;
|
||||
y--;
|
||||
}
|
||||
|
||||
@@ -480,8 +455,8 @@ lcdm001_vbar(int x, int len)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
static void
|
||||
lcdm001_hbar(int x, int y, int len)
|
||||
MODULE_EXPORT void
|
||||
lcdm001_hbar(Driver *drvthis, int x, int y, int len)
|
||||
{
|
||||
|
||||
ValidX(x);
|
||||
@@ -491,16 +466,16 @@ lcdm001_hbar(int x, int y, int len)
|
||||
|
||||
//TODO: Improve this function
|
||||
|
||||
while((x <= lcdm001->wid) && (len > 0))
|
||||
while((x <= width) && (len > 0))
|
||||
{
|
||||
if(len < lcdm001->cellwid)
|
||||
if(len < LCD_DEFAULT_CELLWIDTH)
|
||||
{
|
||||
//lcdm001_chr(x, y, 0x98 + len);
|
||||
break;
|
||||
}
|
||||
|
||||
lcdm001_chr(x, y, 0xFF);
|
||||
len -= lcdm001->cellwid;
|
||||
lcdm001_chr(drvthis, x, y, 0xFF);
|
||||
len -= LCD_DEFAULT_CELLWIDTH;
|
||||
x++;
|
||||
}
|
||||
|
||||
@@ -510,7 +485,8 @@ lcdm001_hbar(int x, int y, int len)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Writes a big number.
|
||||
//
|
||||
static void lcdm001_num (int x, int num)
|
||||
MODULE_EXPORT void
|
||||
lcdm001_num (Driver *drvthis, int x, int num)
|
||||
{
|
||||
int y, dx;
|
||||
|
||||
@@ -520,14 +496,14 @@ static void lcdm001_num (int x, int num)
|
||||
|
||||
for (y = 1; y < 5; y++)
|
||||
for (dx = 0; dx < 3; dx++)
|
||||
lcdm001_chr (x + dx, y, num_icon[num][y-1][dx]);
|
||||
lcdm001_chr (drvthis, x + dx, y, num_icon[num][y-1][dx]);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets character 0 to an icon...
|
||||
//
|
||||
void
|
||||
lcdm001_icon (int which, char dest)
|
||||
MODULE_EXPORT void
|
||||
lcdm001_icon (Driver *drvthis, int which, char dest)
|
||||
{
|
||||
|
||||
/*Heartbeat workaround:
|
||||
@@ -549,27 +525,13 @@ lcdm001_icon (int which, char dest)
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Draws the framebuffer on the display.
|
||||
//
|
||||
// The commented-out code is from the text driver.
|
||||
//
|
||||
void
|
||||
lcdm001_draw_frame (char *dat)
|
||||
{
|
||||
|
||||
//TODO: Check whether this is still correct
|
||||
|
||||
write(fd,lcdm001->framebuf,80);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Tries to read a character from an input device...
|
||||
//
|
||||
// Return 0 for "nothing available".
|
||||
//
|
||||
static char
|
||||
lcdm001_getkey ()
|
||||
MODULE_EXPORT char
|
||||
lcdm001_getkey (Driver *drvthis)
|
||||
{
|
||||
char in = 0;
|
||||
read (fd, &in, 1);
|
||||
@@ -589,8 +551,8 @@ lcdm001_getkey ()
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Does the heartbeat...
|
||||
//
|
||||
static void
|
||||
lcdm001_heartbeat (int type)
|
||||
MODULE_EXPORT void
|
||||
lcdm001_heartbeat (Driver *drvthis, int type)
|
||||
{
|
||||
static int timer = 0;
|
||||
int whichIcon;
|
||||
@@ -605,13 +567,13 @@ lcdm001_heartbeat (int type)
|
||||
|
||||
// This defines a custom character EVERY time...
|
||||
// not efficient... is this necessary?
|
||||
lcdm001_icon (whichIcon, 0);
|
||||
lcdm001_icon (drvthis, whichIcon, 0);
|
||||
|
||||
// Put character on screen...
|
||||
lcdm001_chr (lcdm001->wid, 1, 0);
|
||||
lcdm001_chr (drvthis, width, 1, 0);
|
||||
|
||||
// change display...
|
||||
lcdm001_flush ();
|
||||
lcdm001_flush (drvthis);
|
||||
}
|
||||
|
||||
timer++;
|
||||
|
||||
@@ -30,10 +30,27 @@
|
||||
lcdm001.h
|
||||
******************************************************************/
|
||||
|
||||
// REMOVE: I don't thing this is actualy needed.
|
||||
// extern lcd_logical_driver *lcdm001;
|
||||
/* REMOVE: I don't thing this is actualy needed. */
|
||||
/* extern lcd_logical_driver *lcdm001; */
|
||||
|
||||
int lcdm001_init (struct lcd_logical_driver *driver, char *args);
|
||||
int lcdm001_init (struct lcd_logical_driver *driver, char *args);
|
||||
MODULE_EXPORT void lcdm001_close (Driver *drvthis);
|
||||
MODULE_EXPORT int lcdm001_width (Driver *drvthis);
|
||||
MODULE_EXPORT int lcdm001_height (Driver *drvthis);
|
||||
MODULE_EXPORT void lcdm001_clear (Driver *drvthis);
|
||||
MODULE_EXPORT void lcdm001_flush (Driver *drvthis);
|
||||
MODULE_EXPORT void lcdm001_string (Driver *drvthis, int x, int y, char *string);
|
||||
MODULE_EXPORT void lcdm001_chr (Driver *drvthis, int x, int y, char c);
|
||||
|
||||
MODULE_EXPORT void lcdm001_vbar (Driver *drvthis, int x, int len);
|
||||
MODULE_EXPORT void lcdm001_hbar (Driver *drvthis, int x, int y, int len);
|
||||
MODULE_EXPORT void lcdm001_num (Driver *drvthis, int x, int num);
|
||||
MODULE_EXPORT void lcdm001_icon (Driver *drvthis, int which, char dest);
|
||||
MODULE_EXPORT void lcdm001_heartbeat (Driver *drvthis, int type);
|
||||
|
||||
MODULE_EXPORT void lcdm001_output (Driver *drvthis, int on);
|
||||
|
||||
MODULE_EXPORT char lcdm001_getkey (Driver *drvthis);
|
||||
|
||||
#define DEFAULT_DEVICE "/dev/lcd"
|
||||
#define DEFAULT_CURSORBLINK 0
|
||||
@@ -41,7 +58,7 @@ int lcdm001_init (struct lcd_logical_driver *driver, char *args);
|
||||
/*Heartbeat workaround
|
||||
set chars to be displayed instead of "normal" icons*/
|
||||
|
||||
#define OPEN_HEART ' ' //This combination is at least visible
|
||||
#define OPEN_HEART ' ' /* This combination is at least visible */
|
||||
#define FILLED_HEART '*'
|
||||
#define PAD 255
|
||||
|
||||
|
||||
+20
-12
@@ -17,7 +17,6 @@
|
||||
#define __u32 unsigned int
|
||||
#define __u8 unsigned char
|
||||
|
||||
#include "shared/debug.h"
|
||||
#include "shared/str.h"
|
||||
|
||||
#define NAME_LENGTH 128
|
||||
@@ -33,12 +32,17 @@ struct sockaddr_un addr;
|
||||
|
||||
static struct lirc_config *config;
|
||||
|
||||
// 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 = "LB216_";
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// Base "class" to derive from ///////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
lcd_logical_driver *lircin;
|
||||
|
||||
//void sigterm(int sig)
|
||||
//{
|
||||
// ir_free_commands();
|
||||
@@ -46,8 +50,8 @@ lcd_logical_driver *lircin;
|
||||
// raise(sig);
|
||||
//}
|
||||
|
||||
void
|
||||
lircin_close ()
|
||||
MODULE_EXPORT void
|
||||
lircin_close (Driver * drvthis)
|
||||
{
|
||||
lirc_freeconfig (config);
|
||||
lirc_deinit ();
|
||||
@@ -58,8 +62,8 @@ lircin_close ()
|
||||
//
|
||||
// Return 0 for "nothing available".
|
||||
//
|
||||
char
|
||||
lircin_getkey ()
|
||||
MODULE_EXPORT char
|
||||
lircin_getkey (Driver * drvthis)
|
||||
{
|
||||
char key;
|
||||
char *ir, *cmd;
|
||||
@@ -84,15 +88,19 @@ lircin_getkey ()
|
||||
// init() should set up any device-specific stuff, and
|
||||
// point all the function pointers.
|
||||
int
|
||||
lircin_init (struct lcd_logical_driver *driver, char *args)
|
||||
lircin_init (Driver * drvthis, char *args)
|
||||
{
|
||||
|
||||
/* assign funktions */
|
||||
|
||||
lircin = driver;
|
||||
// Set variables for server
|
||||
drvthis->api_version = api_version;
|
||||
drvthis->stay_in_foreground = &stay_in_foreground;
|
||||
drvthis->supports_multiple = &supports_multiple;
|
||||
|
||||
driver->getkey = lircin_getkey;
|
||||
driver->close = lircin_close;
|
||||
// Set the functions the driver supports
|
||||
drvthis->getkey = lircin_getkey;
|
||||
drvthis->close = lircin_close;
|
||||
|
||||
/* open socket to lirc */
|
||||
|
||||
@@ -113,5 +121,5 @@ lircin_init (struct lcd_logical_driver *driver, char *args)
|
||||
fcntl (fd, F_SETFL, O_NONBLOCK);
|
||||
fcntl (fd, F_SETFD, FD_CLOEXEC);
|
||||
|
||||
return 1; // 200 is arbitrary. (must be 1 or more)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#ifndef LCD_LIRCIN_H
|
||||
#define LCD_LIRCIN_H
|
||||
|
||||
extern lcd_logical_driver *lircin;
|
||||
#include "lcd.h"
|
||||
|
||||
int lircin_init (struct lcd_logical_driver *driver, char *args);
|
||||
void lircin_close ();
|
||||
char lircin_getkey ();
|
||||
int lircin_init (Driver * drvthis, char *args);
|
||||
MODULE_EXPORT void lircin_close (Driver * drvthis);
|
||||
MODULE_EXPORT char lircin_getkey (Driver * drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef REPORT_H
|
||||
#define REPORT_H
|
||||
|
||||
/* DEBUGGING / REPORTING FOR DRIVERS
|
||||
*
|
||||
* This file uses the reporting functions from the server core.
|
||||
* See the file shared/report.h for details.
|
||||
*
|
||||
* This file assumes that the drivers have a drvthis parameter that contains the
|
||||
* current driver structure. It redefines report to make its use simple:
|
||||
*
|
||||
* report( RPT_ERR, "report this: %s", str );
|
||||
* debug( RPT_ERR, "report this if debug enabled: %s", str );
|
||||
*
|
||||
*/
|
||||
|
||||
// Reporting levels
|
||||
#define RPT_CRIT 0
|
||||
#define RPT_ERR 1
|
||||
#define RPT_WARNING 2
|
||||
#define RPT_NOTICE 3
|
||||
#define RPT_INFO 4
|
||||
#define RPT_DEBUG 5
|
||||
|
||||
#define report drvthis->report
|
||||
// This assumes drvthis is locally defined... Anyone has a better idea ?
|
||||
|
||||
static inline void dont_report( const int level, const char *format, .../*args*/ )
|
||||
{} // The idea is that this gets optimized out
|
||||
|
||||
#ifdef DEBUG
|
||||
# define debug report
|
||||
#else
|
||||
# define debug dont_report
|
||||
#endif /*DEBUG*/
|
||||
|
||||
#endif
|
||||
+904
-872
File diff suppressed because it is too large
Load Diff
+28
-24
@@ -1,24 +1,28 @@
|
||||
/*
|
||||
* Driver for SED1330 graphical displays
|
||||
* Header file
|
||||
*/
|
||||
|
||||
#ifndef SED1330_H
|
||||
#define SED1330_H
|
||||
|
||||
#include "lcd.h"
|
||||
|
||||
int sed1330_init( lcd_logical_driver * driver, char *args );
|
||||
void sed1330_close();
|
||||
void sed1330_clear();
|
||||
void sed1330_string( int x, int y, char lcd[] );
|
||||
void sed1330_chr( int x, int y, char c );
|
||||
void sed1330_flush();
|
||||
void sed1330_cursor( int x, int y, char state );
|
||||
void sed1330_backlight( int on );
|
||||
void sed1330_vbar( int x, int len );
|
||||
void sed1330_hbar( int x, int y, int len );
|
||||
void sed1330_num( int x, int num );
|
||||
void sed1330_heartbeat( int type );
|
||||
|
||||
#endif
|
||||
/*
|
||||
* Driver for SED1330 graphical displays
|
||||
* Header file
|
||||
*/
|
||||
|
||||
#ifndef SED1330_H
|
||||
#define SED1330_H
|
||||
|
||||
#include "lcd.h"
|
||||
|
||||
int sed1330_init( Driver * drvthis, char *args );
|
||||
MODULE_EXPORT void sed1330_close( Driver * drvthis );
|
||||
MODULE_EXPORT int sed1330_width( Driver * drvthis );
|
||||
MODULE_EXPORT int sed1330_height( Driver * drvthis );
|
||||
MODULE_EXPORT void sed1330_clear( Driver * drvthis );
|
||||
MODULE_EXPORT void sed1330_flush( Driver * drvthis );
|
||||
MODULE_EXPORT void sed1330_string( Driver * drvthis, int x, int y, char lcd[] );
|
||||
MODULE_EXPORT void sed1330_chr( Driver * drvthis, int x, int y, char c );
|
||||
|
||||
MODULE_EXPORT void sed1330_vbar( Driver * drvthis, int x, int y, int len, int promille, int pattern );
|
||||
MODULE_EXPORT void sed1330_hbar( Driver * drvthis, int x, int y, int len, int promille, int pattern );
|
||||
MODULE_EXPORT void sed1330_num( Driver * drvthis, int x, int num );
|
||||
MODULE_EXPORT void sed1330_heartbeat( Driver * drvthis, int type );
|
||||
MODULE_EXPORT void sed1330_cursor( Driver * drvthis, int x, int y, char state );
|
||||
|
||||
MODULE_EXPORT void sed1330_backlight( Driver * drvthis, int on );
|
||||
|
||||
#endif
|
||||
|
||||
+122
-121
@@ -53,8 +53,18 @@
|
||||
|
||||
|
||||
unsigned int sed1520_lptport = LPTPORT;
|
||||
char *framebuf = NULL;
|
||||
int width = LCD_DEFAULT_WIDTH;
|
||||
int height = LCD_DEFAULT_HEIGHT;
|
||||
int cellwidth = LCD_DEFAULT_CELLWIDTH;
|
||||
int cellheight = LCD_DEFAULT_CELLHEIGHT;
|
||||
|
||||
lcd_logical_driver *sed1520;
|
||||
|
||||
// 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 = "sed1520_";
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// writes command value to one or both sed1520 selected by chip
|
||||
@@ -125,23 +135,21 @@ drawchar2fb (int x, int y, unsigned char z)
|
||||
(((fontmap[(int) z][j] * 2) & (1 << i)) / (1 << i)) *
|
||||
(1 << j);
|
||||
}
|
||||
sed1520->framebuf[(y * 122) + (x * 6) + (6 - i)] = k;
|
||||
framebuf[(y * 122) + (x * 6) + (6 - i)] = k;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// This initialises the stuff. We support supplying port as
|
||||
// This initialises the stuff. We support supplying port as
|
||||
// a command line argument.
|
||||
//
|
||||
//
|
||||
int
|
||||
sed1520_init (struct lcd_logical_driver *driver, char *args)
|
||||
sed1520_init (Driver *drvthis, char *args)
|
||||
{
|
||||
char *argv[64], *str;
|
||||
int argc, i;
|
||||
|
||||
sed1520 = driver;
|
||||
|
||||
if (args)
|
||||
if ((str = (char *) malloc (strlen (args) + 1)))
|
||||
strcpy (str, args);
|
||||
@@ -195,12 +203,23 @@ sed1520_init (struct lcd_logical_driver *driver, char *args)
|
||||
}
|
||||
}
|
||||
|
||||
driver->wid = 20;
|
||||
driver->hgt = 4;
|
||||
// driver->wid = 20;
|
||||
// driver->hgt = 4;
|
||||
|
||||
if (timing_init() == -1)
|
||||
return -1;
|
||||
|
||||
// Allocate our framebuffer
|
||||
framebuf = malloc (122 * 4);
|
||||
if (!framebuf)
|
||||
{
|
||||
// sed1520_close ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// clear screen
|
||||
memset (framebuf, 0, 122 * 4);
|
||||
|
||||
// Initialize the Port and the sed1520s
|
||||
if(port_access(sed1520_lptport)) return -1;
|
||||
if(port_access(sed1520_lptport+2)) return -1;
|
||||
@@ -212,87 +231,105 @@ sed1520_init (struct lcd_logical_driver *driver, char *args)
|
||||
writecommand (0xC0, CS1 + CS2);
|
||||
selectpage (3);
|
||||
|
||||
driver->cellwid = 6;
|
||||
driver->cellhgt = 8;
|
||||
cellwidth = 6;
|
||||
cellheight = 8;
|
||||
|
||||
// The Framebuffer LCDproc allocates by default is too small,
|
||||
// so we free() it (if it exists) and allocate one of adequate size.
|
||||
if (!driver->framebuf)
|
||||
free (driver->framebuf);
|
||||
|
||||
driver->framebuf = malloc (122 * 4);
|
||||
if (!driver->framebuf)
|
||||
{
|
||||
sed1520_close ();
|
||||
return -1;
|
||||
}
|
||||
// Set variables for server
|
||||
drvthis->api_version = api_version;
|
||||
drvthis->stay_in_foreground = &stay_in_foreground;
|
||||
drvthis->supports_multiple = &supports_multiple;
|
||||
|
||||
// clear screen
|
||||
memset (driver->framebuf, 0, 122 * 4);
|
||||
// Set the functions the driver supports
|
||||
drvthis->clear = sed1520_clear;
|
||||
drvthis->string = sed1520_string;
|
||||
drvthis->chr = sed1520_chr;
|
||||
drvthis->old_vbar = sed1520_vbar;
|
||||
drvthis->old_hbar = sed1520_hbar;
|
||||
drvthis->num = sed1520_num;
|
||||
drvthis->init = sed1520_init;
|
||||
drvthis->close = sed1520_close;
|
||||
drvthis->flush = sed1520_flush;
|
||||
drvthis->set_char = sed1520_set_char;
|
||||
|
||||
driver->clear = sed1520_clear;
|
||||
driver->string = sed1520_string;
|
||||
driver->chr = sed1520_chr;
|
||||
driver->vbar = sed1520_vbar;
|
||||
driver->hbar = sed1520_hbar;
|
||||
driver->num = sed1520_num;
|
||||
driver->init = sed1520_init;
|
||||
driver->close = sed1520_close;
|
||||
driver->flush = sed1520_flush;
|
||||
driver->flush_box = sed1520_flush_box;
|
||||
driver->set_char = sed1520_set_char;
|
||||
|
||||
driver->icon = sed1520_icon;
|
||||
driver->draw_frame = sed1520_draw_frame;
|
||||
drvthis->old_icon = sed1520_icon;
|
||||
// We dont't need init for vbar,hbar and friends.
|
||||
//driver->init_hbar = NULL;
|
||||
//driver->init_vbar = NULL;
|
||||
//driver->init_num = NULL;
|
||||
//drvthis->init_hbar = NULL;
|
||||
//drvthis->init_vbar = NULL;
|
||||
//drvthis->init_num = NULL;
|
||||
// Neither contrast nor backlight are controllable.
|
||||
//driver->contrast = NULL;
|
||||
//driver->backlight = NULL;
|
||||
//drvthis->contrast = NULL;
|
||||
//drvthis->backlight = NULL;
|
||||
// There are some unused input lines that may be used for input,
|
||||
// but nothing is programmed so far.
|
||||
//driver->getkey = NULL;
|
||||
return 200; // 200 is arbitrary. (must be 1 or more)
|
||||
//drvthis->getkey = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Frees the frambuffer and exits the driver.
|
||||
//
|
||||
void
|
||||
sed1520_close ()
|
||||
MODULE_EXPORT void
|
||||
sed1520_close (Driver *drvthis)
|
||||
{
|
||||
if (sed1520->framebuf != NULL)
|
||||
free (sed1520->framebuf);
|
||||
sed1520->framebuf = NULL;
|
||||
if (framebuf != NULL)
|
||||
free (framebuf);
|
||||
framebuf = NULL;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display width
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
sed1520_width (Driver *drvthis)
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display height
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
sed1520_height (Driver *drvthis)
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clears the LCD screen
|
||||
//
|
||||
void
|
||||
sed1520_clear ()
|
||||
MODULE_EXPORT void
|
||||
sed1520_clear (Driver *drvthis)
|
||||
{
|
||||
memset (sed1520->framebuf, 0, 488);
|
||||
memset (framebuf, 0, 488);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// Flushes all output to the lcd...
|
||||
//
|
||||
void
|
||||
sed1520_flush ()
|
||||
MODULE_EXPORT void
|
||||
sed1520_flush (Driver *drvthis)
|
||||
{
|
||||
sed1520->draw_frame (sed1520->framebuf);
|
||||
int i, j;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
selectpage (i);
|
||||
selectcolumn (0, CS2) ;
|
||||
for (j = 0; j < 61; j++)
|
||||
writedata (framebuf[j + (i * 122)], CS2);
|
||||
selectcolumn (0, CS1) ;
|
||||
for (j = 61; j < 122; j++)
|
||||
writedata (framebuf[j + (i * 122)], CS1);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Prints a string on the lc display, at position (x,y). The
|
||||
// upper-left is (1,1), and the lower right should be (20,4).
|
||||
//
|
||||
void
|
||||
sed1520_string (int x, int y, char string[])
|
||||
MODULE_EXPORT void
|
||||
sed1520_string (Driver *drvthis, int x, int y, char string[])
|
||||
{
|
||||
int i;
|
||||
x--; // Convert 1-based coords to 0-based...
|
||||
@@ -308,8 +345,8 @@ sed1520_string (int x, int y, char string[])
|
||||
// Writes char c at position x,y into the framebuffer.
|
||||
// x and y are 1-based textmode coordinates.
|
||||
//
|
||||
void
|
||||
sed1520_chr (int x, int y, char c)
|
||||
MODULE_EXPORT void
|
||||
sed1520_chr (Driver *drvthis, int x, int y, char c)
|
||||
{
|
||||
y--;
|
||||
x--;
|
||||
@@ -317,14 +354,14 @@ sed1520_chr (int x, int y, char c)
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// This function draws a number num into the last 3 rows of the
|
||||
// This function draws a number num into the last 3 rows of the
|
||||
// framebuffer at 1-based position x. It should draw a 4-row font,
|
||||
// but methinks this would look a little stretched. When
|
||||
// num=10 a colon is drawn.
|
||||
// FIXME: make big numbers use less memory
|
||||
//
|
||||
void
|
||||
sed1520_num (int x, int num)
|
||||
MODULE_EXPORT void
|
||||
sed1520_num (Driver *drvthis, int x, int num)
|
||||
{
|
||||
int z, c, i, s;
|
||||
x--;
|
||||
@@ -349,7 +386,7 @@ sed1520_num (int x, int num)
|
||||
if (*(fontbigdp[(z * 8) + i] + c) == '.')
|
||||
s += 128;
|
||||
}
|
||||
sed1520->framebuf[(z * 122) + 122 + (x * 6) + c] = s;
|
||||
framebuf[(z * 122) + 122 + (x * 6) + c] = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -367,7 +404,7 @@ sed1520_num (int x, int num)
|
||||
if (*(fontbignum[num][z * 8 + i] + c) == '.')
|
||||
s += 128;
|
||||
}
|
||||
sed1520->framebuf[(z * 122) + 122 + (x * 6) + c] = s;
|
||||
framebuf[(z * 122) + 122 + (x * 6) + c] = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -381,10 +418,10 @@ sed1520_num (int x, int num)
|
||||
// can be altered. !Important: Characters have to be redraw
|
||||
// by drawchar2fb() to show their new shape. Because we use
|
||||
// a non-standard 6x8 font a *dat not calculated from
|
||||
// sed1520->width and sed1520->height will fail.
|
||||
// widthth and sed1520->height will fail.
|
||||
//
|
||||
void
|
||||
sed1520_set_char (int n, char *dat)
|
||||
MODULE_EXPORT void
|
||||
sed1520_set_char (Driver *drvthis, int n, char *dat)
|
||||
{
|
||||
|
||||
int row, col, i;
|
||||
@@ -406,11 +443,11 @@ sed1520_set_char (int n, char *dat)
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a vertical from the bottom up to the last 3 rows of the
|
||||
// Draws a vertical from the bottom up to the last 3 rows of the
|
||||
// framebuffer at 1-based position x. len is given in pixels.
|
||||
//
|
||||
void
|
||||
sed1520_vbar (int x, int len)
|
||||
MODULE_EXPORT void
|
||||
sed1520_vbar (Driver *drvthis, int x, int len)
|
||||
{
|
||||
int i, j, k;
|
||||
x--;
|
||||
@@ -426,12 +463,12 @@ sed1520_vbar (int x, int len)
|
||||
k += 1 << (7 - i);
|
||||
}
|
||||
|
||||
sed1520->framebuf[((3 - j) * 122) + (x * 6)] = 0;
|
||||
sed1520->framebuf[((3 - j) * 122) + (x * 6) + 1] = 0;
|
||||
sed1520->framebuf[((3 - j) * 122) + (x * 6) + 2] = k;
|
||||
sed1520->framebuf[((3 - j) * 122) + (x * 6) + 3] = k;
|
||||
sed1520->framebuf[((3 - j) * 122) + (x * 6) + 4] = k;
|
||||
sed1520->framebuf[((3 - j) * 122) + (x * 6) + 5] = 0;
|
||||
framebuf[((3 - j) * 122) + (x * 6)] = 0;
|
||||
framebuf[((3 - j) * 122) + (x * 6) + 1] = 0;
|
||||
framebuf[((3 - j) * 122) + (x * 6) + 2] = k;
|
||||
framebuf[((3 - j) * 122) + (x * 6) + 3] = k;
|
||||
framebuf[((3 - j) * 122) + (x * 6) + 4] = k;
|
||||
framebuf[((3 - j) * 122) + (x * 6) + 5] = 0;
|
||||
len -= 8;
|
||||
}
|
||||
|
||||
@@ -439,11 +476,11 @@ sed1520_vbar (int x, int len)
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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.
|
||||
//
|
||||
void
|
||||
sed1520_hbar (int x, int y, int len)
|
||||
MODULE_EXPORT void
|
||||
sed1520_hbar (Driver *drvthis, int x, int y, int len)
|
||||
{
|
||||
int i;
|
||||
x--;
|
||||
@@ -453,15 +490,15 @@ sed1520_hbar (int x, int y, int len)
|
||||
return;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
sed1520->framebuf[(y * 122) + (x * 6) + i] = 0x3C;
|
||||
framebuf[(y * 122) + (x * 6) + i] = 0x3C;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Reprogrammes character dest to contain an icon given by
|
||||
// Reprogrammes character dest to contain an icon given by
|
||||
// which. Calls set_char() to do this.
|
||||
//
|
||||
void
|
||||
sed1520_icon (int which, char dest)
|
||||
MODULE_EXPORT void
|
||||
sed1520_icon (Driver *drvthis, int which, char dest)
|
||||
{
|
||||
char icons[3][6 * 8] = {
|
||||
{
|
||||
@@ -495,42 +532,6 @@ sed1520_icon (int which, char dest)
|
||||
1, 0, 1, 0, 1, 0,}
|
||||
,
|
||||
};
|
||||
sed1520_set_char (dest, &icons[which][0]);
|
||||
sed1520_set_char (drvthis, dest, &icons[which][0]);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Send a rectangular area from lft,top to rgt,bot to the display
|
||||
// These coordinates are probably one-based, too. It's so fast to
|
||||
// flush the whole display that it makes no sense to flush less then
|
||||
// the whole display. Therefore this function redraws the whole
|
||||
// display.
|
||||
// FIXME: Check if this function is worth implementing.
|
||||
//
|
||||
void
|
||||
sed1520_flush_box (int lft, int top, int rgt, int bot)
|
||||
{
|
||||
sed1520_flush ();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Outputs the whole framebuffer *dat to the display. This Display
|
||||
// contains 2 Controllers, each of them controlling one half of the
|
||||
// screen.
|
||||
//
|
||||
void
|
||||
sed1520_draw_frame (char *dat)
|
||||
{
|
||||
int i, j;
|
||||
if (!dat)
|
||||
return;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
selectpage (i);
|
||||
selectcolumn (0, CS2) ;
|
||||
for (j = 0; j < 61; j++)
|
||||
writedata (dat[j + (i * 122)], CS2);
|
||||
selectcolumn (0, CS1) ;
|
||||
for (j = 61; j < 122; j++)
|
||||
writedata (dat[j + (i * 122)], CS1);
|
||||
}
|
||||
}
|
||||
|
||||
+16
-14
@@ -1,20 +1,22 @@
|
||||
#ifndef SED1520_H
|
||||
#define SED1520_H
|
||||
|
||||
extern lcd_logical_driver *sed1520;
|
||||
#include "lcd.h"
|
||||
|
||||
int sed1520_init (struct lcd_logical_driver *driver, char *args);
|
||||
void sed1520_close ();
|
||||
void sed1520_clear ();
|
||||
void sed1520_flush ();
|
||||
void sed1520_string (int x, int y, char string[]);
|
||||
void sed1520_chr (int x, int y, char c);
|
||||
void sed1520_vbar (int x, int len);
|
||||
void sed1520_hbar (int x, int y, int len);
|
||||
void sed1520_num (int x, int num);
|
||||
void sed1520_set_char (int n, char *dat);
|
||||
void sed1520_icon (int which, char dest);
|
||||
void sed1520_flush_box (int lft, int top, int rgt, int bot);
|
||||
void sed1520_draw_frame (char *dat);
|
||||
int sed1520_init (Driver *drvthis, char *args);
|
||||
MODULE_EXPORT void sed1520_close (Driver *drvthis);
|
||||
MODULE_EXPORT int sed1520_width (Driver *drvthis);
|
||||
MODULE_EXPORT int sed1520_height (Driver *drvthis);
|
||||
MODULE_EXPORT void sed1520_clear (Driver *drvthis);
|
||||
MODULE_EXPORT void sed1520_flush (Driver *drvthis);
|
||||
MODULE_EXPORT void sed1520_string (Driver *drvthis, int x, int y, char string[]);
|
||||
MODULE_EXPORT void sed1520_chr (Driver *drvthis, int x, int y, char c);
|
||||
|
||||
MODULE_EXPORT void sed1520_vbar (Driver *drvthis, int x, int len);
|
||||
MODULE_EXPORT void sed1520_hbar (Driver *drvthis, int x, int y, int len);
|
||||
MODULE_EXPORT void sed1520_num (Driver *drvthis, int x, int num);
|
||||
MODULE_EXPORT void sed1520_icon (Driver *drvthis, int which, char dest);
|
||||
|
||||
MODULE_EXPORT void sed1520_set_char (Driver *drvthis, int n, char *dat);
|
||||
|
||||
#endif
|
||||
|
||||
+142
-125
@@ -71,7 +71,7 @@
|
||||
|
||||
// Choose Colors: FLINE: First line text color, TEXT: Text color, CBACK: Character Background Color
|
||||
// CBORD: Character Border Color, SBACK: Screen Background color
|
||||
// 0:Black, 1: Blue, 2:Green, 3: Cyan, 4: Red, 5: Magenta, 6: Yellow, 7: White
|
||||
// 0:Black, 1: Blue, 2:Green, 3: Cyan, 4: Red, 5: Magenta, 6: Yellow, 7: White
|
||||
#define STV5730_COL_FLINE 4
|
||||
#define STV5730_COL_TEXT 1
|
||||
#define STV5730_COL_CBACK 3
|
||||
@@ -83,6 +83,15 @@
|
||||
unsigned int stv5730_lptport = LPTPORT;
|
||||
unsigned int stv5730_charattrib = STV5730_ATTRIB;
|
||||
unsigned int stv5730_flags = 0;
|
||||
char * stv5730_framebuf = NULL;
|
||||
|
||||
// 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 = "stv5730_";
|
||||
|
||||
|
||||
|
||||
// Translation map ascii->stv5730 charset
|
||||
unsigned char stv5730_to_ascii[256] =
|
||||
@@ -121,7 +130,6 @@ unsigned char stv5730_to_ascii[256] =
|
||||
};
|
||||
|
||||
|
||||
lcd_logical_driver *stv5730;
|
||||
|
||||
//static void stv5730_upause (int delayCalls);
|
||||
#define stv5730_upause timing_uPause
|
||||
@@ -263,22 +271,20 @@ stv5730_drawchar2fb (int x, int y, unsigned char z)
|
||||
|
||||
if (x < 0 || x >= STV5730_WID || y < 0 || y >= STV5730_HGT)
|
||||
return;
|
||||
stv5730->framebuf[(y * STV5730_WID) + x] = stv5730_to_ascii[(unsigned int) z];
|
||||
stv5730_framebuf[(y * STV5730_WID) + x] = stv5730_to_ascii[(unsigned int) z];
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// This initialises the stuff. We support supplying port as
|
||||
// This initialises the stuff. We support supplying port as
|
||||
// a command line argument.
|
||||
//
|
||||
//
|
||||
int
|
||||
stv5730_init (struct lcd_logical_driver *driver, char *args)
|
||||
stv5730_init (Driver *drvthis, char *args)
|
||||
{
|
||||
char *argv[64], *str;
|
||||
int argc, i;
|
||||
|
||||
stv5730 = driver;
|
||||
|
||||
if (args)
|
||||
if ((str = (char *) malloc (strlen (args) + 1)))
|
||||
strcpy (str, args);
|
||||
@@ -333,9 +339,6 @@ stv5730_init (struct lcd_logical_driver *driver, char *args)
|
||||
}
|
||||
}
|
||||
|
||||
driver->wid = STV5730_WID;
|
||||
driver->hgt = STV5730_HGT;
|
||||
|
||||
if (timing_init() == -1)
|
||||
return -1;
|
||||
|
||||
@@ -426,89 +429,150 @@ stv5730_init (struct lcd_logical_driver *driver, char *args)
|
||||
stv5730_write16bit (0x10C0);
|
||||
}
|
||||
|
||||
|
||||
// The Framebuffer LCDproc allocates by default is too small,
|
||||
// so we free() it and allocate one of adequate size.
|
||||
if (!driver->framebuf)
|
||||
free (driver->framebuf);
|
||||
|
||||
driver->framebuf = malloc (STV5730_WID * STV5730_HGT);
|
||||
if (!driver->framebuf)
|
||||
// Alocate our own framebuffer
|
||||
stv5730_framebuf = malloc (STV5730_WID * STV5730_HGT);
|
||||
if (!stv5730_framebuf)
|
||||
{
|
||||
stv5730_close ();
|
||||
return -1;
|
||||
stv5730_close (drvthis);
|
||||
return -4;
|
||||
}
|
||||
|
||||
// clear screen
|
||||
memset (driver->framebuf, 0, STV5730_WID * STV5730_HGT);
|
||||
memset (stv5730_framebuf, 0, STV5730_WID * STV5730_HGT);
|
||||
|
||||
driver->cellwid = 4;
|
||||
driver->cellhgt = 6;
|
||||
// Set variables for server
|
||||
drvthis->api_version = api_version;
|
||||
drvthis->stay_in_foreground = &stay_in_foreground;
|
||||
drvthis->supports_multiple = &supports_multiple;
|
||||
|
||||
driver->clear = stv5730_clear;
|
||||
driver->string = stv5730_string;
|
||||
driver->chr = stv5730_chr;
|
||||
driver->vbar = stv5730_vbar;
|
||||
driver->hbar = stv5730_hbar;
|
||||
driver->num = stv5730_num;
|
||||
driver->init = stv5730_init;
|
||||
driver->close = stv5730_close;
|
||||
driver->flush = stv5730_flush;
|
||||
driver->flush_box = stv5730_flush_box;
|
||||
// Set the functions the driver supports
|
||||
drvthis->clear = stv5730_clear;
|
||||
drvthis->string = stv5730_string;
|
||||
drvthis->chr = stv5730_chr;
|
||||
drvthis->old_vbar = stv5730_vbar;
|
||||
drvthis->old_hbar = stv5730_hbar;
|
||||
drvthis->num = stv5730_num;
|
||||
drvthis->init = stv5730_init;
|
||||
drvthis->close = stv5730_close;
|
||||
drvthis->width = stv5730_width;
|
||||
drvthis->height = stv5730_height;
|
||||
drvthis->cellwidth = stv5730_cellwidth;
|
||||
drvthis->cellheight = stv5730_cellheight;
|
||||
drvthis->flush = stv5730_flush;
|
||||
// We dont't have any programmable chars.
|
||||
//driver->set_char = NULL;
|
||||
//drvthis->set_char = NULL;
|
||||
|
||||
driver->icon = stv5730_icon;
|
||||
driver->draw_frame = stv5730_draw_frame;
|
||||
drvthis->old_icon = stv5730_icon;
|
||||
// We dont't need init for vbar,hbar and friends.
|
||||
//driver->init_hbar = NULL;
|
||||
//driver->init_vbar = NULL;
|
||||
//driver->init_num = NULL;
|
||||
//drvthis->init_hbar = NULL;
|
||||
//drvthis->init_vbar = NULL;
|
||||
//drvthis->init_num = NULL;
|
||||
// Neither contrast nor backlight are controllable.
|
||||
//driver->contrast = NULL;
|
||||
//driver->backlight = NULL;
|
||||
//drvthis->contrast = NULL;
|
||||
//drvthis->backlight = NULL;
|
||||
// There are some unused input lines that may be used for input,
|
||||
// but nothing is programmed so far.
|
||||
//driver->getkey = NULL;
|
||||
return 200; // 200 is arbitrary. (must be 1 or more)
|
||||
//drvthis->getkey = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Frees the framebuffer and exits the driver.
|
||||
//
|
||||
void
|
||||
stv5730_close ()
|
||||
MODULE_EXPORT void
|
||||
stv5730_close (Driver *drvthis)
|
||||
{
|
||||
if (stv5730->framebuf != NULL)
|
||||
free (stv5730->framebuf);
|
||||
stv5730->framebuf = NULL;
|
||||
if (stv5730_framebuf != NULL)
|
||||
free (stv5730_framebuf);
|
||||
stv5730_framebuf = NULL;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display width
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
stv5730_width (Driver *drvthis)
|
||||
{
|
||||
return STV5730_WID;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display height
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
stv5730_height (Driver *drvthis)
|
||||
{
|
||||
return STV5730_HGT;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the number of pixels a character is wide
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
stv5730_cellwidth (Driver *drvthis)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the number of pixels a character is high
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
stv5730_cellheight (Driver *drvthis)
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
// cellwidth and cellheight are only needed for old_vbar.
|
||||
// Therefor these values are now hardcoded into these functions.
|
||||
// When old_vbar is not used anymore, these two functions can be removed.
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clears the screen
|
||||
//
|
||||
void
|
||||
stv5730_clear ()
|
||||
MODULE_EXPORT void
|
||||
stv5730_clear (Driver *drvthis)
|
||||
{
|
||||
memset (stv5730->framebuf, 0x0B, STV5730_WID * STV5730_HGT);
|
||||
memset (stv5730_framebuf, 0x0B, STV5730_WID * STV5730_HGT);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// Flushes all output to the lcd...
|
||||
//
|
||||
void
|
||||
stv5730_flush ()
|
||||
MODULE_EXPORT void
|
||||
stv5730_flush (Driver *drvthis)
|
||||
{
|
||||
stv5730->draw_frame (stv5730->framebuf);
|
||||
int i, j, atr;
|
||||
|
||||
stv5730_locate (0, 0);
|
||||
|
||||
for (i = 0; i < STV5730_HGT; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
atr = (STV5730_COL_FLINE << 8);
|
||||
else
|
||||
atr = (STV5730_COL_TEXT << 8);
|
||||
stv5730_write16bit (0x1000 + atr + stv5730_framebuf[i * STV5730_WID] +
|
||||
stv5730_charattrib);
|
||||
for (j = 1; j < STV5730_WID; j++)
|
||||
{
|
||||
if (stv5730_framebuf[j + (i * STV5730_WID) - 1] !=
|
||||
stv5730_framebuf[j + (i * STV5730_WID)])
|
||||
stv5730_write8bit (stv5730_framebuf[j + (i * STV5730_WID)]);
|
||||
else
|
||||
stv5730_write0bit ();
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Prints a string on the screen, at position (x,y). The
|
||||
// upper-left is (1,1), and the lower right should be (28,11).
|
||||
//
|
||||
void
|
||||
stv5730_string (int x, int y, char string[])
|
||||
MODULE_EXPORT void
|
||||
stv5730_string (Driver *drvthis, int x, int y, char string[])
|
||||
{
|
||||
int i;
|
||||
x--; // Convert 1-based coords to 0-based...
|
||||
@@ -524,8 +588,8 @@ stv5730_string (int x, int y, char string[])
|
||||
// Writes char c at position x,y into the framebuffer.
|
||||
// x and y are 1-based textmode coordinates.
|
||||
//
|
||||
void
|
||||
stv5730_chr (int x, int y, char c)
|
||||
MODULE_EXPORT void
|
||||
stv5730_chr (Driver *drvthis, int x, int y, char c)
|
||||
{
|
||||
y--;
|
||||
x--;
|
||||
@@ -536,8 +600,8 @@ stv5730_chr (int x, int y, char c)
|
||||
// This function draws ugly big numbers. We could use the zoom
|
||||
// feature of the stv5730 if we'd know when big numbers start
|
||||
// and stop.
|
||||
void
|
||||
stv5730_num (int x, int num)
|
||||
MODULE_EXPORT void
|
||||
stv5730_num (Driver *drvthis, int x, int num)
|
||||
{
|
||||
|
||||
int i, j;
|
||||
@@ -566,11 +630,11 @@ stv5730_num (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 to the last 7 rows of the
|
||||
// framebuffer at 1-based position x. len is given in pixels.
|
||||
//
|
||||
void
|
||||
stv5730_vbar (int x, int len)
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
stv5730_vbar (Driver *drvthis, int x, int len)
|
||||
{
|
||||
|
||||
int i;
|
||||
@@ -584,11 +648,11 @@ stv5730_vbar (int x, int len)
|
||||
|
||||
if (len >= (i + 6))
|
||||
{
|
||||
stv5730->framebuf[((10 - (i / 6)) * STV5730_WID) + x] = 0x77;
|
||||
stv5730_framebuf[((10 - (i / 6)) * STV5730_WID) + x] = 0x77;
|
||||
}
|
||||
else
|
||||
{
|
||||
stv5730->framebuf[((10 - (i / 6)) * STV5730_WID) + x] =
|
||||
stv5730_framebuf[((10 - (i / 6)) * STV5730_WID) + x] =
|
||||
0x72 + (len % 6);
|
||||
}
|
||||
}
|
||||
@@ -597,12 +661,12 @@ stv5730_vbar (int x, int len)
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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.
|
||||
// It uses the STV5730 'channel-tuning' chars(0x64-0x68) to do
|
||||
// It uses the STV5730 'channel-tuning' chars(0x64-0x68) to do
|
||||
// this.
|
||||
void
|
||||
stv5730_hbar (int x, int y, int len)
|
||||
MODULE_EXPORT void
|
||||
stv5730_hbar (Driver *drvthis, int x, int y, int len)
|
||||
{
|
||||
int i;
|
||||
x--;
|
||||
@@ -617,24 +681,24 @@ stv5730_hbar (int x, int y, int len)
|
||||
|
||||
if (len >= (i + 4))
|
||||
{
|
||||
stv5730->framebuf[(y * STV5730_WID) + x + (i / 5)] = 0x64;
|
||||
stv5730_framebuf[(y * STV5730_WID) + x + (i / 5)] = 0x64;
|
||||
}
|
||||
else
|
||||
{
|
||||
stv5730->framebuf[(y * STV5730_WID) + x + (i / 5)] =
|
||||
stv5730_framebuf[(y * STV5730_WID) + x + (i / 5)] =
|
||||
0x65 + (len % 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Reprogrammes character dest to contain an icon given by
|
||||
// which.
|
||||
// Reprogrammes character dest to contain an icon given by
|
||||
// which.
|
||||
// The STV5730 has no programmable chars. The charset is very
|
||||
// limited, it doesn't even contain a '%' char. But wait...
|
||||
// It contains a heartbeat char ! :-)
|
||||
void
|
||||
stv5730_icon (int which, char dest)
|
||||
MODULE_EXPORT void
|
||||
stv5730_icon (Driver *drvthis, int which, char dest)
|
||||
{
|
||||
switch (which)
|
||||
{
|
||||
@@ -654,50 +718,3 @@ stv5730_icon (int which, char dest)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Send a rectangular area from lft,top to rgt,bot to the display
|
||||
// These coordinates are probably one-based, too. It's so fast to
|
||||
// flush the whole display that it makes no sense to flush less then
|
||||
// the whole display. Therefore this function redraws the whole
|
||||
// display.
|
||||
// FIXME: Check if this function is worth implementing.
|
||||
//
|
||||
void
|
||||
stv5730_flush_box (int lft, int top, int rgt, int bot)
|
||||
{
|
||||
stv5730_flush ();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Outputs the whole framebuffer *dat to the display.
|
||||
// Attributes are set for every row only.
|
||||
// The first line has special attributes.
|
||||
void
|
||||
stv5730_draw_frame (char *dat)
|
||||
{
|
||||
int i, j, atr;
|
||||
if (!dat)
|
||||
return;
|
||||
|
||||
stv5730_locate (0, 0);
|
||||
|
||||
for (i = 0; i < STV5730_HGT; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
atr = (STV5730_COL_FLINE << 8);
|
||||
else
|
||||
atr = (STV5730_COL_TEXT << 8);
|
||||
stv5730_write16bit (0x1000 + atr + dat[i * STV5730_WID] +
|
||||
stv5730_charattrib);
|
||||
for (j = 1; j < STV5730_WID; j++)
|
||||
{
|
||||
if (dat[j + (i * STV5730_WID) - 1] !=
|
||||
dat[j + (i * STV5730_WID)])
|
||||
stv5730_write8bit (dat[j + (i * STV5730_WID)]);
|
||||
else
|
||||
stv5730_write0bit ();
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+15
-13
@@ -1,19 +1,21 @@
|
||||
#ifndef STV5730_H
|
||||
#define STV5730_H
|
||||
|
||||
extern lcd_logical_driver *stv5730;
|
||||
#include "lcd.h"
|
||||
|
||||
int stv5730_init (struct lcd_logical_driver *driver, char *args);
|
||||
void stv5730_close ();
|
||||
void stv5730_clear ();
|
||||
void stv5730_flush ();
|
||||
void stv5730_string (int x, int y, char string[]);
|
||||
void stv5730_chr (int x, int y, char c);
|
||||
void stv5730_vbar (int x, int len);
|
||||
void stv5730_hbar (int x, int y, int len);
|
||||
void stv5730_num (int x, int num);
|
||||
void stv5730_icon (int which, char dest);
|
||||
void stv5730_flush_box (int lft, int top, int rgt, int bot);
|
||||
void stv5730_draw_frame (char *dat);
|
||||
int stv5730_init (Driver *drvthis, char *args);
|
||||
MODULE_EXPORT void stv5730_close (Driver *drvthis);
|
||||
MODULE_EXPORT int stv5730_width (Driver *drvthis);
|
||||
MODULE_EXPORT int stv5730_height (Driver *drvthis);
|
||||
MODULE_EXPORT int stv5730_cellwidth (Driver *drvthis);
|
||||
MODULE_EXPORT int stv5730_cellheight (Driver *drvthis);
|
||||
MODULE_EXPORT void stv5730_clear (Driver *drvthis);
|
||||
MODULE_EXPORT void stv5730_flush (Driver *drvthis);
|
||||
MODULE_EXPORT void stv5730_string (Driver *drvthis, int x, int y, char string[]);
|
||||
MODULE_EXPORT void stv5730_chr (Driver *drvthis, int x, int y, char c);
|
||||
MODULE_EXPORT void stv5730_vbar (Driver *drvthis, int x, int len);
|
||||
MODULE_EXPORT void stv5730_hbar (Driver *drvthis, int x, int y, int len);
|
||||
MODULE_EXPORT void stv5730_num (Driver *drvthis, int x, int num);
|
||||
MODULE_EXPORT void stv5730_icon (Driver *drvthis, int which, char dest);
|
||||
|
||||
#endif
|
||||
|
||||
+104
-122
@@ -24,7 +24,6 @@
|
||||
#include "shared/debug.h"
|
||||
|
||||
#include "lcd.h"
|
||||
#include "render.h"
|
||||
#include "port.h"
|
||||
#include "t6963.h"
|
||||
#include "t6963_font.h"
|
||||
@@ -37,7 +36,6 @@
|
||||
#define DEBUG4 if(debug_level > 3) printf
|
||||
|
||||
extern int debug_level;
|
||||
lcd_logical_driver *t6963;
|
||||
|
||||
static u16 t6963_out_port;
|
||||
static u16 t6963_display_mode;
|
||||
@@ -45,8 +43,20 @@ static u8 *t6963_display_buffer1;
|
||||
static u8 *t6963_display_buffer2;
|
||||
static u8 t6963_graph_line[6];
|
||||
|
||||
static char *t6963_framebuf = NULL;
|
||||
static int width;
|
||||
static int height;
|
||||
static int cellwidth;
|
||||
static int cellheight;
|
||||
|
||||
// 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 = "t6963_";
|
||||
|
||||
int
|
||||
t6963_init (struct lcd_logical_driver *driver, char *args)
|
||||
t6963_init (Driver *drvthis, char *args)
|
||||
{
|
||||
char *argv[64];
|
||||
int argc;
|
||||
@@ -63,8 +73,6 @@ t6963_init (struct lcd_logical_driver *driver, char *args)
|
||||
t6963_graph_line[4] = 0x3E;
|
||||
t6963_graph_line[5] = 0x3F;
|
||||
|
||||
t6963 = driver;
|
||||
|
||||
DEBUG3 ("Reading arguments...\n");
|
||||
argc = get_args (argv, args, 64);
|
||||
|
||||
@@ -101,47 +109,50 @@ t6963_init (struct lcd_logical_driver *driver, char *args)
|
||||
|
||||
DEBUG3 (" cool, got 'em!\nSetting width and height\n");
|
||||
|
||||
DEBUG3 ("done\nAllocating memory: %i x %i bytes = %i...\n", driver->wid, driver->hgt, driver->wid * driver->hgt);
|
||||
DEBUG3 ("done\nAllocating memory: %i x %i bytes = %i...\n", width, height, width * height);
|
||||
|
||||
// Set display size
|
||||
t6963->wid = 20;
|
||||
t6963->hgt = 6;
|
||||
t6963->cellwid = 6;
|
||||
t6963->cellhgt = 8;
|
||||
width = 20;
|
||||
height = 6;
|
||||
cellwidth = 6;
|
||||
cellheight = 8;
|
||||
|
||||
// You must use driver->framebuf here, but may use lcd.framebuf later.
|
||||
if (!driver->framebuf)
|
||||
driver->framebuf = malloc (driver->wid * driver->hgt);
|
||||
// Allocate framebuf
|
||||
t6963_framebuf = malloc (width * height);
|
||||
|
||||
if (!driver->framebuf) {
|
||||
t6963_close ();
|
||||
if (!t6963_framebuf) {
|
||||
t6963_close (drvthis);
|
||||
return -1;
|
||||
}
|
||||
// Allocate memory
|
||||
t6963_display_buffer1 = malloc (driver->wid * 6);
|
||||
t6963_display_buffer2 = malloc (driver->wid * 6);
|
||||
t6963_display_buffer1 = malloc (width * 6);
|
||||
t6963_display_buffer2 = malloc (width * 6);
|
||||
// Clear front and back buffer
|
||||
if(t6963_display_buffer1) memset(t6963_display_buffer1, ' ', driver->wid * 6);
|
||||
if(t6963_display_buffer2) memset(t6963_display_buffer1, ' ', driver->wid * 6);
|
||||
if(t6963_display_buffer1) memset(t6963_display_buffer1, ' ', width * 6);
|
||||
if(t6963_display_buffer2) memset(t6963_display_buffer1, ' ', width * 6);
|
||||
|
||||
DEBUG3 ("done\nSetting function pointers...\n");
|
||||
|
||||
driver->clear = t6963_clear;
|
||||
driver->string = t6963_string;
|
||||
driver->chr = t6963_chr;
|
||||
driver->vbar = t6963_vbar;
|
||||
driver->hbar = t6963_hbar;
|
||||
driver->num = t6963_num;
|
||||
driver->init = t6963_init;
|
||||
driver->close = t6963_close;
|
||||
driver->flush = t6963_flush;
|
||||
driver->flush_box = t6963_flush_box;
|
||||
driver->set_char = t6963_set_char;
|
||||
driver->icon = t6963_icon;
|
||||
driver->heartbeat = t6963_heartbeat;
|
||||
driver->draw_frame = t6963_draw_frame;
|
||||
// Set variables for server
|
||||
drvthis->stay_in_foreground = &stay_in_foreground;
|
||||
drvthis->api_version = api_version;
|
||||
drvthis->supports_multiple = &supports_multiple;
|
||||
|
||||
driver->getkey = t6963_getkey;
|
||||
// Set the functions the driver supports
|
||||
drvthis->clear = t6963_clear;
|
||||
drvthis->string = t6963_string;
|
||||
drvthis->chr = t6963_chr;
|
||||
drvthis->old_vbar = t6963_vbar;
|
||||
drvthis->old_hbar = t6963_hbar;
|
||||
drvthis->num = t6963_num;
|
||||
drvthis->init = t6963_init;
|
||||
drvthis->close = t6963_close;
|
||||
drvthis->flush = t6963_flush;
|
||||
drvthis->set_char = t6963_set_char;
|
||||
drvthis->old_icon = t6963_icon;
|
||||
drvthis->heartbeat = t6963_heartbeat;
|
||||
|
||||
drvthis->getkey = t6963_getkey;
|
||||
|
||||
DEBUG3 ("done\nSending init to display...\n");
|
||||
DEBUG4 (" make parallel port an output port\n");
|
||||
@@ -155,25 +166,25 @@ t6963_init (struct lcd_logical_driver *driver, char *args)
|
||||
DEBUG4(" set graphic/text home adress and area\n");
|
||||
|
||||
t6963_low_command_word (SET_GRAPHIC_HOME_ADDRESS, ATTRIB_BASE);
|
||||
t6963_low_command_word (SET_GRAPHIC_AREA, driver->wid);
|
||||
t6963_low_command_word (SET_GRAPHIC_AREA, width);
|
||||
t6963_low_command_word (SET_TEXT_HOME_ADDRESS, TEXT_BASE);
|
||||
t6963_low_command_word (SET_TEXT_AREA, driver->wid);
|
||||
t6963_low_command_word (SET_TEXT_AREA, width);
|
||||
|
||||
t6963_low_command (SET_MODE | OR_MODE | EXTERNAL_CG);
|
||||
t6963_low_command_2_bytes (SET_OFFSET_REGISTER, CHARGEN_BASE>>11, 0);
|
||||
t6963_low_command (SET_CURSOR_PATTERN | 7); // cursor is 8 lines high
|
||||
t6963_low_command_2_bytes (SET_CURSOR_POINTER, 0, 0);
|
||||
|
||||
t6963_set_nchar (0, fontdata_6x8, 256);
|
||||
t6963_set_nchar (drvthis, 0, fontdata_6x8, 256);
|
||||
|
||||
t6963_low_enable_mode (TEXT_ON);
|
||||
t6963_low_disable_mode (GRAPHIC_ON);
|
||||
t6963_low_disable_mode (CURSOR_ON);
|
||||
t6963_low_disable_mode (BLINK_ON);
|
||||
|
||||
t6963_clear ();
|
||||
t6963_graphic_clear (0, 0, driver->wid, driver->cellhgt * 6);
|
||||
t6963_flush();
|
||||
t6963_clear (drvthis);
|
||||
t6963_graphic_clear (drvthis, 0, 0, width, cellheight * 6);
|
||||
t6963_flush(drvthis);
|
||||
DEBUG3 ("Initialization done!\n");
|
||||
|
||||
return 0; // 200 is arbitrary. (must be 1 or more)
|
||||
@@ -183,19 +194,19 @@ t6963_init (struct lcd_logical_driver *driver, char *args)
|
||||
// lcd.framebuf will be set to the appropriate buffer before calling
|
||||
// your driver.
|
||||
|
||||
void
|
||||
t6963_close ()
|
||||
MODULE_EXPORT void
|
||||
t6963_close (Driver *drvthis)
|
||||
{
|
||||
DEBUG3 ("Shutting down!\n");
|
||||
t6963_low_disable_mode (BLINK_ON);
|
||||
|
||||
ioperm(t6963_out_port, 3, 0);
|
||||
if (t6963->framebuf != NULL)
|
||||
free (t6963->framebuf);
|
||||
if (t6963_framebuf != NULL)
|
||||
free (t6963_framebuf);
|
||||
if (t6963_display_buffer1 != NULL) free (t6963_display_buffer1);
|
||||
if (t6963_display_buffer2 != NULL) free (t6963_display_buffer2);
|
||||
|
||||
t6963->framebuf = NULL;
|
||||
t6963_framebuf = NULL;
|
||||
t6963_display_buffer1 = NULL;
|
||||
t6963_display_buffer2 = NULL;
|
||||
}
|
||||
@@ -203,20 +214,20 @@ t6963_close ()
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clears the LCD screen
|
||||
//
|
||||
void
|
||||
t6963_clear ()
|
||||
MODULE_EXPORT void
|
||||
t6963_clear (Driver *drvthis)
|
||||
{
|
||||
DEBUG4 ("Clearing Display of size %i x %i\n", t6963->wid, 6);
|
||||
DEBUG4 ("Clearing Display of size %i x %i\n", width, 6);
|
||||
|
||||
memset (t6963_display_buffer1, ' ', t6963->wid * 6);
|
||||
memset (t6963_display_buffer1, ' ', width * 6);
|
||||
// for (i=0; i < 6; i++)
|
||||
// if (t6963_hbar_len[i]==0) t6963_graphic_clear(0, i*t6963->cellhgt, t6963->wid, (i+1)*t6963->cellhgt);
|
||||
// if (t6963_hbar_len[i]==0) t6963_graphic_clear(0, i*cellheight, width, (i+1)*cellheight);
|
||||
|
||||
DEBUG4 ("Done\n");
|
||||
}
|
||||
|
||||
void
|
||||
t6963_graphic_clear (int x1, int y1, int x2, int y2)
|
||||
t6963_graphic_clear (Driver *drvthis, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
int x;
|
||||
|
||||
@@ -224,7 +235,7 @@ t6963_graphic_clear (int x1, int y1, int x2, int y2)
|
||||
|
||||
for (;y1 < y2; y1++)
|
||||
{
|
||||
t6963_low_command_word(SET_ADDRESS_POINTER, ATTRIB_BASE + y1 * t6963->wid + x1);
|
||||
t6963_low_command_word(SET_ADDRESS_POINTER, ATTRIB_BASE + y1 * width + x1);
|
||||
for (x = x1; x < x2; x++)
|
||||
t6963_low_command_byte(DATA_WRITE_INC, 0);
|
||||
}
|
||||
@@ -233,13 +244,13 @@ t6963_graphic_clear (int x1, int y1, int x2, int y2)
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Flushes all output to the lcd...
|
||||
//
|
||||
void
|
||||
t6963_flush ()
|
||||
MODULE_EXPORT void
|
||||
t6963_flush (Driver *drvthis)
|
||||
{
|
||||
int i;
|
||||
DEBUG4 ("Flushing %i x %i\n", t6963->wid, t6963->hgt);
|
||||
DEBUG4 ("Flushing %i x %i\n", width, height);
|
||||
|
||||
for (i = 0; i < (t6963->wid * 6); i++)
|
||||
for (i = 0; i < (width * 6); i++)
|
||||
{
|
||||
DEBUG4 ("%i%i|", t6963_display_buffer1[i], t6963_display_buffer2[i]);
|
||||
if (t6963_display_buffer1[i] != t6963_display_buffer2[i])
|
||||
@@ -250,30 +261,15 @@ t6963_flush ()
|
||||
}
|
||||
DEBUG4 ("\n");
|
||||
t6963_swap_buffers();
|
||||
t6963_clear();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Send a rectangular area to the display.
|
||||
//
|
||||
// I've just called drv_base_flush() because there's not much point yet
|
||||
// in flushing less than the entire framebuffer.
|
||||
//
|
||||
void
|
||||
t6963_flush_box (int lft, int top, int rgt, int bot)
|
||||
{
|
||||
DEBUG4 ("flush_box\n");
|
||||
t6963_flush();
|
||||
//drv_base_flush();
|
||||
|
||||
t6963_clear(drvthis);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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).
|
||||
//
|
||||
void
|
||||
t6963_string (int x, int y, char string[])
|
||||
MODULE_EXPORT void
|
||||
t6963_string (Driver *drvthis, int x, int y, char string[])
|
||||
{
|
||||
DEBUG4 ("String out\n");
|
||||
|
||||
@@ -281,8 +277,8 @@ t6963_string (int x, int y, char string[])
|
||||
y -= 1;
|
||||
|
||||
// t6963_low_command_word(SET_ADDRESS_POINTER,TEXT_BASE+POSITION(x,y));
|
||||
if(y * t6963->wid + x + strlen(string) <= t6963->wid * 6);
|
||||
memcpy(&t6963_display_buffer1[y * t6963->wid + x], string, strlen(string));
|
||||
if(y * width + x + strlen(string) <= width * 6);
|
||||
memcpy(&t6963_display_buffer1[y * width + x], string, strlen(string));
|
||||
|
||||
}
|
||||
|
||||
@@ -290,21 +286,21 @@ t6963_string (int x, int y, char 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).
|
||||
//
|
||||
void
|
||||
t6963_chr (int x, int y, char c)
|
||||
MODULE_EXPORT void
|
||||
t6963_chr (Driver *drvthis, int x, int y, char c)
|
||||
{
|
||||
DEBUG4 ("Char out\n");
|
||||
y--;
|
||||
x--;
|
||||
if ((y * t6963->wid) + x <= (t6963->wid * 6))
|
||||
t6963_display_buffer1[(y * t6963->wid) + x] = c;
|
||||
if ((y * width) + x <= (width * 6))
|
||||
t6963_display_buffer1[(y * width) + x] = c;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Draws a big (4-row) number.
|
||||
//
|
||||
void
|
||||
t6963_num (int x, int num)
|
||||
MODULE_EXPORT void
|
||||
t6963_num (Driver *drvthis, int x, int num)
|
||||
{
|
||||
// printf("BigNum(%i, %i)\n", x, num);
|
||||
}
|
||||
@@ -313,7 +309,7 @@ t6963_num (int x, int num)
|
||||
// Changes the font data of character n.
|
||||
//
|
||||
void
|
||||
t6963_set_nchar (int n, char *dat, int num)
|
||||
t6963_set_nchar (Driver *drvthis, int n, char *dat, int num)
|
||||
{
|
||||
int row, col;
|
||||
char letter;
|
||||
@@ -324,36 +320,36 @@ t6963_set_nchar (int n, char *dat, int num)
|
||||
return;
|
||||
|
||||
t6963_low_command_word(SET_ADDRESS_POINTER, CHARGEN_BASE + n*8);
|
||||
for (row = 0; row < t6963->cellhgt * num; row++) {
|
||||
for (row = 0; row < cellheight * num; row++) {
|
||||
letter = 0;
|
||||
for (col = 0; col < t6963->cellwid; col++) {
|
||||
for (col = 0; col < cellwidth; col++) {
|
||||
letter <<= 1;
|
||||
letter |= (dat[(row * t6963->cellwid) + col] > 0);
|
||||
letter |= (dat[(row * cellwidth) + col] > 0);
|
||||
}
|
||||
|
||||
t6963_low_command_byte(DATA_WRITE_INC, letter);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
t6963_set_char (int n, char *dat)
|
||||
MODULE_EXPORT void
|
||||
t6963_set_char (Driver *drvthis, int n, char *dat)
|
||||
{
|
||||
t6963_set_nchar (n, dat, 1);
|
||||
t6963_set_nchar (drvthis, n, dat, 1);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a vertical bar, from the bottom of the screen up.
|
||||
//
|
||||
void
|
||||
t6963_vbar (int x, int len)
|
||||
MODULE_EXPORT void
|
||||
t6963_vbar (Driver *drvthis, int x, int len)
|
||||
{
|
||||
int y;
|
||||
DEBUG4 ("Drawing vertical bar...");
|
||||
for (y = 0; y < len/t6963->cellhgt; y++)
|
||||
t6963_chr (x, 6-y, 219);
|
||||
for (y = 0; y < len/cellheight; y++)
|
||||
t6963_chr (drvthis, x, 6-y, 219);
|
||||
|
||||
if (len % t6963->cellhgt)
|
||||
t6963_chr (x, 6-y, 211 + (len % t6963->cellhgt));
|
||||
if (len % cellheight)
|
||||
t6963_chr (drvthis, x, 6-y, 211 + (len % cellheight));
|
||||
|
||||
DEBUG4 ("Done\n");
|
||||
}
|
||||
@@ -361,16 +357,16 @@ t6963_vbar (int x, int len)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
void
|
||||
t6963_hbar (int x, int y, int len)
|
||||
MODULE_EXPORT void
|
||||
t6963_hbar (Driver *drvthis, int x, int y, int len)
|
||||
{
|
||||
int stop = x + len/t6963->cellwid;
|
||||
int stop = x + len/cellwidth;
|
||||
DEBUG4 ("Drawing horizontal bar x: %i, y: %i, len:%i, stop: %i...", x, y, len, stop);
|
||||
for (; x < stop; x++)
|
||||
t6963_chr (x, y, 219);
|
||||
t6963_chr (drvthis, x, y, 219);
|
||||
|
||||
if (len % t6963->cellwid)
|
||||
t6963_chr (x, y, 225 - (len % t6963->cellwid));
|
||||
if (len % cellwidth)
|
||||
t6963_chr (drvthis, x, y, 225 - (len % cellwidth));
|
||||
|
||||
DEBUG4 ("Done\n");
|
||||
}
|
||||
@@ -378,8 +374,8 @@ t6963_hbar (int x, int y, int len)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets character 0 to an icon...
|
||||
//
|
||||
void
|
||||
t6963_icon (int which, char dest)
|
||||
MODULE_EXPORT void
|
||||
t6963_icon (Driver *drvthis, int which, char dest)
|
||||
{
|
||||
// printf("Char %i set to icon %i\n", dest, which);
|
||||
DEBUG4 ("Icon %i\n", which);
|
||||
@@ -388,8 +384,8 @@ t6963_icon (int which, char dest)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Does the heartbeat
|
||||
//
|
||||
void
|
||||
t6963_heartbeat (int type)
|
||||
MODULE_EXPORT void
|
||||
t6963_heartbeat (Driver *drvthis, int type)
|
||||
{
|
||||
static int timer;
|
||||
int whichIcon;
|
||||
@@ -402,34 +398,20 @@ t6963_heartbeat (int type)
|
||||
// Set this to pulsate like a real heartbeat...
|
||||
whichIcon = (! ((timer + 4) & 5));
|
||||
// Put character on screen...
|
||||
t6963_chr (t6963->wid, 1, 3+whichIcon);
|
||||
t6963_chr (drvthis, width, 1, 3+whichIcon);
|
||||
}
|
||||
|
||||
timer++;
|
||||
timer &= 0x0f;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Gets a whole screen buffer as argument...
|
||||
//
|
||||
|
||||
void
|
||||
t6963_draw_frame (char *dat)
|
||||
{
|
||||
DEBUG4 ("Drawing frame...");
|
||||
|
||||
memcpy (t6963_display_buffer1, dat, t6963->wid * t6963->hgt);
|
||||
|
||||
DEBUG4 ("Done");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Tries to read a character from an input device...
|
||||
//
|
||||
// Return 0 for "nothing available".
|
||||
//
|
||||
char
|
||||
t6963_getkey ()
|
||||
MODULE_EXPORT char
|
||||
t6963_getkey (Driver *drvthis)
|
||||
{
|
||||
DEBUG4 ("Get key");
|
||||
return 0;
|
||||
|
||||
+23
-18
@@ -12,6 +12,8 @@
|
||||
#ifndef T6963_H
|
||||
#define T6963_H
|
||||
|
||||
#include "lcd.h"
|
||||
|
||||
#define SM_UP (1)
|
||||
#define SM_DOWN (2)
|
||||
#define CM_ERASE (2)
|
||||
@@ -105,25 +107,28 @@ typedef unsigned char u8;
|
||||
// * F U N C T I O N S *
|
||||
// ****************************************************************************************
|
||||
|
||||
extern lcd_logical_driver *t6963;
|
||||
|
||||
int t6963_init (struct lcd_logical_driver *driver, char *args);
|
||||
void t6963_close ();
|
||||
void t6963_clear ();
|
||||
void t6963_graphic_clear ();
|
||||
void t6963_flush ();
|
||||
void t6963_string (int x, int y, char string[]);
|
||||
void t6963_chr (int x, int y, char c);
|
||||
void t6963_vbar (int x, int len);
|
||||
void t6963_hbar (int x, int y, int len);
|
||||
void t6963_num (int x, int num);
|
||||
void t6963_set_nchar (int n, char *dat, int num);
|
||||
void t6963_set_char (int n, char *dat);
|
||||
void t6963_icon (int which, char dest);
|
||||
void t6963_heartbeat (int type);
|
||||
void t6963_flush_box (int lft, int top, int rgt, int bot);
|
||||
void t6963_draw_frame (char *dat);
|
||||
char t6963_getkey ();
|
||||
int t6963_init (Driver *drvthis, char *args);
|
||||
MODULE_EXPORT void t6963_close (Driver *drvthis);
|
||||
MODULE_EXPORT int t6963_width (Driver *drvthis);
|
||||
MODULE_EXPORT int t6963_height (Driver *drvthis);
|
||||
MODULE_EXPORT void t6963_clear (Driver *drvthis);
|
||||
MODULE_EXPORT void t6963_flush (Driver *drvthis);
|
||||
MODULE_EXPORT void t6963_string (Driver *drvthis, int x, int y, char string[]);
|
||||
MODULE_EXPORT void t6963_chr (Driver *drvthis, int x, int y, char c);
|
||||
|
||||
MODULE_EXPORT void t6963_vbar (Driver *drvthis, int x, int len);
|
||||
MODULE_EXPORT void t6963_hbar (Driver *drvthis, int x, int y, int len);
|
||||
MODULE_EXPORT void t6963_num (Driver *drvthis, int x, int num);
|
||||
MODULE_EXPORT void t6963_icon (Driver *drvthis, int which, char dest);
|
||||
MODULE_EXPORT void t6963_heartbeat (Driver *drvthis, int type);
|
||||
|
||||
MODULE_EXPORT void t6963_set_char (Driver *drvthis, int n, char *dat);
|
||||
|
||||
MODULE_EXPORT char t6963_getkey (Driver *drvthis);
|
||||
|
||||
void t6963_graphic_clear (Driver *drvthis, int x1, int y1, int x2, int y2);
|
||||
void t6963_set_nchar (Driver *drvthis, int n, char *dat, int num);
|
||||
|
||||
void t6963_low_data(u8 byte);
|
||||
void t6963_low_command (u8 byte);
|
||||
|
||||
+146
-136
@@ -6,6 +6,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
@@ -17,24 +21,7 @@
|
||||
|
||||
#include "lcd.h"
|
||||
#include "text.h"
|
||||
#include "drv_base.h"
|
||||
|
||||
static void text_close ();
|
||||
static void text_clear ();
|
||||
static void text_flush ();
|
||||
static void text_string (int x, int y, char string[]);
|
||||
static void text_chr (int x, int y, char c);
|
||||
static int text_contrast (int contrast);
|
||||
static void text_backlight (int on);
|
||||
//static void text_init_vbar ();
|
||||
//static void text_init_hbar ();
|
||||
//static void text_init_num ();
|
||||
static void text_vbar (int x, int len);
|
||||
static void text_hbar (int x, int y, int len);
|
||||
static void text_num (int x, int num);
|
||||
//static void text_set_char (int n, char *dat);
|
||||
//static void text_flush_box (int lft, int top, int rgt, int bot);
|
||||
static void text_draw_frame (char *dat);
|
||||
//#include "drv_base.h"
|
||||
|
||||
/* Ugly code extracted by David GLAUDE from lcdm001.c ;)*/
|
||||
static char num_icon [10][4][3] = {{{' ','_',' '}, /*0*/
|
||||
@@ -79,106 +66,160 @@ static char num_icon [10][4][3] = {{{' ','_',' '}, /*0*/
|
||||
{' ',' ',' '}}};
|
||||
/* End of ugly code ;) by Rene Wagner */
|
||||
|
||||
lcd_logical_driver *text;
|
||||
// Variables
|
||||
int width;
|
||||
int height;
|
||||
char * framebuf;
|
||||
|
||||
// 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 = "text_";
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// For Text-Mode Output //////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define LCD_DEFAULT_WIDTH 20
|
||||
#define LCD_DEFAULT_HEIGHT 4
|
||||
// The two value below are fake, we don't support custom char.
|
||||
#define LCD_DEFAULT_CELL_WIDTH 5
|
||||
#define LCD_DEFAULT_CELL_HEIGHT 8
|
||||
|
||||
// TODO: When using the text driver, ^C fails to interrupt!
|
||||
// Why? Fix it...
|
||||
// DONE??? Are you sure, not in my Konsole. David GLAUDE
|
||||
|
||||
int
|
||||
text_init (lcd_logical_driver * driver, char *args)
|
||||
text_init (Driver *drvthis, char *args)
|
||||
{
|
||||
text = driver;
|
||||
// Set display sizes
|
||||
if( drvthis->request_display_width() > 0
|
||||
&& drvthis->request_display_height() > 0 ) {
|
||||
// Use size from primary driver
|
||||
width = drvthis->request_display_width();
|
||||
height = drvthis->request_display_height();
|
||||
}
|
||||
else {
|
||||
// Use default size
|
||||
width = LCD_DEFAULT_WIDTH;
|
||||
height = LCD_DEFAULT_HEIGHT;
|
||||
}
|
||||
|
||||
// Make sure the frame buffer is there...
|
||||
if (!text->framebuf)
|
||||
text->framebuf = (unsigned char *)
|
||||
malloc (text->wid * text->hgt);
|
||||
memset (text->framebuf, ' ', text->wid * text->hgt);
|
||||
// Allocate the framebuffer
|
||||
framebuf = (unsigned char *) malloc (width * height);
|
||||
memset (framebuf, ' ', width * height);
|
||||
|
||||
// Set variables for server
|
||||
drvthis->api_version = api_version;
|
||||
drvthis->stay_in_foreground = &stay_in_foreground;
|
||||
drvthis->supports_multiple = &supports_multiple;
|
||||
|
||||
// Set the functions the driver supports
|
||||
drvthis->init = text_init;
|
||||
drvthis->close = text_close;
|
||||
drvthis->width = text_width;
|
||||
drvthis->height = text_height;
|
||||
|
||||
text->wid = LCD_DEFAULT_WIDTH;
|
||||
text->hgt = LCD_DEFAULT_HEIGHT;
|
||||
text->cellwid = LCD_DEFAULT_CELL_WIDTH;
|
||||
text->cellhgt = LCD_DEFAULT_CELL_HEIGHT;
|
||||
drvthis->clear = text_clear;
|
||||
drvthis->flush = text_flush;
|
||||
drvthis->string = text_string;
|
||||
drvthis->chr = text_chr;
|
||||
|
||||
text->clear = text_clear;
|
||||
text->string = text_string;
|
||||
text->chr = text_chr;
|
||||
text->vbar = text_vbar;
|
||||
//text->init_vbar = NULL;
|
||||
text->hbar = text_hbar;
|
||||
//text->init_hbar = NULL;
|
||||
text->num = text_num;
|
||||
//text->init_num = NULL;
|
||||
drvthis->old_vbar = text_vbar;
|
||||
//drvthis->init_vbar = NULL;
|
||||
drvthis->old_hbar = text_hbar;
|
||||
//drvthis->init_hbar = NULL;
|
||||
drvthis->num = text_num;
|
||||
//drvthis->init_num = NULL;
|
||||
|
||||
text->init = text_init;
|
||||
text->close = text_close;
|
||||
text->flush = text_flush;
|
||||
//text->flush_box = NULL;
|
||||
//text->contrast = NULL;
|
||||
//text->backlight = NULL;
|
||||
//text->set_char = NULL;
|
||||
//text->icon = NULL;
|
||||
text->draw_frame = text_draw_frame;
|
||||
drvthis->set_contrast = text_set_contrast;
|
||||
drvthis->backlight = text_backlight;
|
||||
|
||||
//text->getkey = NULL;
|
||||
//drvthis->set_char = NULL;
|
||||
//drvthis->icon = NULL;
|
||||
|
||||
return 200; // 200 is arbitrary. (must be 1 or more)
|
||||
//drvthis->getkey = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
text_close ()
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Closes the device
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
text_close (Driver *drvthis)
|
||||
{
|
||||
if (text->framebuf != NULL)
|
||||
free (text->framebuf);
|
||||
if (framebuf != NULL)
|
||||
free (framebuf);
|
||||
|
||||
text->framebuf = NULL;
|
||||
framebuf = NULL;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display width
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
text_width (Driver *drvthis)
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display height
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
text_height (Driver *drvthis)
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clears the LCD screen
|
||||
//
|
||||
static void
|
||||
text_clear ()
|
||||
MODULE_EXPORT void
|
||||
text_clear (Driver *drvthis)
|
||||
{
|
||||
memset (text->framebuf, ' ', text->wid * text->hgt);
|
||||
memset (framebuf, ' ', width * height);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Flushes all output to the lcd...
|
||||
//
|
||||
static void
|
||||
text_flush ()
|
||||
MODULE_EXPORT void
|
||||
text_flush (Driver *drvthis)
|
||||
{
|
||||
text_draw_frame (text->framebuf);
|
||||
int i, j;
|
||||
|
||||
char out[LCD_MAX_WIDTH];
|
||||
|
||||
for (i = 0; i < width; i++) {
|
||||
out[i] = '-';
|
||||
}
|
||||
out[width] = 0;
|
||||
printf ("+%s+\n", out);
|
||||
|
||||
for (i = 0; i < height; i++) {
|
||||
for (j = 0; j < width; j++) {
|
||||
out[j] = framebuf[j + (i * width)];
|
||||
}
|
||||
out[width] = 0;
|
||||
printf ("|%s|\n", out);
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i < width; i++) {
|
||||
out[i] = '-';
|
||||
}
|
||||
out[width] = 0;
|
||||
printf ("+%s+\n", out);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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).
|
||||
//
|
||||
static void
|
||||
text_string (int x, int y, char string[])
|
||||
MODULE_EXPORT void
|
||||
text_string (Driver *drvthis, int x, int y, char string[])
|
||||
{
|
||||
int i;
|
||||
|
||||
x--; y--; // Convert 1-based coords to 0-based...
|
||||
|
||||
for (i = 0; string[i]; i++) {
|
||||
text->framebuf[(y * text->wid) + x + i] = string[i];
|
||||
framebuf[(y * width) + x + i] = string[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,24 +227,33 @@ text_string (int x, int y, char 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,4).
|
||||
//
|
||||
static void
|
||||
text_chr (int x, int y, char c)
|
||||
MODULE_EXPORT void
|
||||
text_chr (Driver *drvthis, int x, int y, char c)
|
||||
{
|
||||
y--; x--;
|
||||
|
||||
text->framebuf[(y * text->wid) + x] = c;
|
||||
framebuf[(y * width) + x] = c;
|
||||
}
|
||||
|
||||
static int
|
||||
text_contrast (int contrast)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets the contrast
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
text_set_contrast (Driver *drvthis, int promille)
|
||||
{
|
||||
// printf("Contrast: %i\n", contrast);
|
||||
return 0;
|
||||
/*
|
||||
printf("Contrast: %d\n", promille);
|
||||
*/
|
||||
}
|
||||
|
||||
static void
|
||||
text_backlight (int on)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets the backlight brightness
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
text_backlight (Driver *drvthis, int on)
|
||||
{
|
||||
//PrivateData * p = (PrivateData*) drvthis->private_data;
|
||||
|
||||
/*
|
||||
if(on)
|
||||
{
|
||||
@@ -237,14 +287,16 @@ text_backlight (int on)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Writes a big number. (by Rene Wagner from lcdm001.c)
|
||||
//
|
||||
static void text_num (int x, int num)
|
||||
MODULE_EXPORT void text_num (Driver *drvthis, int x, int num)
|
||||
{
|
||||
//PrivateData * p = (PrivateData*) drvthis->private_data;
|
||||
|
||||
int y, dx;
|
||||
|
||||
// printf("BigNum(%i, %i)\n", x, num);
|
||||
for (y = 1; y < 5; y++)
|
||||
for (dx = 0; dx < 3; dx++)
|
||||
text_chr (x + dx, y, num_icon[num][y-1][dx]);
|
||||
text_chr (drvthis, x + dx, y, num_icon[num][y-1][dx]);
|
||||
}
|
||||
|
||||
//void
|
||||
@@ -256,14 +308,14 @@ static void text_num (int x, int num)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a vertical bar; erases entire column onscreen.
|
||||
//
|
||||
static void
|
||||
text_vbar (int x, int len)
|
||||
MODULE_EXPORT void
|
||||
text_vbar (Driver *drvthis, int x, int len)
|
||||
{
|
||||
int y;
|
||||
for (y = text->hgt; y > 0 && len > 0; y--) {
|
||||
text_chr (x, y, '|');
|
||||
for (y = height; y > 0 && len > 0; y--) {
|
||||
text_chr (drvthis, x, y, '|');
|
||||
|
||||
len -= text->cellhgt;
|
||||
len -= LCD_DEFAULT_CELLHEIGHT;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -271,56 +323,14 @@ text_vbar (int x, int len)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
static void
|
||||
text_hbar (int x, int y, int len)
|
||||
MODULE_EXPORT void
|
||||
text_hbar (Driver *drvthis, int x, int y, int len)
|
||||
{
|
||||
for (; x <= text->wid && len > 0; x++) {
|
||||
text_chr (x, y, '-');
|
||||
for (; x <= width && len > 0; x++) {
|
||||
text_chr (drvthis, x, y, '-');
|
||||
|
||||
len -= text->cellwid;
|
||||
len -= LCD_DEFAULT_CELLWIDTH;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
text_flush_box (int lft, int top, int rgt, int bot)
|
||||
{
|
||||
text_flush ();
|
||||
}
|
||||
|
||||
static void
|
||||
text_draw_frame (char *dat)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
char out[LCD_MAX_WIDTH];
|
||||
|
||||
if (!dat)
|
||||
return;
|
||||
|
||||
// printf("Frame (%ix%i): \n%s\n", lcd.wid, lcd.hgt, dat);
|
||||
|
||||
for (i = 0; i < text->wid; i++) {
|
||||
out[i] = '-';
|
||||
}
|
||||
out[text->wid] = 0;
|
||||
printf ("+%s+\n", out);
|
||||
|
||||
for (i = 0; i < text->hgt; i++) {
|
||||
for (j = 0; j < text->wid; j++) {
|
||||
out[j] = dat[j + (i * text->wid)];
|
||||
}
|
||||
out[text->wid] = 0;
|
||||
printf ("|%s|\n", out);
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i < text->wid; i++) {
|
||||
out[i] = '-';
|
||||
}
|
||||
out[text->wid] = 0;
|
||||
printf ("+%s+\n", out);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+19
-2
@@ -1,8 +1,25 @@
|
||||
#ifndef LCD_TEXT_H
|
||||
#define LCD_TEXT_H
|
||||
|
||||
extern lcd_logical_driver *text;
|
||||
#include "lcd.h"
|
||||
|
||||
int text_init (Driver * drvthis, char *args);
|
||||
MODULE_EXPORT void text_close (Driver *drvthis);
|
||||
MODULE_EXPORT int text_width (Driver *drvthis);
|
||||
MODULE_EXPORT int text_height (Driver *drvthis);
|
||||
MODULE_EXPORT void text_clear (Driver *drvthis);
|
||||
MODULE_EXPORT void text_flush (Driver *drvthis);
|
||||
MODULE_EXPORT void text_string (Driver *drvthis, int x, int y, char string[]);
|
||||
MODULE_EXPORT void text_chr (Driver *drvthis, int x, int y, char c);
|
||||
MODULE_EXPORT void text_set_contrast (Driver *drvthis, int promille);
|
||||
MODULE_EXPORT void text_backlight (Driver *drvthis, int on);
|
||||
//MODULE_EXPORT void text_init_vbar (Driver *drvthis);
|
||||
//MODULE_EXPORT void text_init_hbar (Driver *drvthis);
|
||||
//MODULE_EXPORT void text_init_num (Driver *drvthis);
|
||||
MODULE_EXPORT void text_vbar (Driver *drvthis, int x, int len);
|
||||
MODULE_EXPORT void text_hbar (Driver *drvthis, int x, int y, int len);
|
||||
MODULE_EXPORT void text_num (Driver *drvthis, int x, int num);
|
||||
//MODULE_EXPORT void text_set_char (Driver *drvthis, int n, char *dat);
|
||||
|
||||
int text_init (struct lcd_logical_driver *driver, char *args);
|
||||
|
||||
#endif
|
||||
|
||||
+133
-162
@@ -1,7 +1,7 @@
|
||||
/* wirz-sli.c -- Source file for LCDproc Wirz SLI driver
|
||||
Copyright (C) 1999 Horizon Technologies-http://horizon.pair.com/
|
||||
Written by Bryan Rittmeyer <bryanr@pair.com> - Released under GPL
|
||||
|
||||
|
||||
LCD info: http://www.wirz.com/ */
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "lcd.h"
|
||||
#include "wirz-sli.h"
|
||||
#include "drv_base.h"
|
||||
//#include "drv_base.h"
|
||||
|
||||
#include "shared/debug.h"
|
||||
#include "shared/str.h"
|
||||
@@ -32,15 +32,22 @@ typedef enum {
|
||||
} custom_type;
|
||||
|
||||
static int fd;
|
||||
static char lastframe[32];
|
||||
static char *framebuf = NULL;
|
||||
static int width = 0;
|
||||
static int height = 0;
|
||||
|
||||
// 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 = "sli_";
|
||||
|
||||
lcd_logical_driver *sli;
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Opens com port and sets baud correctly...
|
||||
//
|
||||
int
|
||||
sli_init (lcd_logical_driver * driver, char *args)
|
||||
sli_init (Driver *drvthis, char *args)
|
||||
{
|
||||
char *argv[64];
|
||||
int argc;
|
||||
@@ -52,8 +59,6 @@ sli_init (lcd_logical_driver * driver, char *args)
|
||||
char device[256] = "/dev/lcd";
|
||||
int speed = B19200;
|
||||
|
||||
sli = driver;
|
||||
|
||||
//debug("sli_init: Args(all): %s\n", args);
|
||||
|
||||
argc = get_args (argv, args, 64);
|
||||
@@ -135,7 +140,7 @@ sli_init (lcd_logical_driver * driver, char *args)
|
||||
// Do it...
|
||||
tcsetattr (fd, TCSANOW, &portset);
|
||||
|
||||
/* Initialize SLI using autobaud detection, and then turn off cursor
|
||||
/* Initialize SLI using autobaud detection, and then turn off cursor
|
||||
and clear screen */
|
||||
usleep (150000); /* 150ms delay to allow SLI to power on */
|
||||
out[0] = 13; /* CR for SLI autobaud */
|
||||
@@ -151,92 +156,109 @@ sli_init (lcd_logical_driver * driver, char *args)
|
||||
// Set LCD parameters (I use a 16x2 LCD) -- small but still useful
|
||||
// Its also much cheaper than the higher quality Matrix Orbital modules
|
||||
// Currently, $30 for interface kit and 16x2 non-backlit LCD...
|
||||
driver->wid = 15;
|
||||
driver->hgt = 2;
|
||||
width = 15;
|
||||
height = 2;
|
||||
|
||||
// Set the functions the driver supports...
|
||||
// Set variables for server
|
||||
drvthis->api_version = api_version;
|
||||
drvthis->stay_in_foreground = &stay_in_foreground;
|
||||
drvthis->supports_multiple = &supports_multiple;
|
||||
|
||||
driver->clear = sli_clear;
|
||||
driver->string = sli_string;
|
||||
driver->chr = sli_chr;
|
||||
driver->vbar = sli_vbar;
|
||||
driver->init_vbar = sli_init_vbar;
|
||||
driver->hbar = sli_hbar;
|
||||
driver->init_hbar = sli_init_hbar;
|
||||
//driver->num = NULL;
|
||||
//driver->init_num = NULL;
|
||||
// Set the functions the driver supports
|
||||
drvthis->clear = sli_clear;
|
||||
drvthis->string = sli_string;
|
||||
drvthis->chr = sli_chr;
|
||||
drvthis->old_vbar = sli_vbar;
|
||||
drvthis->init_vbar = sli_init_vbar;
|
||||
drvthis->old_hbar = sli_hbar;
|
||||
drvthis->init_hbar = sli_init_hbar;
|
||||
//drvthis->num = NULL;
|
||||
//drvthis->init_num = NULL;
|
||||
|
||||
driver->init = sli_init;
|
||||
driver->close = sli_close;
|
||||
driver->flush = sli_flush;
|
||||
driver->flush_box = sli_flush_box;
|
||||
//driver->contrast = NULL;
|
||||
//driver->backlight = NULL;
|
||||
driver->set_char = sli_set_char;
|
||||
driver->icon = sli_icon;
|
||||
driver->draw_frame = sli_draw_frame;
|
||||
drvthis->init = sli_init;
|
||||
drvthis->close = sli_close;
|
||||
drvthis->flush = sli_flush;
|
||||
//drvthis->contrast = NULL;
|
||||
//drvthis->backlight = NULL;
|
||||
drvthis->set_char = sli_set_char;
|
||||
drvthis->old_icon = sli_icon;
|
||||
|
||||
//driver->getkey = NULL;
|
||||
//drvthis->getkey = NULL;
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
/* Clean-up */
|
||||
void
|
||||
sli_close ()
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clean up
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
sli_close (Driver *drvthis)
|
||||
{
|
||||
close (fd);
|
||||
|
||||
if (sli->framebuf)
|
||||
free (sli->framebuf);
|
||||
if (framebuf)
|
||||
free (framebuf);
|
||||
|
||||
sli->framebuf = NULL;
|
||||
framebuf = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
sli_flush ()
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display width
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
sli_width (Driver *drvthis)
|
||||
{
|
||||
sli_draw_frame (sli->framebuf);
|
||||
return width;
|
||||
}
|
||||
|
||||
/* no bounds checking is done in MtxOrb.c (which I shamelessly ripped)
|
||||
this is bad imho, so I added it.. may remove later
|
||||
speed is not a huge issue though, this isnt a
|
||||
device driver or anything ;) */
|
||||
void
|
||||
sli_flush_box (int lft, int top, int rgt, int bot)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the display height
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
sli_height (Driver *drvthis)
|
||||
{
|
||||
int y;
|
||||
char out[2]; /* Why does the matrix driver allocate so much here? */
|
||||
return height;
|
||||
}
|
||||
|
||||
/* simple bounds checking */
|
||||
if ((top > sli->hgt) | (bot > sli->hgt))
|
||||
return;
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Flush framebuffer to LCD
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
sli_flush (Driver *drvthis)
|
||||
{
|
||||
char out[2]; /* Again, why does the Matrix driver allocate so much here? */
|
||||
|
||||
if ((lft > sli->wid) | (rgt > sli->wid))
|
||||
return;
|
||||
/*
|
||||
out[0]=0x0FE;
|
||||
out[1]=0x001;
|
||||
write(fd, out, 2);
|
||||
*/
|
||||
|
||||
// printf("Flush (%i,%i)-(%i,%i)\n", lft, top, rgt, bot);
|
||||
/* Don't update if we have no new data
|
||||
this keeps me from getting a migraine
|
||||
(just like those copyleft penguin mints... mmmmmm) */
|
||||
|
||||
/* I like having hex, everywhere and all the time */
|
||||
for (y = top; y <= bot; y++) {
|
||||
if (y == 1)
|
||||
snprintf (out, sizeof(out), "%c%c", 0x0FE, 0x080 + lft);
|
||||
if (y == 2)
|
||||
snprintf (out, sizeof(out), "%c%c", 0x0FE, 0x0C0 + lft);
|
||||
write (fd, out, 0x002);
|
||||
write (fd, sli->framebuf + (y * sli->wid) + lft, rgt - lft + 1);
|
||||
}
|
||||
// if (!strncmp(dat,lastframe,32)) /* Nothing has changed */
|
||||
// return;
|
||||
|
||||
/* Do the actual refresh */
|
||||
out[0] = 0x0FE;
|
||||
out[1] = 0x080;
|
||||
write (fd, out, 2);
|
||||
write (fd, &framebuf[0], 16);
|
||||
usleep (10);
|
||||
write (fd, &framebuf[16], 15);
|
||||
|
||||
// strncpy(lastframe,dat,32); // Update lastframe...
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clears the LCD screen
|
||||
//
|
||||
void
|
||||
sli_clear ()
|
||||
MODULE_EXPORT void
|
||||
sli_clear (Driver *drvthis)
|
||||
{
|
||||
memset (sli->framebuf, ' ', sli->wid * sli->hgt);
|
||||
memset (framebuf, ' ', width * height);
|
||||
|
||||
}
|
||||
|
||||
@@ -244,8 +266,8 @@ sli_clear ()
|
||||
// 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).
|
||||
//
|
||||
void
|
||||
sli_string (int x, int y, char string[])
|
||||
MODULE_EXPORT void
|
||||
sli_string (Driver *drvthis, int x, int y, char string[])
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -254,9 +276,9 @@ sli_string (int x, int y, char string[])
|
||||
|
||||
for (i = 0; string[i]; i++) {
|
||||
// Check for buffer overflows...
|
||||
if ((y * sli->wid) + x + i > (sli->wid * sli->hgt))
|
||||
if ((y * width) + x + i > (width * height))
|
||||
break;
|
||||
sli->framebuf[(y * sli->wid) + x + i] = string[i];
|
||||
framebuf[(y * width) + x + i] = string[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,26 +286,13 @@ sli_string (int x, int y, char 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,4).
|
||||
//
|
||||
void
|
||||
sli_chr (int x, int y, char c)
|
||||
MODULE_EXPORT void
|
||||
sli_chr (Driver *drvthis, int x, int y, char c)
|
||||
{
|
||||
y--;
|
||||
x--;
|
||||
|
||||
sli->framebuf[(y * sli->wid) + x] = c;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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).
|
||||
//
|
||||
void
|
||||
sli_chr (int x, int y, char c)
|
||||
{
|
||||
y--;
|
||||
x--;
|
||||
|
||||
sli->framebuf[(y * sli->wid) + x] = c;
|
||||
framebuf[(y * width) + x] = c;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
@@ -293,14 +302,14 @@ sli_chr (int x, int y, char c)
|
||||
/* Because of the way we do this (custom characters in CGRAM)
|
||||
we can't have both horizontal and vertical bars at once...
|
||||
this also appears to be a limitation of the Matrix Orbital
|
||||
modules so I will assume that all client coders know about it
|
||||
modules so I will assume that all client coders know about it
|
||||
|
||||
I think it would be cool to use triangular stuff for the non-full
|
||||
characters, so that you can do both bar types at once.. maybe I
|
||||
characters, so that you can do both bar types at once.. maybe I
|
||||
will release a new version of the SLI driver that attempts this */
|
||||
|
||||
void
|
||||
sli_init_vbar ()
|
||||
MODULE_EXPORT void
|
||||
sli_init_vbar (Driver *drvthis)
|
||||
{
|
||||
char a[] = {
|
||||
0, 0, 0, 0, 0,
|
||||
@@ -374,13 +383,13 @@ sli_init_vbar ()
|
||||
};
|
||||
|
||||
if (custom != vbar) {
|
||||
sli_set_char (1, a);
|
||||
sli_set_char (2, b);
|
||||
sli_set_char (3, c);
|
||||
sli_set_char (4, d);
|
||||
sli_set_char (5, e);
|
||||
sli_set_char (6, f);
|
||||
sli_set_char (7, g);
|
||||
sli_set_char (drvthis, 1, a);
|
||||
sli_set_char (drvthis, 2, b);
|
||||
sli_set_char (drvthis, 3, c);
|
||||
sli_set_char (drvthis, 4, d);
|
||||
sli_set_char (drvthis, 5, e);
|
||||
sli_set_char (drvthis, 6, f);
|
||||
sli_set_char (drvthis, 7, g);
|
||||
custom = vbar;
|
||||
}
|
||||
}
|
||||
@@ -388,8 +397,8 @@ sli_init_vbar ()
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Inits horizontal bars...
|
||||
//
|
||||
void
|
||||
sli_init_hbar ()
|
||||
MODULE_EXPORT void
|
||||
sli_init_hbar (Driver *drvthis)
|
||||
{
|
||||
|
||||
char a[] = {
|
||||
@@ -434,10 +443,10 @@ sli_init_hbar ()
|
||||
};
|
||||
|
||||
if (custom != hbar) {
|
||||
sli_set_char (1, a);
|
||||
sli_set_char (2, b);
|
||||
sli_set_char (3, c);
|
||||
sli_set_char (4, d);
|
||||
sli_set_char (drvthis, 1, a);
|
||||
sli_set_char (drvthis, 2, b);
|
||||
sli_set_char (drvthis, 3, c);
|
||||
sli_set_char (drvthis, 4, d);
|
||||
custom = hbar;
|
||||
}
|
||||
}
|
||||
@@ -451,19 +460,19 @@ sli_init_hbar ()
|
||||
since we only have 2 lines anyway this is rather pointless
|
||||
for me to add */
|
||||
|
||||
void
|
||||
sli_vbar (int x, int len)
|
||||
MODULE_EXPORT void
|
||||
sli_vbar (Driver *drvthis, int x, int len)
|
||||
{
|
||||
char map[9] = { 32, 1, 2, 3, 4, 5, 6, 7, 255 };
|
||||
|
||||
int y;
|
||||
for (y = sli->hgt; y > 0 && len > 0; y--) {
|
||||
if (len >= sli->cellhgt)
|
||||
sli_chr (x, y, 255);
|
||||
for (y = height; y > 0 && len > 0; y--) {
|
||||
if (len >= LCD_DEFAULT_CELLHEIGHT)
|
||||
sli_chr (drvthis, x, y, 255);
|
||||
else
|
||||
sli_chr (x, y, map[len]);
|
||||
sli_chr (drvthis, x, y, map[len]);
|
||||
|
||||
len -= sli->cellhgt;
|
||||
len -= LCD_DEFAULT_CELLHEIGHT;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -471,18 +480,18 @@ sli_vbar (int x, int len)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
void
|
||||
sli_hbar (int x, int y, int len)
|
||||
MODULE_EXPORT void
|
||||
sli_hbar (Driver *drvthis, int x, int y, int len)
|
||||
{
|
||||
char map[6] = { 32, 1, 2, 3, 4, 255 };
|
||||
|
||||
for (; x <= sli->wid && len > 0; x++) {
|
||||
if (len >= sli->cellwid)
|
||||
sli_chr (x, y, 255);
|
||||
for (; x <= width && len > 0; x++) {
|
||||
if (len >= LCD_DEFAULT_CELLWIDTH)
|
||||
sli_chr (drvthis, x, y, 255);
|
||||
else
|
||||
sli_chr (x, y, map[len]);
|
||||
sli_chr (drvthis, x, y, map[len]);
|
||||
|
||||
len -= sli->cellwid;
|
||||
len -= LCD_DEFAULT_CELLWIDTH;
|
||||
|
||||
}
|
||||
|
||||
@@ -495,8 +504,8 @@ sli_hbar (int x, int y, int len)
|
||||
//
|
||||
// The input is just an array of characters...
|
||||
//
|
||||
void
|
||||
sli_set_char (int n, char *dat)
|
||||
MODULE_EXPORT void
|
||||
sli_set_char (Driver *drvthis, int n, char *dat)
|
||||
{
|
||||
char out[2];
|
||||
int row, col;
|
||||
@@ -513,11 +522,11 @@ sli_set_char (int n, char *dat)
|
||||
out[1] = 0x040 + 8 * n;
|
||||
write (fd, out, 2);
|
||||
|
||||
for (row = 0; row < sli->cellhgt; row++) {
|
||||
for (row = 0; row < LCD_DEFAULT_CELLHEIGHT; row++) {
|
||||
letter = 0;
|
||||
for (col = 0; col < sli->cellwid; col++) {
|
||||
for (col = 0; col < LCD_DEFAULT_CELLWIDTH; col++) {
|
||||
letter <<= 1;
|
||||
letter |= (dat[(row * sli->cellwid) + col] > 0);
|
||||
letter |= (dat[(row * LCD_DEFAULT_CELLWIDTH) + col] > 0);
|
||||
}
|
||||
letter |= 0x020; /* SLI can't accept CR, LF, etc in this character! */
|
||||
write (fd, &letter, 1);
|
||||
@@ -529,8 +538,8 @@ sli_set_char (int n, char *dat)
|
||||
write (fd, out, 2);
|
||||
}
|
||||
|
||||
void
|
||||
sli_icon (int which, char dest)
|
||||
MODULE_EXPORT void
|
||||
sli_icon (Driver *drvthis, int which, char dest)
|
||||
{
|
||||
char icons[3][5 * 8] = {
|
||||
{
|
||||
@@ -570,44 +579,6 @@ sli_icon (int which, char dest)
|
||||
|
||||
if (custom == bign)
|
||||
custom = beat;
|
||||
sli_set_char (dest, &icons[which][0]);
|
||||
sli_set_char (drvthis, dest, &icons[which][0]);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Blasts a single frame onscreen, to the lcd...
|
||||
//
|
||||
// Input is a character array, sized sli->wid*sli->hgt
|
||||
//
|
||||
void
|
||||
sli_draw_frame (char *dat)
|
||||
{
|
||||
char out[2]; /* Again, why does the Matrix driver allocate so much here? */
|
||||
int y;
|
||||
|
||||
if (!dat)
|
||||
return;
|
||||
|
||||
/*
|
||||
out[0]=0x0FE;
|
||||
out[1]=0x001;
|
||||
write(fd, out, 2);
|
||||
*/
|
||||
|
||||
/* Don't update if we have no new data
|
||||
this keeps me from getting a migraine
|
||||
(just like those copyleft penguin mints... mmmmmm) */
|
||||
|
||||
// if (!strncmp(dat,lastframe,32)) /* Nothing has changed */
|
||||
// return;
|
||||
|
||||
/* Do the actual refresh */
|
||||
out[0] = 0x0FE;
|
||||
out[1] = 0x080;
|
||||
write (fd, out, 2);
|
||||
write (fd, &dat[0], 16);
|
||||
usleep (10);
|
||||
write (fd, &dat[16], 15);
|
||||
|
||||
// strncpy(lastframe,dat,32); // Update lastframe...
|
||||
|
||||
}
|
||||
|
||||
+27
-19
@@ -1,30 +1,38 @@
|
||||
/* wirz-sli.h -- Header file for LCDproc Wirz SLI driver
|
||||
Copyright (C) 1999 Horizon Technologies-http://horizon.pair.com/
|
||||
Written by Bryan Rittmeyer <bryanr@pair.com> - Released under GPL
|
||||
|
||||
|
||||
LCD info: http://www.wirz.com/sli/ */
|
||||
|
||||
#ifndef SLI_H
|
||||
#define SLI_H
|
||||
|
||||
extern lcd_logical_driver *sli;
|
||||
#include "lcd.h"
|
||||
|
||||
int sli_init (lcd_logical_driver * driver, char *device);
|
||||
void sli_close ();
|
||||
void sli_flush ();
|
||||
void sli_flush_box (int lft, int top, int rgt, int bot);
|
||||
void sli_chr (int x, int y, char c);
|
||||
int sli_contrast (int contrast);
|
||||
void sli_backlight (int on);
|
||||
void sli_init_vbar ();
|
||||
void sli_init_hbar ();
|
||||
void sli_vbar (int x, int len);
|
||||
void sli_hbar (int x, int y, int len);
|
||||
void sli_init_num ();
|
||||
void sli_num (int x, int num);
|
||||
void sli_set_char (int n, char *dat);
|
||||
void sli_icon (int which, char dest);
|
||||
void sli_draw_frame (char *dat);
|
||||
char sli_getkey ();
|
||||
int sli_init (Driver *drvthis, char *args);
|
||||
MODULE_EXPORT void sli_close (Driver *drvthis);
|
||||
MODULE_EXPORT int sli_width (Driver *drvthis);
|
||||
MODULE_EXPORT int sli_height (Driver *drvthis);
|
||||
MODULE_EXPORT void sli_clear (Driver *drvthis);
|
||||
MODULE_EXPORT void sli_flush (Driver *drvthis);
|
||||
MODULE_EXPORT void sli_string (Driver *drvthis, int x, int y, char *string);
|
||||
MODULE_EXPORT void sli_chr (Driver *drvthis, int x, int y, char c);
|
||||
|
||||
MODULE_EXPORT void sli_vbar (Driver *drvthis, int x, int len);
|
||||
MODULE_EXPORT void sli_hbar (Driver *drvthis, int x, int y, int len);
|
||||
MODULE_EXPORT void sli_num (Driver *drvthis, int x, int num);
|
||||
MODULE_EXPORT void sli_icon (Driver *drvthis, int which, char dest);
|
||||
|
||||
MODULE_EXPORT void sli_set_char (Driver *drvthis, int n, char *dat);
|
||||
|
||||
MODULE_EXPORT int sli_get_contrast (Driver *drvthis);
|
||||
MODULE_EXPORT void sli_set_contrast (Driver *drvthis, int contrast);
|
||||
MODULE_EXPORT void sli_backlight (Driver *drvthis, int on);
|
||||
|
||||
MODULE_EXPORT char sli_getkey (Driver *drvthis);
|
||||
|
||||
MODULE_EXPORT void sli_init_vbar (Driver *drvthis);
|
||||
MODULE_EXPORT void sli_init_hbar (Driver *drvthis);
|
||||
MODULE_EXPORT void sli_init_num (Driver *drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user