Make driver start in background and return 0 on init success

Convert function descriptions to use doxygen while there
This commit is contained in:
mmdolze
2009-03-22 13:04:27 +00:00
parent 15f2bf4ba3
commit 0a811b47f6
7 changed files with 197 additions and 124 deletions
+1
View File
@@ -66,6 +66,7 @@ v.0.5dev (ongoing development)
* hd44780 driver: update the backlight setting only on change
+ hd44780 driver: add lineaddress option to support ST7036 (Malte Poeggel)
+ lcdproc: Retrieve per CPU usage statistics on FreeBSD (M. Dolze)
* Change drivers to start in background by default: bayrad, CFontz, ea65, glk
v.0.5.2
* fix switching on/off the Load screen in lcdproc client using the menu
+1
View File
@@ -13,6 +13,7 @@ Things for the short term:
- lcterm: Support keyboard input
- MtxOrb: Recover the code for I2C connectivity to MtxOrb
- shuttleVFD: Use output() method for these special "out-of-band" symbols.
- glk: port icon, vBar and hBar to 0.5 API.
Things for the longer term:
+2 -2
View File
@@ -87,7 +87,7 @@ typedef struct CFontz_private_data {
// Vars for the server core
MODULE_EXPORT char *api_version = API_VERSION;
MODULE_EXPORT int stay_in_foreground = 1;
MODULE_EXPORT int stay_in_foreground = 0;
MODULE_EXPORT int supports_multiple = 0;
MODULE_EXPORT char *symbol_prefix = "CFontz_";
@@ -271,7 +271,7 @@ CFontz_init(Driver *drvthis)
report(RPT_DEBUG, "%s: init() done", drvthis->name);
return 1;
return 0;
}
+2 -2
View File
@@ -64,7 +64,7 @@ typedef struct bayrad_private_data {
// Vars for the server core
MODULE_EXPORT char * api_version = API_VERSION;
MODULE_EXPORT int stay_in_foreground = 1;
MODULE_EXPORT int stay_in_foreground = 0;
MODULE_EXPORT int supports_multiple = 0;
MODULE_EXPORT char *symbol_prefix = "bayrad_";
@@ -173,7 +173,7 @@ bayrad_init(Driver *drvthis)
report(RPT_DEBUG, "%s: init() done", drvthis->name);
return 1;
return 0;
}
+78 -45
View File
@@ -1,5 +1,7 @@
/** \file server/drivers/ea65.c
* LCDd \c ea65 driver for the VFD used in the Aopen XC Cube-AV EA65 media barebone.
*
* \todo Implement API functions to change brightness on-the-fly
*/
/* This is the LCDproc driver for the vfd on the Aopen EA65, based on
@@ -55,15 +57,17 @@ typedef struct EA65_private_data {
// Vars for the server core
MODULE_EXPORT char *api_version = API_VERSION;
MODULE_EXPORT int stay_in_foreground = 1;
MODULE_EXPORT int stay_in_foreground = 0;
MODULE_EXPORT int supports_multiple = 0;
MODULE_EXPORT int does_input = 0;
MODULE_EXPORT int does_output = 1;
MODULE_EXPORT char *symbol_prefix = "EA65_";
/////////////////////////////////////////////////////////////////
// Opens com port and sets baud correctly...
//
/**
* Initialize the driver.
* Opens com port and sets baud correctly.
* \param drvthis Pointer to driver structure.
* \retval 0 Success.
* \retval <0 Error.
*/
MODULE_EXPORT int
EA65_init (Driver *drvthis)
{
@@ -82,7 +86,7 @@ EA65_init (Driver *drvthis)
if (drvthis->store_private_ptr(drvthis, p))
return -1;
//// initialize private data
//// initialize private data
// Width and Height are fixed
p->width = 9;
p->height = 1;
@@ -158,23 +162,33 @@ EA65_init (Driver *drvthis)
return 0;
}
/////////////////////////////////////////////////////////////////
// Clean-up
//
/**
* Close the driver (do necessary clean-up).
* \param drvthis Pointer to driver structure.
*/
MODULE_EXPORT void
EA65_close (Driver *drvthis)
{
PrivateData *p = (PrivateData *) drvthis->private_data;
PrivateData *p = drvthis->private_data;
close (p->fd);
if (p != NULL) {
if (p->fd >= 0)
close(p->fd);
if(p->framebuf) free (p->framebuf);
p->framebuf = NULL;
if (p->framebuf)
free(p->framebuf);
p->framebuf = NULL;
free(p);
}
drvthis->store_private_ptr(drvthis, NULL);
}
/////////////////////////////////////////////////////////////////
// Returns the display width
//
/**
* Return the display width in characters.
* \param drvthis Pointer to driver structure.
* \return Number of characters the display is wide.
*/
MODULE_EXPORT int
EA65_width (Driver *drvthis)
{
@@ -183,9 +197,11 @@ EA65_width (Driver *drvthis)
return p->width;
}
/////////////////////////////////////////////////////////////////
// Returns the display height
//
/**
* Return the display height in characters.
* \param drvthis Pointer to driver structure.
* \return Number of characters the display is high.
*/
MODULE_EXPORT int
EA65_height (Driver *drvthis)
{
@@ -194,9 +210,10 @@ EA65_height (Driver *drvthis)
return p->height;
}
//////////////////////////////////////////////////////////////////
// Flushes all output to the lcd...
//
/**
* Flushes all output to the lcd.
* \param drvthis Pointer to driver structure.
*/
MODULE_EXPORT void
EA65_flush (Driver *drvthis)
{
@@ -225,7 +242,7 @@ EA65_flush (Driver *drvthis)
else if (p->framebuf[i] >= 210 && p->framebuf[i] <= 214) // use an "O"
p->framebuf[i] = 79;
else if (p->framebuf[i] >= 217 && p->framebuf[i] <= 220) // use an "U"
p->framebuf[i] = 85;
p->framebuf[i] = 85;
else p->framebuf[i] = 32; // other characters replaced by a space
}
snprintf(out, sizeof(out), "%c%c%c%c%c", 0xa0, 0x00, 0x80, 0x8a, 0x8a);
@@ -233,10 +250,16 @@ EA65_flush (Driver *drvthis)
write(p->fd, p->framebuf, p->width * p->height);
}
/////////////////////////////////////////////////////////////////
// Prints a character on the lcd display, at position (x,y). The
// upper-left is (1,1), and the lower right should be (9,1).
//
/**
* Print a character on the screen at position (x,y).
* The upper-left corner is (1,1), the lower-right corner is (9, 1).
* \param drvthis Pointer to driver structure.
* \param x Horizontal character position (column).
* \param y Vertical character position (row).
* \param c Character that gets written.
*
* \todo Boundary checks necessary
*/
MODULE_EXPORT void
EA65_chr (Driver *drvthis, int x, int y, char c)
{
@@ -249,16 +272,18 @@ EA65_chr (Driver *drvthis, int x, int y, char c)
// c += 128;
// For V2 of the firmware to get the block to display right
//if (newfirmware && c==-1) {
// c=214;
//}
//if (newfirmware && c==-1)
// c = 214;
p->framebuf[(y * p->width) + x] = c;
}
/////////////////////////////////////////////////////////////////
// Sets the backlight on or off
//
/**
* Sets the backlight on or off.
* Uses the \c brightness / \c offbrightness values from \c LCDd.conf
* \param drvthis Pointer to driver structure.
* \param on New backlight status.
*/
MODULE_EXPORT void
EA65_backlight (Driver *drvthis, int on)
{
@@ -273,9 +298,10 @@ EA65_backlight (Driver *drvthis, int on)
write (p->fd, out, 5);
}
/////////////////////////////////////////////////////////////////
// Clears the LCD screen
//
/**
* Clear the screen.
* \param drvthis Pointer to driver structure.
*/
MODULE_EXPORT void
EA65_clear (Driver *drvthis)
{
@@ -285,10 +311,14 @@ EA65_clear (Driver *drvthis)
}
/////////////////////////////////////////////////////////////////
// Prints a string on the lcd display, at position (x,y). The
// upper-left is (1,1), and the lower right should be (9,1).
//
/**
* Print a string on the screen at position (x,y).
* The upper-left corner is (1,1), the lower-right corner is (p->width, p->height).
* \param drvthis Pointer to driver structure.
* \param x Horizontal character position (column).
* \param y Vertical character position (row).
* \param string String that gets written.
*/
MODULE_EXPORT void
EA65_string (Driver *drvthis, int x, int y, const char string[])
{
@@ -296,7 +326,8 @@ EA65_string (Driver *drvthis, int x, int y, const char string[])
int i;
x -= 1; // Convert 1-based coords to 0-based...
// Convert 1-based coords to 0-based...
x -= 1;
y -= 1;
for (i = 0; string[i]; i++) {
@@ -308,9 +339,11 @@ EA65_string (Driver *drvthis, int x, int y, const char string[])
}
}
/////////////////////////////////////////////////////////////////
//// Turns the recording LED on or off as desired.
////
/**
* Turns the recording LED on or off as desired.
* \param drvthis Pointer to driver structure.
* \param on 0 = LED off, 1 = LED on.
*/
MODULE_EXPORT void
EA65_output (Driver *drvthis, int on)
{
+106 -70
View File
@@ -1,5 +1,7 @@
/** \file server/drivers/glk.c
* LCDd \c glk driver for graphical displays by MatroxOrbital.
*
* \todo Adapt hBar, vBar, and icon to 0.5 API.
*/
/*
@@ -80,15 +82,18 @@ typedef struct glk_private_data {
// Vars for the server core
MODULE_EXPORT char *api_version = API_VERSION;
MODULE_EXPORT int stay_in_foreground = 1;
MODULE_EXPORT int stay_in_foreground = 0;
MODULE_EXPORT int supports_multiple = 0;
MODULE_EXPORT char *symbol_prefix = "glk_";
////////////////////////////////////////////////////////////
// init() should set up any device-specific stuff, and
// point all the function pointers.
/**
* Initialize the driver.
* \param drvthis Pointer to driver structure.
* \retval 0 Success.
* \retval <0 Error.
*/
MODULE_EXPORT int
glk_init(Driver *drvthis)
{
@@ -243,13 +248,14 @@ glk_init(Driver *drvthis)
report(RPT_DEBUG, "%s: init() done", drvthis->name);
return 1;
return 0;
}
/////////////////////////////////////////////////////////////////
// Close the driver
//
/**
* Close the driver (do necessary clean-up).
* \param drvthis Pointer to driver structure.
*/
MODULE_EXPORT void
glk_close(Driver *drvthis)
{
@@ -273,9 +279,11 @@ glk_close(Driver *drvthis)
}
/////////////////////////////////////////////////////////////////
// Returns the display width
//
/**
* Return the display width in characters.
* \param drvthis Pointer to driver structure.
* \return Number of characters the display is wide.
*/
MODULE_EXPORT int
glk_width(Driver *drvthis)
{
@@ -285,9 +293,11 @@ glk_width(Driver *drvthis)
}
/////////////////////////////////////////////////////////////////
// Returns the display height
//
/**
* Return the display height in characters.
* \param drvthis Pointer to driver structure.
* \return Number of characters the display is high.
*/
MODULE_EXPORT int
glk_height(Driver *drvthis)
{
@@ -297,9 +307,11 @@ glk_height(Driver *drvthis)
}
/////////////////////////////////////////////////////////////////
// Returns the display's cell width
//
/**
* Return the width of a character in pixels.
* \param drvthis Pointer to driver structure.
* \return Number of pixel columns a character cell is wide.
*/
MODULE_EXPORT int
glk_cellwidth(Driver *drvthis)
{
@@ -309,9 +321,11 @@ glk_cellwidth(Driver *drvthis)
}
/////////////////////////////////////////////////////////////////
// Returns the display's cell height
//
/**
* Return the height of a character in pixels.
* \param drvthis Pointer to driver structure.
* \return Number of pixel lines a character cell is high.
*/
MODULE_EXPORT int
glk_cellheight(Driver *drvthis)
{
@@ -321,11 +335,12 @@ glk_cellheight(Driver *drvthis)
}
/////////////////////////////////////////////////////////////////
// Clears the LCD screen
//
#define CLEARCOUNT (1000000)
/**
* Clears the LCD screen using a hardware command
* \param drvthis Pointer to driver structure.
*/
void glk_clear_forced(Driver *drvthis)
{
PrivateData *p = drvthis->private_data;
@@ -335,7 +350,10 @@ void glk_clear_forced(Driver *drvthis)
memset(p->backingstore, ' ', p->width * p->height);
}
/**
* Clear the screen.
* \param drvthis Pointer to driver structure.
*/
MODULE_EXPORT void
glk_clear(Driver *drvthis)
{
@@ -349,9 +367,10 @@ glk_clear(Driver *drvthis)
}
//////////////////////////////////////////////////////////////////
// Flushes all output to the lcd...
//
/**
* Flush data on screen to the LCD.
* \param drvthis Pointer to driver structure.
*/
MODULE_EXPORT void
glk_flush(Driver *drvthis)
{
@@ -393,10 +412,14 @@ glk_flush(Driver *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).
//
/**
* Prints a string on the lcd display at position (x,y).
* The upper-left corner is (1,1), the lower-right corner is (p->width, p->height).
* \param drvthis Pointer to driver structure.
* \param x Horizontal character position (column).
* \param y Vertical character position (row).
* \param string String that gets written.
*/
MODULE_EXPORT void
glk_string(Driver *drvthis, int x, int y, const char string[])
{
@@ -414,10 +437,14 @@ glk_string(Driver *drvthis, int x, int y, const 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).
//
/**
* Print a character on the lcd at position (x,y).
* The upper-left corner is (1,1), the lower-right corner is (p->width, p->height).
* \param drvthis Pointer to driver structure.
* \param x Horizontal character position (column).
* \param y Vertical character position (row).
* \param c Character that gets written.
*/
MODULE_EXPORT void
glk_chr(Driver *drvthis, int x, int y, char c)
{
@@ -455,12 +482,13 @@ glk_chr(Driver *drvthis, int x, int y, char c)
}
/////////////////////////////////////////////////////////////////
// Returns current p->contrast
// This is only the locally stored contrast, the contrast value
// cannot be retrieved from the LCD.
// Value 0 to 1000.
//
/**
* Get current LCD contrast.
* This is only the locally stored contrast, the contrast value
* cannot be retrieved from the LCD.
* \param drvthis Pointer to driver structure.
* \return Stored contrast in promille [0-1000].
*/
MODULE_EXPORT int
glk_get_contrast(Driver *drvthis)
{
@@ -470,10 +498,11 @@ glk_get_contrast(Driver *drvthis)
}
//////////////////////////////////////////////////////////////////////
// Sets the p->contrast of the display. Value is 0-255, where 140 is
// what I consider "just right".
//
/**
* Sets the contrast of the display.
* \param drvthis Pointer to driver structure.
* \param promille New contrast value in promille.
*/
MODULE_EXPORT void
glk_set_contrast(Driver *drvthis, int promille)
{
@@ -492,9 +521,11 @@ glk_set_contrast(Driver *drvthis, int promille)
}
//////////////////////////////////////////////////////////////////////
// Turns the lcd backlight on or off...
//
/**
* Turn the LCD backlight on or off.
* \param drvthis Pointer to driver structure.
* \param on New backlight status.
*/
MODULE_EXPORT void
glk_backlight(Driver *drvthis, int on)
{
@@ -511,8 +542,11 @@ glk_backlight(Driver *drvthis, int on)
}
//////////////////////////////////////////////////////////////////////
// Sets general purpose outputs on or off
/**
* Sets general purpose outputs on or off
* \param drvthis Pointer to driver structure.
* \param on Integer with bits representing GPIO states.
*/
MODULE_EXPORT void
glk_output(Driver *drvthis, int on)
{
@@ -600,9 +634,10 @@ glk_get_free_chars(Driver *drvthis)
}
//////////////////////////////////////////////////////////////////////
// Changes the font data of character n.
//
/**
* Changes the font data of character n.
* This function is a stub and currently does nothing.
*/
MODULE_EXPORT void
glk_set_char(Driver *drvthis, int n, char *dat)
{
@@ -612,9 +647,10 @@ glk_set_char(Driver *drvthis, int n, char *dat)
}
/////////////////////////////////////////////////////////////////
// Draws a vertical bar, from the bottom of the screen up.
//
/**
* Draws a vertical bar, from the bottom of the screen up.
* This function still uses 0.4 API.
*/
MODULE_EXPORT void
glk_old_vbar(Driver *drvthis, int x, int len)
{
@@ -647,9 +683,10 @@ glk_old_vbar(Driver *drvthis, int x, int len)
}
/////////////////////////////////////////////////////////////////
// Draws a horizontal bar to the right.
//
/**
* Draws a horizontal bar to the right.
* This function still uses 0.4 API.
*/
MODULE_EXPORT void
glk_old_hbar(Driver *drvthis, int x, int y, int len)
{
@@ -679,15 +716,13 @@ glk_old_hbar(Driver *drvthis, int x, int y, int len)
}
/////////////////////////////////////////////////////////////////
// Sets character 0 to an icon...
//
/**
* Sets character 0 to an icon.
* This function still uses 0.4 API.
*/
MODULE_EXPORT void
glk_old_icon(Driver *drvthis, int which, int dest)
{
/* TODO IMPLEMENTATION OF NEW API */
/* any volonteers ? */
PrivateData *p = drvthis->private_data;
unsigned char old, new;
unsigned char *pf = p->framebuf;
@@ -726,11 +761,12 @@ glk_old_icon(Driver *drvthis, int which, int dest)
}
//////////////////////////////////////////////////////////////////////
// Tries to read a character from an input device...
//
// Return NULL for "nothing available".
//
/**
* Get key from the key panel connected to the display.
* \param drvthis Pointer to driver structure.
* \return String representation of the key;
* \c NULL if nothing available / unmapped key.
*/
MODULE_EXPORT const char *
glk_get_key(Driver *drvthis)
{
+7 -5
View File
@@ -3,7 +3,7 @@
#include "lcd.h"
MODULE_EXPORT int glk_init(Driver *drvthis);
MODULE_EXPORT int glk_init(Driver *drvthis);
MODULE_EXPORT void glk_close(Driver *drvthis);
MODULE_EXPORT int glk_width(Driver *drvthis);
MODULE_EXPORT int glk_height(Driver *drvthis);
@@ -14,19 +14,21 @@ MODULE_EXPORT void glk_flush(Driver *drvthis);
MODULE_EXPORT void glk_string(Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void glk_chr(Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void glk_old_vbar(Driver *drvthis, int x, int len);
MODULE_EXPORT void glk_old_hbar(Driver *drvthis, int x, int y, int len);
MODULE_EXPORT void glk_num(Driver *drvthis, int x, int num);
MODULE_EXPORT void glk_old_icon(Driver *drvthis, int which, int dest);
MODULE_EXPORT int glk_get_free_chars(Driver *drvthis);
MODULE_EXPORT void glk_set_char(Driver *drvthis, int n, char *dat);
MODULE_EXPORT int glk_get_contrast(Driver *drvthis);
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);
MODULE_EXPORT const char *glk_get_key(Driver *drvthis);
// Functions using old 0.4 API.
MODULE_EXPORT void glk_old_vbar(Driver *drvthis, int x, int len);
MODULE_EXPORT void glk_old_hbar(Driver *drvthis, int x, int y, int len);
MODULE_EXPORT void glk_old_icon(Driver *drvthis, int which, int dest);
#endif