Thanks to Chris Debenham <chris.debenham@aus.sun.com>, the LCDproc server
process LCDd now compiles and runs properly on Solaris! Additionally, he has provided a new driver for a 16x2 LCD made by an Australian company. I've compiled and executed this new code on a Solaris 2.6 box, and while I don't have the display the new driver uses, LCDd tries to use it anyway, fails (since the device isn't installed), and continues running, so this looks solid!
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
|
||||
#undef JOY_DRV
|
||||
|
||||
#undef LB216_DRV
|
||||
|
||||
#undef LCDPORT
|
||||
|
||||
#undef LINUX
|
||||
@@ -47,6 +49,8 @@
|
||||
|
||||
#undef SLI_DRV
|
||||
|
||||
#undef SOLARIS
|
||||
|
||||
#undef STAT_NFS
|
||||
|
||||
#undef STAT_SMBFS
|
||||
|
||||
+6
-2
@@ -6,10 +6,10 @@ AC_ARG_ENABLE(drivers,
|
||||
[ drivers may be separated with commas.]
|
||||
[ \"all\" compiles all drivers],
|
||||
drivers="$enableval",
|
||||
drivers=[mtxorb,cfontz,curses,text])
|
||||
drivers=[mtxorb,cfontz,curses,text,lb216])
|
||||
|
||||
if test "$drivers" = "all"; then
|
||||
drivers=[mtxorb,cfontz,curses,text,hd44780,joy,irman,lircin]
|
||||
drivers=[mtxorb,cfontz,curses,text,lb216,hd44780,joy,irman,lircin]
|
||||
AC_MSG_RESULT(all)
|
||||
fi
|
||||
|
||||
@@ -41,6 +41,10 @@ fi
|
||||
DRIVERS="$DRIVERS text.o"
|
||||
AC_DEFINE(TEXT_DRV)
|
||||
;;
|
||||
lb216)
|
||||
DRIVERS="$DRIVERS lb216.o"
|
||||
AC_DEFINE(LB216_DRV)
|
||||
;;
|
||||
hd44780)
|
||||
DRIVERS="$DRIVERS hd44780.o hd44780-4bit.o hd44780-ext8bit.o lcd_sem.o hd44780-serialLpt.o hd44780-winamp.o"
|
||||
AC_DEFINE(HD44780_DRV)
|
||||
|
||||
@@ -101,7 +101,9 @@ chrono_init ()
|
||||
# endif
|
||||
|
||||
/* Get OS name and version from uname() */
|
||||
if (uname (unamebuf) != 0) {
|
||||
/* Changed to check if eq -1 instead of non-zero */
|
||||
/* since uname may return any non-negative value */
|
||||
if (uname (unamebuf) == -1) {
|
||||
perror ("Error calling uname:");
|
||||
}
|
||||
strcpy (kver, unamebuf->release);
|
||||
|
||||
@@ -27,20 +27,24 @@ get_loadavg (void)
|
||||
int
|
||||
load_init ()
|
||||
{
|
||||
#ifndef SOLARIS
|
||||
if (!loadavg_fd)
|
||||
loadavg_fd = open ("/proc/loadavg", O_RDONLY);
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
load_close ()
|
||||
{
|
||||
#ifndef SOLARIS
|
||||
if (loadavg_fd)
|
||||
close (loadavg_fd);
|
||||
|
||||
loadavg_fd = 0;
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
#include "mode.h"
|
||||
#include "mem.h"
|
||||
|
||||
#ifdef SOLARIS
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
|
||||
struct meminfo {
|
||||
int total, cache, buffers, free, shared;
|
||||
};
|
||||
@@ -27,7 +32,9 @@ static void
|
||||
get_mem_info (struct meminfo *result)
|
||||
{
|
||||
// int i, res; char *bufptr;
|
||||
int pagesize,page,i;
|
||||
|
||||
#ifndef SOLARIS
|
||||
reread (meminfo_fd, "get_meminfo:");
|
||||
result[0].total = getentry ("MemTotal:", buffer);
|
||||
result[0].free = getentry ("MemFree:", buffer);
|
||||
@@ -36,26 +43,39 @@ get_mem_info (struct meminfo *result)
|
||||
result[0].cache = getentry ("Cached:", buffer);
|
||||
result[1].total = getentry ("SwapTotal:", buffer);
|
||||
result[1].free = getentry ("SwapFree:", buffer);
|
||||
#else
|
||||
result[0].total = 0;
|
||||
result[0].free = 0;
|
||||
result[0].shared = 0;
|
||||
result[0].buffers = 0;
|
||||
result[0].cache = 0;
|
||||
result[1].total = 0;
|
||||
result[1].free = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
mem_init ()
|
||||
{
|
||||
#ifndef SOLARIS
|
||||
if (!meminfo_fd) {
|
||||
meminfo_fd = open ("/proc/meminfo", O_RDONLY);
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
mem_close ()
|
||||
{
|
||||
#ifndef SOLARIS
|
||||
if (meminfo_fd)
|
||||
meminfo_fd = open ("/proc/meminfo", O_RDONLY);
|
||||
|
||||
meminfo_fd = 0;
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
#include "load.h"
|
||||
#include "mem.h"
|
||||
|
||||
#ifdef SOLARIS
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
int ELLIPSIS = '-';
|
||||
|
||||
// TODO: Clean this up... Support multiple display sizes..
|
||||
|
||||
@@ -8,6 +8,10 @@ case "$host" in
|
||||
*-*-*linux*)
|
||||
AC_DEFINE(LINUX)
|
||||
;;
|
||||
*-*-*solaris*)
|
||||
AC_DEFINE(SOLARIS)
|
||||
LIBS="-lnsl -lsocket"
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_MSG_CHECKING(whether to enable debugging)
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "../../shared/debug.h"
|
||||
#include "../../shared/str.h"
|
||||
#include "../../config.h"
|
||||
|
||||
static int custom = 0;
|
||||
typedef enum {
|
||||
@@ -138,7 +139,9 @@ CFontz_init (lcd_logical_driver * driver, char *args)
|
||||
tcgetattr (fd, &portset);
|
||||
// This is necessary in Linux, but does not exist in irix.
|
||||
#ifndef IRIX
|
||||
#ifndef SOLARIS
|
||||
cfmakeraw (&portset);
|
||||
#endif
|
||||
#endif
|
||||
cfsetospeed (&portset, speed);
|
||||
cfsetispeed (&portset, speed);
|
||||
|
||||
@@ -2,7 +2,7 @@ noinst_LIBRARIES = libLCDdrivers.a
|
||||
libLCDdrivers_a_SOURCES = lcd.c lcd.h drv_base.c
|
||||
EXTRA_libLCDdrivers_a_SOURCES = MtxOrb.c MtxOrb.h text.c text.h \
|
||||
curses_drv.c curses_drv.h drv_base.c drv_base.h \
|
||||
hd44780.c hd44780.h \
|
||||
hd44780.c hd44780.h lb216.c lb216.h \
|
||||
hd44780-4bit.c hd44780-4bit.h \
|
||||
hd44780-ext8bit.c hd44780-ext8bit.h lcd_sem.c lcd_sem.h \
|
||||
hd44780-serialLpt.c hd44780-serialLpt.h \
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "../../shared/debug.h"
|
||||
#include "../../shared/str.h"
|
||||
#include "../../config.h"
|
||||
|
||||
static int custom = 0;
|
||||
|
||||
@@ -149,7 +150,9 @@ MtxOrb_init (lcd_logical_driver * driver, char *args)
|
||||
tcgetattr (fd, &portset);
|
||||
// This is necessary in Linux, but does not exist in irix.
|
||||
#ifndef IRIX
|
||||
#ifndef SOLARIS
|
||||
cfmakeraw (&portset);
|
||||
#endif
|
||||
#endif
|
||||
cfsetospeed (&portset, speed);
|
||||
cfsetispeed (&portset, speed);
|
||||
|
||||
@@ -0,0 +1,599 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <termios.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <ncurses.h>
|
||||
|
||||
#include "../../shared/str.h"
|
||||
|
||||
#include "lcd.h"
|
||||
#include "lb216.h"
|
||||
#include "drv_base.h"
|
||||
|
||||
#include "../render.h"
|
||||
|
||||
#include "../../shared/debug.h"
|
||||
#include "../../config.h"
|
||||
|
||||
static int custom=0;
|
||||
typedef enum {
|
||||
hbar = 1,
|
||||
vbar = 2,
|
||||
bign = 4,
|
||||
beat = 8 } custom_type;
|
||||
|
||||
|
||||
|
||||
static int fd;
|
||||
|
||||
static void LB216_hidecursor();
|
||||
static void LB216_reboot();
|
||||
|
||||
// TODO: Get rid of this variable?
|
||||
lcd_logical_driver *LB216;
|
||||
// TODO: Get the frame buffers working right
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Opens com port and sets baud correctly...
|
||||
//
|
||||
int LB216_init(lcd_logical_driver *driver, char *args)
|
||||
{
|
||||
char *argv[64];
|
||||
int argc;
|
||||
struct termios portset;
|
||||
int i;
|
||||
int tmp;
|
||||
int reboot=0;
|
||||
|
||||
char device[256] = "/dev/lcd";
|
||||
int speed=B9600;
|
||||
|
||||
LB216 = driver;
|
||||
|
||||
//debug("LB216_init: Args(all): %s\n", args);
|
||||
|
||||
argc = get_args(argv, args, 64);
|
||||
|
||||
/*
|
||||
for(i=0; i<argc; i++)
|
||||
{
|
||||
printf("Arg(%i): %s\n", i, argv[i]);
|
||||
}
|
||||
*/
|
||||
|
||||
for(i=0; i<argc; i++)
|
||||
{
|
||||
//printf("Arg(%i): %s\n", i, argv[i]);
|
||||
if(0 == strcmp(argv[i], "-d") ||
|
||||
0 == strcmp(argv[i], "--device"))
|
||||
{
|
||||
if(i + 1 > argc) {
|
||||
fprintf(stderr, "LB216_init: %s requires an argument\n",
|
||||
argv[i]);
|
||||
return -1;
|
||||
}
|
||||
strcpy(device, argv[++i]);
|
||||
}
|
||||
else if(0 == strcmp(argv[i], "-b") ||
|
||||
0 == strcmp(argv[i], "--brightness"))
|
||||
{
|
||||
if(i + 1 > argc) {
|
||||
fprintf(stderr, "LB216_init: %s requires an argument\n",
|
||||
argv[i]);
|
||||
return -1;
|
||||
}
|
||||
tmp = atoi(argv[++i]);
|
||||
if((tmp < 0) || (tmp > 255)){
|
||||
fprintf(stderr, "LB216_init: %s argument must between 0 and 255. Using default value.\n",
|
||||
argv[i]);
|
||||
} else backlight_brightness = tmp;
|
||||
}
|
||||
else if(0 == strcmp(argv[i], "-s") ||
|
||||
0 == strcmp(argv[i], "--speed"))
|
||||
{
|
||||
if(i + 1 > argc) {
|
||||
fprintf(stderr, "LB216_init: %s requires an argument\n",
|
||||
argv[i]);
|
||||
return -1;
|
||||
}
|
||||
tmp = atoi(argv[++i]);
|
||||
if(tmp==2400) speed=B2400;
|
||||
else if(tmp==9600) speed=B9600;
|
||||
else {
|
||||
fprintf(stderr, "LB216_init: %s argument must be 2400, or 9600. Using default value.\n",
|
||||
argv[i]);
|
||||
}
|
||||
}
|
||||
else if(0 == strcmp(argv[i], "-h") ||
|
||||
0 == strcmp(argv[i], "--help"))
|
||||
{
|
||||
printf("LCDproc LB216 LCD driver\n"
|
||||
"\t-d\t--device\tSelect the output device to use [/dev/lcd]\n"
|
||||
"\t-t\t--type\t\tSelect the LCD type (size) [16x2]\n"
|
||||
"\t-b\t--brightness\tSet the initial brightness [255]\n"
|
||||
"\t-s\t--speed\t\tSet the communication speed [9600]\n"
|
||||
"\t-r\t--reboot\tReinitialize the LCD's BIOS\n"
|
||||
"\t-h\t--help\t\tShow this help information\n");
|
||||
return -1;
|
||||
}
|
||||
else if(0 == strcmp(argv[i], "-r") ||
|
||||
0 == strcmp(argv[i], "--reboot"))
|
||||
{
|
||||
printf("LCDd: rebooting LB216 LCD...\n");
|
||||
reboot=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Invalid parameter: %s\n", argv[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Set up io port correctly, and open it...
|
||||
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
if (fd == -1)
|
||||
{
|
||||
fprintf(stderr, "LB216_init: failed (%s)\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
//else fprintf(stderr, "LB216_init: opened device %s\n", device);
|
||||
tcgetattr(fd, &portset);
|
||||
// This is necessary in Linux, but does not exist in irix or solaris.
|
||||
#ifndef IRIX
|
||||
#ifndef SOLARIS
|
||||
cfmakeraw(&portset);
|
||||
#endif
|
||||
#endif
|
||||
cfsetospeed(&portset, speed);
|
||||
cfsetispeed(&portset, speed);
|
||||
tcsetattr(fd, TCSANOW, &portset);
|
||||
|
||||
|
||||
// Set display-specific stuff..
|
||||
if(reboot)
|
||||
{
|
||||
LB216_reboot();
|
||||
sleep(4);
|
||||
reboot=0;
|
||||
}
|
||||
sleep(1);
|
||||
LB216_hidecursor();
|
||||
LB216_backlight(backlight_brightness);
|
||||
|
||||
|
||||
if(!driver->framebuf)
|
||||
{
|
||||
fprintf(stderr, "LB216_init: No frame buffer.\n");
|
||||
driver->close();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// Set the functions the driver supports...
|
||||
|
||||
driver->clear = NULL;
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
lcd.cellwid = 5;
|
||||
lcd.cellhgt = 8;
|
||||
|
||||
debug("LB216: foo!\n");
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clean-up
|
||||
//
|
||||
void LB216_close()
|
||||
{
|
||||
close (fd);
|
||||
|
||||
if(LB216->framebuf) free(LB216->framebuf);
|
||||
|
||||
LB216->framebuf = NULL;
|
||||
}
|
||||
|
||||
|
||||
void LB216_flush()
|
||||
{
|
||||
LB216_draw_frame(lcd.framebuf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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)
|
||||
{
|
||||
//y--;
|
||||
// x--;
|
||||
|
||||
//if(c < 32 && c >= 0) c += 128;
|
||||
// lcd.framebuf[(y*lcd.wid) + x] = c;
|
||||
char chr[1];
|
||||
sprintf(chr, "%c", c);
|
||||
LB216_string (x, y, chr);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets the backlight on or off -- can be done quickly for
|
||||
// an intermediate brightness...
|
||||
//
|
||||
void LB216_backlight(int on)
|
||||
{
|
||||
char out[4];
|
||||
if(on)
|
||||
{
|
||||
sprintf(out, "%c%c", 254, 253);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(out, "%c%c", 254, 252);
|
||||
}
|
||||
write(fd, out, 2);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Get rid of the blinking curson
|
||||
//
|
||||
static void LB216_hidecursor()
|
||||
{
|
||||
char out[4];
|
||||
sprintf(out, "%c%c", 254,12);
|
||||
write(fd, out, 2);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Reset the display bios
|
||||
//
|
||||
static void LB216_reboot()
|
||||
{
|
||||
char out[4];
|
||||
sprintf(out, "%c%c", 254,1);
|
||||
write(fd, out, 2);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Blasts a single frame onscreen, to the lcd...
|
||||
//
|
||||
// Input is a character array, sized lcd.wid*lcd.hgt
|
||||
//
|
||||
void LB216_draw_frame(char *dat)
|
||||
{
|
||||
char out[LCD_MAX_WIDTH * LCD_MAX_HEIGHT];
|
||||
int i,j;
|
||||
|
||||
if(!dat) return;
|
||||
|
||||
sprintf(out, "%c%c", 254,80);
|
||||
write(fd, out, 2);
|
||||
|
||||
|
||||
for(j=0; j<lcd.hgt; j++) {
|
||||
sprintf(out,"%c%c",254,128+(64*(j)));
|
||||
// printf ("|\n|");
|
||||
write(fd, out, 2);
|
||||
for(i=0; i<lcd.wid; i++) {
|
||||
sprintf(out,"%c",dat[i+(j*lcd.wid)]);
|
||||
// printf("%d,",out[0]);
|
||||
write(fd, out, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LB216_string (int x, int y, char string[])
|
||||
{
|
||||
int i;
|
||||
char c;
|
||||
|
||||
//printf("%d,%d:%s\n",x,y,string);
|
||||
y--;x--;
|
||||
for(i=0; string[i]; i++)
|
||||
{
|
||||
c = string[i];
|
||||
switch(c)
|
||||
{
|
||||
case '\254': c = '#'; break;
|
||||
}
|
||||
lcd.framebuf[(y*lcd.wid) + x+i] = c;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets up for vertical bars. Call before lcd.vbar()
|
||||
//
|
||||
void LB216_init_vbar()
|
||||
{
|
||||
char a[] = {
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
1,1,1,1,1,
|
||||
};
|
||||
char b[] = {
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
};
|
||||
char c[] = {
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
};
|
||||
char d[] = {
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
};
|
||||
char e[] = {
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
};
|
||||
char f[] = {
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
};
|
||||
char g[] = {
|
||||
0,0,0,0,0,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
};
|
||||
|
||||
if(custom!=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);
|
||||
custom=vbar;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Inits horizontal bars...
|
||||
//
|
||||
void LB216_init_hbar()
|
||||
{
|
||||
|
||||
char a[] = {
|
||||
1,0,0,0,0,
|
||||
1,0,0,0,0,
|
||||
1,0,0,0,0,
|
||||
1,0,0,0,0,
|
||||
1,0,0,0,0,
|
||||
1,0,0,0,0,
|
||||
1,0,0,0,0,
|
||||
1,0,0,0,0,
|
||||
};
|
||||
char b[] = {
|
||||
1,1,0,0,0,
|
||||
1,1,0,0,0,
|
||||
1,1,0,0,0,
|
||||
1,1,0,0,0,
|
||||
1,1,0,0,0,
|
||||
1,1,0,0,0,
|
||||
1,1,0,0,0,
|
||||
1,1,0,0,0,
|
||||
};
|
||||
char c[] = {
|
||||
1,1,1,0,0,
|
||||
1,1,1,0,0,
|
||||
1,1,1,0,0,
|
||||
1,1,1,0,0,
|
||||
1,1,1,0,0,
|
||||
1,1,1,0,0,
|
||||
1,1,1,0,0,
|
||||
1,1,1,0,0,
|
||||
};
|
||||
char d[] = {
|
||||
1,1,1,1,0,
|
||||
1,1,1,1,0,
|
||||
1,1,1,1,0,
|
||||
1,1,1,1,0,
|
||||
1,1,1,1,0,
|
||||
1,1,1,1,0,
|
||||
1,1,1,1,0,
|
||||
1,1,1,1,0,
|
||||
};
|
||||
char e[] = {
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
};
|
||||
|
||||
if(custom!=hbar) {
|
||||
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);
|
||||
custom=hbar;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a vertical bar...
|
||||
//
|
||||
void LB216_vbar(int x, int len)
|
||||
{
|
||||
char map[9] = {32, 1, 2, 3, 4, 5, 6, 7, 255 };
|
||||
|
||||
|
||||
int y;
|
||||
for(y=lcd.hgt; y > 0 && len>0; y--)
|
||||
{
|
||||
if(len >= lcd.cellhgt) LB216_chr(x, y, 255);
|
||||
else LB216_chr(x, y, map[len]);
|
||||
|
||||
len -= lcd.cellhgt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
void LB216_hbar(int x, int y, int len)
|
||||
{
|
||||
char map[7] = { 32, 1, 2, 3, 4, 5 };
|
||||
|
||||
for(; x<=lcd.wid && len>0; x++)
|
||||
{
|
||||
if(len >= lcd.cellwid) LB216_chr(x,y,map[5]);
|
||||
else LB216_chr(x, y, map[len]);
|
||||
|
||||
//printf ("%d,",len);
|
||||
len -= lcd.cellwid;
|
||||
|
||||
}
|
||||
// printf ("\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets a custom character from 0-7...
|
||||
//
|
||||
// For input, values > 0 mean "on" and values <= 0 are "off".
|
||||
//
|
||||
// The input is just an array of characters...
|
||||
//
|
||||
void LB216_set_char(int n, char *dat)
|
||||
{
|
||||
char out[4];
|
||||
int row, col;
|
||||
int letter;
|
||||
|
||||
if(n < 0 || n > 7) return;
|
||||
n=64+(8*n);
|
||||
if(!dat) return;
|
||||
|
||||
sprintf(out, "%c%c", 254, n);
|
||||
write(fd, out, 2);
|
||||
|
||||
for(row=0; row<lcd.cellhgt; row++)
|
||||
{
|
||||
letter = 1;
|
||||
for(col=0; col<lcd.cellwid; col++)
|
||||
{
|
||||
letter <<= 1;
|
||||
letter |= (dat[(row*lcd.cellwid) + col] > 0);
|
||||
}
|
||||
sprintf(out,"%c",letter);
|
||||
write(fd, out, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void LB216_icon(int which, char dest)
|
||||
{
|
||||
char icons[3][8*8] = {
|
||||
{
|
||||
1,1,1,1,1, // Empty Heart
|
||||
1,0,1,0,1,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
1,0,0,0,1,
|
||||
1,1,0,1,1,
|
||||
1,1,1,1,1,
|
||||
},
|
||||
|
||||
{
|
||||
1,1,1,1,1, // Filled Heart
|
||||
1,0,1,0,1,
|
||||
0,1,0,1,0,
|
||||
0,1,1,1,0,
|
||||
0,1,1,1,0,
|
||||
1,0,1,0,1,
|
||||
1,1,0,1,1,
|
||||
1,1,1,1,1,
|
||||
},
|
||||
|
||||
{
|
||||
0,0,0,0,0, // Ellipsis
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
1,0,1,0,1,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
if(custom==bign) custom=beat;
|
||||
LB216_set_char(dest, &icons[which][0]);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef LB216_H
|
||||
#define LB216_H
|
||||
|
||||
|
||||
extern lcd_logical_driver *LB216;
|
||||
|
||||
int LB216_init(lcd_logical_driver *driver, char *device);
|
||||
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);
|
||||
|
||||
#endif
|
||||
@@ -24,6 +24,10 @@
|
||||
#include "CFontz.h"
|
||||
#endif
|
||||
|
||||
#ifdef LB216_DRV
|
||||
#include "lb216.h"
|
||||
#endif
|
||||
|
||||
#ifdef TEXT_DRV
|
||||
#include "text.h"
|
||||
#endif
|
||||
@@ -74,6 +78,9 @@ lcd_physical_driver drivers[] = {
|
||||
#ifdef SLI_DRV
|
||||
{"sli", sli_init,},
|
||||
#endif
|
||||
#ifdef LB216_DRV
|
||||
{"LB216", LB216_init,},
|
||||
#endif
|
||||
#ifdef TEXT_DRV
|
||||
{"text", text_init,},
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -303,7 +303,7 @@ HelpScreen ()
|
||||
printf ("\t-h\t--help\n\t\t\tDisplay this help screen\n");
|
||||
printf ("\t-t\t--type <size>\n\t\t\tSelect an LCD size (20x4, 16x2, etc...)\n");
|
||||
printf ("\t-d\t--driver <driver> [args]\n\t\t\tAdd a driver to use:\n");
|
||||
printf ("\t\t\tCFontz, curses, HD44780, irmanin, joy,\n\t\t\tMtxOrb, text\n");
|
||||
printf ("\t\t\tCFontz, curses, HD44780, irmanin, joy,\n\t\t\tMtxOrb, LB216, text\n");
|
||||
printf ("\t\t\t(args will be passed to the driver for init)\n");
|
||||
printf ("\t-f\t--foreground\n\t\t\tRun in the foreground (no daemon)\n");
|
||||
printf ("\t-b\t--backlight <mode>\n\t\t\tSet backlight mode (on, off, open)\n");
|
||||
|
||||
Reference in New Issue
Block a user