mirror of
https://github.com/netfun2000/lcd4linux.git
synced 2026-02-27 09:44:34 +08:00
[lcd4linux @ 2004-06-02 10:09:22 by reinelt]
splash screen for HD44780 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@462 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
This commit is contained in:
45
drv.c
45
drv.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: drv.c,v 1.16 2004/06/02 09:41:19 reinelt Exp $
|
/* $Id: drv.c,v 1.17 2004/06/02 10:09:22 reinelt Exp $
|
||||||
*
|
*
|
||||||
* new framework for display drivers
|
* new framework for display drivers
|
||||||
*
|
*
|
||||||
@@ -23,6 +23,10 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* $Log: drv.c,v $
|
* $Log: drv.c,v $
|
||||||
|
* Revision 1.17 2004/06/02 10:09:22 reinelt
|
||||||
|
*
|
||||||
|
* splash screen for HD44780
|
||||||
|
*
|
||||||
* Revision 1.16 2004/06/02 09:41:19 reinelt
|
* Revision 1.16 2004/06/02 09:41:19 reinelt
|
||||||
*
|
*
|
||||||
* prepared support for startup splash screen
|
* prepared support for startup splash screen
|
||||||
@@ -207,45 +211,6 @@ DRIVER *Driver[] = {
|
|||||||
static DRIVER *Drv = NULL;
|
static DRIVER *Drv = NULL;
|
||||||
|
|
||||||
|
|
||||||
// Fixme
|
|
||||||
char* drv_hello (int line, int cols)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
static char *line1[] = { "* LCD4Linux " VERSION " *",
|
|
||||||
"LCD4Linux " VERSION,
|
|
||||||
"* LCD4Linux *",
|
|
||||||
"LCD4Linux",
|
|
||||||
"L4Linux",
|
|
||||||
NULL };
|
|
||||||
|
|
||||||
static char *line2[] = { "http://lcd4linux.sourceforge.net",
|
|
||||||
"lcd4linux.sourceforge.net",
|
|
||||||
"http://lcd4linux.sf.net",
|
|
||||||
"lcd4linux.sf.net",
|
|
||||||
NULL };
|
|
||||||
|
|
||||||
|
|
||||||
switch (line) {
|
|
||||||
case 1:
|
|
||||||
for (i = 0; line1[i]; i++) {
|
|
||||||
if (strlen(line1[i]) <= cols) {
|
|
||||||
return line1[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
for (i = 0; line2[i]; i++) {
|
|
||||||
if (strlen(line2[i]) <= cols) {
|
|
||||||
return line2[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int drv_list (void)
|
int drv_list (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: drv_HD44780.c,v 1.25 2004/06/02 09:41:19 reinelt Exp $
|
/* $Id: drv_HD44780.c,v 1.26 2004/06/02 10:09:22 reinelt Exp $
|
||||||
*
|
*
|
||||||
* new style driver for HD44780-based displays
|
* new style driver for HD44780-based displays
|
||||||
*
|
*
|
||||||
@@ -29,6 +29,10 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* $Log: drv_HD44780.c,v $
|
* $Log: drv_HD44780.c,v $
|
||||||
|
* Revision 1.26 2004/06/02 10:09:22 reinelt
|
||||||
|
*
|
||||||
|
* splash screen for HD44780
|
||||||
|
*
|
||||||
* Revision 1.25 2004/06/02 09:41:19 reinelt
|
* Revision 1.25 2004/06/02 09:41:19 reinelt
|
||||||
*
|
*
|
||||||
* prepared support for startup splash screen
|
* prepared support for startup splash screen
|
||||||
@@ -586,7 +590,7 @@ static void drv_HD_setGPO (int bits)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static int drv_HD_start (char *section)
|
static int drv_HD_start (char *section, int quiet)
|
||||||
{
|
{
|
||||||
char *model, *strsize;
|
char *model, *strsize;
|
||||||
int rows=-1, cols=-1, gpos=-1;
|
int rows=-1, cols=-1, gpos=-1;
|
||||||
@@ -729,6 +733,15 @@ static int drv_HD_start (char *section)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!quiet) {
|
||||||
|
char buffer[40];
|
||||||
|
qprintf(buffer, sizeof(buffer), "%s %dx%d", Name, DCOLS, DROWS);
|
||||||
|
if (drv_generic_text_greet (buffer)) {
|
||||||
|
sleep (3);
|
||||||
|
drv_HD_command (allControllers, 0x01, T_CLEAR); // clear *both* displays
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -794,7 +807,7 @@ int drv_HD_init (char *section, int quiet)
|
|||||||
|
|
||||||
|
|
||||||
// start display
|
// start display
|
||||||
if ((ret=drv_HD_start (section))!=0)
|
if ((ret=drv_HD_start (section, quiet))!=0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
// initialize generic text driver
|
// initialize generic text driver
|
||||||
@@ -834,48 +847,8 @@ int drv_HD_init (char *section, int quiet)
|
|||||||
widget_register(&wc);
|
widget_register(&wc);
|
||||||
|
|
||||||
// register plugins
|
// register plugins
|
||||||
if (Capabilities & CAP_BRIGHTNESS)
|
if (Capabilities & CAP_BRIGHTNESS) {
|
||||||
AddFunction ("LCD::brightness", 1, plugin_brightness);
|
AddFunction ("LCD::brightness", 1, plugin_brightness);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// say hello to the user
|
|
||||||
static int drv_HD_greet (int start_stop)
|
|
||||||
{
|
|
||||||
int flag = 0;
|
|
||||||
char buffer[40];
|
|
||||||
char *msg;
|
|
||||||
|
|
||||||
drv_HD_command (allControllers, 0x01, T_CLEAR); // clear *both* displays
|
|
||||||
|
|
||||||
msg = drv_hello (1, DCOLS);
|
|
||||||
if (msg != NULL) {
|
|
||||||
drv_HD_write (0, (DCOLS-strlen(msg))/2, msg, strlen(msg));
|
|
||||||
flag = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DROWS >= 2) {
|
|
||||||
msg = drv_hello (2, DCOLS);
|
|
||||||
if (msg != NULL) {
|
|
||||||
drv_HD_write (1, (DCOLS-strlen(msg))/2, msg, strlen(msg));
|
|
||||||
flag = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DROWS >= 3) {
|
|
||||||
qprintf(buffer, sizeof(buffer), "HD44780 %dx%d", DCOLS, DROWS);
|
|
||||||
msg = buffer;
|
|
||||||
if (strlen(msg) <= DCOLS) {
|
|
||||||
drv_HD_write (2, (DCOLS-strlen(msg))/2, msg, strlen(msg));
|
|
||||||
flag = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flag && start_stop) {
|
|
||||||
sleep (3);
|
|
||||||
drv_HD_command (allControllers, 0x01, T_CLEAR); // clear *both* displays
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -886,8 +859,13 @@ static int drv_HD_greet (int start_stop)
|
|||||||
int drv_HD_quit (void) {
|
int drv_HD_quit (void) {
|
||||||
|
|
||||||
info("%s: shutting down.", Name);
|
info("%s: shutting down.", Name);
|
||||||
drv_generic_parport_close();
|
|
||||||
drv_generic_text_quit();
|
drv_generic_text_quit();
|
||||||
|
|
||||||
|
drv_HD_command (allControllers, 0x01, T_CLEAR); // clear *both* displays
|
||||||
|
drv_generic_text_greet ("good bye!");
|
||||||
|
|
||||||
|
drv_generic_parport_close();
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: drv_generic_text.c,v 1.15 2004/06/01 06:45:30 reinelt Exp $
|
/* $Id: drv_generic_text.c,v 1.16 2004/06/02 10:09:22 reinelt Exp $
|
||||||
*
|
*
|
||||||
* generic driver helper for text-based displays
|
* generic driver helper for text-based displays
|
||||||
*
|
*
|
||||||
@@ -23,6 +23,10 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* $Log: drv_generic_text.c,v $
|
* $Log: drv_generic_text.c,v $
|
||||||
|
* Revision 1.16 2004/06/02 10:09:22 reinelt
|
||||||
|
*
|
||||||
|
* splash screen for HD44780
|
||||||
|
*
|
||||||
* Revision 1.15 2004/06/01 06:45:30 reinelt
|
* Revision 1.15 2004/06/01 06:45:30 reinelt
|
||||||
*
|
*
|
||||||
* some Fixme's processed
|
* some Fixme's processed
|
||||||
@@ -266,6 +270,85 @@ static void drv_generic_text_resizeFB (int rows, int cols)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ****************************************
|
||||||
|
// *** generic text handling ***
|
||||||
|
// ****************************************
|
||||||
|
|
||||||
|
int drv_generic_text_init (char *section, char *driver)
|
||||||
|
{
|
||||||
|
|
||||||
|
Section=section;
|
||||||
|
Driver=driver;
|
||||||
|
|
||||||
|
// init display framebuffer
|
||||||
|
DisplayFB = (char*)malloc(DCOLS*DROWS*sizeof(char));
|
||||||
|
memset (DisplayFB, ' ', DROWS*DCOLS*sizeof(char));
|
||||||
|
|
||||||
|
// init layout framebuffer
|
||||||
|
LROWS = 0;
|
||||||
|
LCOLS = 0;
|
||||||
|
LayoutFB=NULL;
|
||||||
|
drv_generic_text_resizeFB (DROWS, DCOLS);
|
||||||
|
|
||||||
|
// sanity check
|
||||||
|
if (LayoutFB==NULL || DisplayFB==NULL) {
|
||||||
|
error ("%s: framebuffer could not be allocated: malloc() failed", Driver);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// say hello to the user
|
||||||
|
int drv_generic_text_greet (char *message)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int flag = 0;
|
||||||
|
|
||||||
|
char *line1[] = { "* LCD4Linux " VERSION " *",
|
||||||
|
"LCD4Linux " VERSION,
|
||||||
|
"* LCD4Linux *",
|
||||||
|
"LCD4Linux",
|
||||||
|
"L4Linux",
|
||||||
|
NULL };
|
||||||
|
|
||||||
|
char *line2[] = { "http://lcd4linux.sourceforge.net",
|
||||||
|
"lcd4linux.sourceforge.net",
|
||||||
|
"http://lcd4linux.sf.net",
|
||||||
|
"lcd4linux.sf.net",
|
||||||
|
NULL };
|
||||||
|
|
||||||
|
|
||||||
|
for (i = 0; line1[i]; i++) {
|
||||||
|
if (strlen(line1[i]) <= DCOLS) {
|
||||||
|
drv_generic_text_real_write (0, (DCOLS-strlen(line1[i]))/2, line1[i], strlen(line1[i]));
|
||||||
|
flag = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DROWS >= 2) {
|
||||||
|
for (i = 0; line2[i]; i++) {
|
||||||
|
if (strlen(line2[i]) <= DCOLS) {
|
||||||
|
drv_generic_text_real_write (1, (DCOLS-strlen(line2[i]))/2, line2[i], strlen(line2[i]));
|
||||||
|
flag = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message && DROWS >= 3) {
|
||||||
|
int len = strlen(message);
|
||||||
|
if ( len <= DCOLS) {
|
||||||
|
drv_generic_text_real_write (2, (DCOLS-len)/2, message, len);
|
||||||
|
flag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int drv_generic_text_draw (WIDGET *W)
|
int drv_generic_text_draw (WIDGET *W)
|
||||||
{
|
{
|
||||||
@@ -312,10 +395,42 @@ int drv_generic_text_draw (WIDGET *W)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int drv_generic_text_quit (void) {
|
||||||
|
|
||||||
|
if (LayoutFB) {
|
||||||
|
free(LayoutFB);
|
||||||
|
LayoutFB=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DisplayFB) {
|
||||||
|
free(DisplayFB);
|
||||||
|
DisplayFB=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BarFB) {
|
||||||
|
free (BarFB);
|
||||||
|
BarFB=NULL;
|
||||||
|
}
|
||||||
|
widget_unregister();
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ****************************************
|
// ****************************************
|
||||||
// *** generic icon handling ***
|
// *** generic icon handling ***
|
||||||
// ****************************************
|
// ****************************************
|
||||||
|
|
||||||
|
int drv_generic_text_icon_init (void)
|
||||||
|
{
|
||||||
|
if (cfg_number(Section, "Icons", 0, 0, CHARS, &ICONS)<0) return -1;
|
||||||
|
if (ICONS>0) {
|
||||||
|
info ("%s: reserving %d of %d user-defined characters for icons", Driver, ICONS, CHARS);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int drv_generic_text_icon_draw (WIDGET *W)
|
int drv_generic_text_icon_draw (WIDGET *W)
|
||||||
{
|
{
|
||||||
static int icon_counter=0;
|
static int icon_counter=0;
|
||||||
@@ -386,6 +501,39 @@ static void drv_generic_text_bar_clear(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int drv_generic_text_bar_init (int single_segments)
|
||||||
|
{
|
||||||
|
if (BarFB) free (BarFB);
|
||||||
|
|
||||||
|
if ((BarFB=malloc (LROWS*LCOLS*sizeof(BAR)))==NULL) {
|
||||||
|
error ("bar buffer allocation failed: out of memory");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Single_Segments = single_segments;
|
||||||
|
|
||||||
|
nSegment=0;
|
||||||
|
fSegment=0;
|
||||||
|
|
||||||
|
drv_generic_text_bar_clear();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void drv_generic_text_bar_add_segment(int val1, int val2, DIRECTION dir, int ascii)
|
||||||
|
{
|
||||||
|
Segment[fSegment].val1=val1;
|
||||||
|
Segment[fSegment].val2=val2;
|
||||||
|
Segment[fSegment].dir=dir;
|
||||||
|
Segment[fSegment].used=0;
|
||||||
|
Segment[fSegment].ascii=ascii;
|
||||||
|
|
||||||
|
fSegment++;
|
||||||
|
nSegment=fSegment;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void drv_generic_text_bar_create_bar (int row, int col, DIRECTION dir, int len, int val1, int val2)
|
static void drv_generic_text_bar_create_bar (int row, int col, DIRECTION dir, int len, int val1, int val2)
|
||||||
{
|
{
|
||||||
int rev=0;
|
int rev=0;
|
||||||
@@ -725,96 +873,3 @@ int drv_generic_text_bar_draw (WIDGET *W)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ****************************************
|
|
||||||
// *** generic init/quit ***
|
|
||||||
// ****************************************
|
|
||||||
|
|
||||||
int drv_generic_text_init (char *section, char *driver)
|
|
||||||
{
|
|
||||||
|
|
||||||
Section=section;
|
|
||||||
Driver=driver;
|
|
||||||
|
|
||||||
// init display framebuffer
|
|
||||||
DisplayFB = (char*)malloc(DCOLS*DROWS*sizeof(char));
|
|
||||||
memset (DisplayFB, ' ', DROWS*DCOLS*sizeof(char));
|
|
||||||
|
|
||||||
// init layout framebuffer
|
|
||||||
LROWS = 0;
|
|
||||||
LCOLS = 0;
|
|
||||||
LayoutFB=NULL;
|
|
||||||
drv_generic_text_resizeFB (DROWS, DCOLS);
|
|
||||||
|
|
||||||
// sanity check
|
|
||||||
if (LayoutFB==NULL || DisplayFB==NULL) {
|
|
||||||
error ("%s: framebuffer could not be allocated: malloc() failed", Driver);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int drv_generic_text_icon_init (void)
|
|
||||||
{
|
|
||||||
if (cfg_number(Section, "Icons", 0, 0, CHARS, &ICONS)<0) return -1;
|
|
||||||
if (ICONS>0) {
|
|
||||||
info ("%s: reserving %d of %d user-defined characters for icons", Driver, ICONS, CHARS);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int drv_generic_text_bar_init (int single_segments)
|
|
||||||
{
|
|
||||||
if (BarFB) free (BarFB);
|
|
||||||
|
|
||||||
if ((BarFB=malloc (LROWS*LCOLS*sizeof(BAR)))==NULL) {
|
|
||||||
error ("bar buffer allocation failed: out of memory");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Single_Segments = single_segments;
|
|
||||||
|
|
||||||
nSegment=0;
|
|
||||||
fSegment=0;
|
|
||||||
|
|
||||||
drv_generic_text_bar_clear();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void drv_generic_text_bar_add_segment(int val1, int val2, DIRECTION dir, int ascii)
|
|
||||||
{
|
|
||||||
Segment[fSegment].val1=val1;
|
|
||||||
Segment[fSegment].val2=val2;
|
|
||||||
Segment[fSegment].dir=dir;
|
|
||||||
Segment[fSegment].used=0;
|
|
||||||
Segment[fSegment].ascii=ascii;
|
|
||||||
|
|
||||||
fSegment++;
|
|
||||||
nSegment=fSegment;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int drv_generic_text_quit (void) {
|
|
||||||
|
|
||||||
if (LayoutFB) {
|
|
||||||
free(LayoutFB);
|
|
||||||
LayoutFB=NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DisplayFB) {
|
|
||||||
free(DisplayFB);
|
|
||||||
DisplayFB=NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (BarFB) {
|
|
||||||
free (BarFB);
|
|
||||||
BarFB=NULL;
|
|
||||||
}
|
|
||||||
widget_unregister();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: drv_generic_text.h,v 1.10 2004/06/01 06:45:30 reinelt Exp $
|
/* $Id: drv_generic_text.h,v 1.11 2004/06/02 10:09:22 reinelt Exp $
|
||||||
*
|
*
|
||||||
* generic driver helper for text-based displays
|
* generic driver helper for text-based displays
|
||||||
*
|
*
|
||||||
@@ -23,6 +23,10 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* $Log: drv_generic_text.h,v $
|
* $Log: drv_generic_text.h,v $
|
||||||
|
* Revision 1.11 2004/06/02 10:09:22 reinelt
|
||||||
|
*
|
||||||
|
* splash screen for HD44780
|
||||||
|
*
|
||||||
* Revision 1.10 2004/06/01 06:45:30 reinelt
|
* Revision 1.10 2004/06/01 06:45:30 reinelt
|
||||||
*
|
*
|
||||||
* some Fixme's processed
|
* some Fixme's processed
|
||||||
@@ -88,6 +92,7 @@ void (*drv_generic_text_real_defchar)(int ascii, unsigned char *buffer);
|
|||||||
|
|
||||||
// generic functions and widget callbacks
|
// generic functions and widget callbacks
|
||||||
int drv_generic_text_init (char *section, char *driver);
|
int drv_generic_text_init (char *section, char *driver);
|
||||||
|
int drv_generic_text_greet (char *message);
|
||||||
int drv_generic_text_draw (WIDGET *W);
|
int drv_generic_text_draw (WIDGET *W);
|
||||||
int drv_generic_text_icon_init (void);
|
int drv_generic_text_icon_init (void);
|
||||||
int drv_generic_text_icon_draw (WIDGET *W);
|
int drv_generic_text_icon_draw (WIDGET *W);
|
||||||
|
|||||||
Reference in New Issue
Block a user