Doxygen-ize; sort functions to order used in most other drivers
This commit is contained in:
+368
-296
@@ -109,8 +109,14 @@ static void serialVFD_init_hbar (Driver *drvthis);
|
||||
static void serialVFD_put_char (Driver *drvthis, int n);
|
||||
static void serialVFD_hw_write (Driver *drvthis, int i);
|
||||
|
||||
// Opens com port and sets baud correctly...
|
||||
//
|
||||
|
||||
/**
|
||||
* Initialize the driver.
|
||||
* Open com port and set baud correctly...
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \retval 0 Success.
|
||||
* \retval <0 Error.
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
serialVFD_init (Driver *drvthis)
|
||||
{
|
||||
@@ -275,156 +281,103 @@ serialVFD_init (Driver *drvthis)
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieves brightness (in promille)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Close the driver (do necessary clean-up).
|
||||
* \param drvthis Pointer to driver structure.
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
serialVFD_close (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
if (p != NULL) {
|
||||
Port_Function[p->use_parallel].close_fkt(drvthis);
|
||||
if (p->framebuf)
|
||||
free(p->framebuf);
|
||||
if (p->backingstore)
|
||||
free(p->backingstore);
|
||||
free(p);
|
||||
}
|
||||
|
||||
drvthis->store_private_ptr(drvthis, NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the display width in characters.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \return Number of characters the display is wide.
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
serialVFD_get_brightness(Driver *drvthis, int state)
|
||||
serialVFD_width (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
return (state == BACKLIGHT_ON) ? p->on_brightness : p->off_brightness;
|
||||
return p->width;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Sets on/off brightness (in promille)
|
||||
/**
|
||||
* Return the display height in characters.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \return Number of characters the display is high.
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
serialVFD_height (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
return p->height;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
serialVFD_cellwidth (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
return p->cellwidth;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
serialVFD_cellheight (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
return p->cellheight;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the screen.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
serialVFD_set_brightness(Driver *drvthis, int state, int promille)
|
||||
serialVFD_clear (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
/* Check it */
|
||||
if (promille < 0 || promille > 1000)
|
||||
return;
|
||||
memset(p->framebuf, ' ', p->width * p->height);
|
||||
|
||||
/* store the software value since there is not get */
|
||||
if (state == BACKLIGHT_ON) {
|
||||
p->on_brightness = promille;
|
||||
}
|
||||
else {
|
||||
p->off_brightness = promille;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Sets the backlight on or off.
|
||||
* The hardware support any value between 0 and 100.
|
||||
/**
|
||||
* Flush data on screen to the VFD.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
serialVFD_backlight (Driver *drvthis, int on)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
int hardware_value = (on == BACKLIGHT_ON)
|
||||
? p->on_brightness
|
||||
: p->off_brightness;
|
||||
|
||||
// map range [0, 1000] -> [0, 4] that the hardware understands
|
||||
//(4 steps 0-250, 251-500, 501-750, 751-1000)
|
||||
hardware_value /= 251;
|
||||
if (hardware_value != p->hw_brightness) {
|
||||
p->hw_brightness = hardware_value;
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, &p->hw_cmd[p->hw_brightness][1],\
|
||||
p->hw_cmd[p->hw_brightness][0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a vertical bar...
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
serialVFD_vbar (Driver *drvthis, int x, int y, int len, int promille, int options)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
if (p->customchars >= p->cellheight || p->predefined_vbar == 1) {
|
||||
serialVFD_init_vbar(drvthis);
|
||||
lib_vbar_static(drvthis, x, y, len, promille, options, p->cellheight, p->vbar_cc_offset);
|
||||
}
|
||||
else {
|
||||
lib_vbar_static(drvthis, x, y, len, promille, options, 2, 0x5E);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
|
||||
MODULE_EXPORT void
|
||||
serialVFD_hbar (Driver *drvthis, int x, int y, int len, int promille, int options)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
if (p->customchars >= p->cellwidth || p->predefined_hbar == 1) {
|
||||
serialVFD_init_hbar(drvthis);
|
||||
lib_hbar_static(drvthis, x, y, len, promille, options, p->cellwidth, p->hbar_cc_offset);
|
||||
}
|
||||
else {
|
||||
lib_hbar_static(drvthis, x, y, len, promille, options, 2, 0x2C);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets a custom character from 0-7...
|
||||
//
|
||||
// For input, value 1 mean "on" and 0 is "off".
|
||||
//
|
||||
// The input is just an array of characters...
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
serialVFD_set_char (Driver *drvthis, int n, unsigned char *dat)
|
||||
{ //set char in p->custom_char
|
||||
PrivateData *p = drvthis->private_data;
|
||||
unsigned int byte, bit;
|
||||
|
||||
if (n < 0 || n > p->customchars-1)
|
||||
return;
|
||||
if (!dat)
|
||||
return;
|
||||
|
||||
for (byte = 0; byte < p->usr_chr_dot_assignment[0]; byte++) {
|
||||
int letter = 0;
|
||||
|
||||
for (bit = 0; bit < 8; bit++) {
|
||||
int pos = (int) p->usr_chr_dot_assignment[bit+8*byte+1];
|
||||
|
||||
if (pos > 0) {
|
||||
int posbyte = (pos-1) / 5;
|
||||
int posbit = 4 - ((pos-1) % 5);
|
||||
|
||||
letter |= ((dat[posbyte] >> posbit) & 1) << bit;
|
||||
}
|
||||
}
|
||||
p->custom_char[n][byte] = letter;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
serialVFD_put_char (Driver *drvthis, int n)
|
||||
{ // put userchar in display
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, &p->hw_cmd[set_user_char][1],\
|
||||
p->hw_cmd[set_user_char][0]);// substitute and select Character to overwrite
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, (unsigned char *) &p->usr_chr_load_mapping[n], 1);
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, &p->custom_char[n][0], p->usr_chr_dot_assignment[0]);// overwrite selected Character
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Blasts a single frame onscreen, to the lcd...
|
||||
//
|
||||
// Input is a character array, sized serialVFD->width*serialVFD->height
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
serialVFD_flush (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
@@ -529,39 +482,110 @@ serialVFD_flush (Driver *drvthis)
|
||||
memcpy(p->backingstore, p->framebuf, p->height * p->width);
|
||||
//report(RPT_WARNING, "%s: memcpy", drvthis->name);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
serialVFD_hw_write (Driver *drvthis, int i)
|
||||
{ // finally write character/usercharacter on the display
|
||||
|
||||
/**
|
||||
* 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
|
||||
serialVFD_string (Driver *drvthis, int x, int y, const char string[])
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
int i;
|
||||
|
||||
x--;
|
||||
y--;
|
||||
for (i = 0; string[i] != '\0'; i++) {
|
||||
// Check for buffer overflows...
|
||||
if ((y * p->width) + x + i > (p->width * p->height))
|
||||
break;
|
||||
p->framebuf[(y * p->width) + x + i] = string[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print a character 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 c Character that gets written.
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
serialVFD_chr (Driver *drvthis, int x, int y, char c)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
if (p->framebuf[i] <= 30) { // custom character
|
||||
if (p->display_type == 1) { // KD Rev 2.1 only
|
||||
if (p->last_custom != p->framebuf[i]) {
|
||||
// substitute and select character to overwrite (237)
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, (unsigned char *)"\x1A\xDB", 2);
|
||||
// overwrite selected character
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, &p->custom_char[(int)p->framebuf[i]][0], 7);
|
||||
}
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, (unsigned char *)"\xDB", 1); // write character
|
||||
p->last_custom = p->framebuf[i];
|
||||
}
|
||||
else { // all other displays
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, (unsigned char *) &p->usr_chr_mapping[(int)p->framebuf[i]], 1);
|
||||
}
|
||||
}
|
||||
else if ((p->framebuf[i] == 127) || ((p->framebuf[i] > 127) && (p->ISO_8859_1 != 0))) { // ISO_8859_1 translation for 129 ... 255
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, &p->charmap[p->framebuf[i] - 127], 1);
|
||||
if ((x > p->width) || (y > p->height))
|
||||
return;
|
||||
y--;
|
||||
x--;
|
||||
|
||||
p->framebuf[(y * p->width) + x ] = c;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw a vertical bar bottom-up.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \param x Horizontal character position (column) of the starting point.
|
||||
* \param y Vertical character position (row) of the starting point.
|
||||
* \param len Number of characters that the bar is high at 100%
|
||||
* \param promille Current height level of the bar in promille.
|
||||
* \param options Options (currently unused).
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
serialVFD_vbar (Driver *drvthis, int x, int y, int len, int promille, int options)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
if (p->customchars >= p->cellheight || p->predefined_vbar == 1) {
|
||||
serialVFD_init_vbar(drvthis);
|
||||
lib_vbar_static(drvthis, x, y, len, promille, options, p->cellheight, p->vbar_cc_offset);
|
||||
}
|
||||
else {
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, &p->framebuf[i], 1);
|
||||
lib_vbar_static(drvthis, x, y, len, promille, options, 2, 0x5E);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw a horizontal bar to the right.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \param x Horizontal character position (column) of the starting point.
|
||||
* \param y Vertical character position (row) of the starting point.
|
||||
* \param len Number of characters that the bar is long at 100%
|
||||
* \param promille Current length level of the bar in promille.
|
||||
* \param options Options (currently unused).
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
serialVFD_hbar (Driver *drvthis, int x, int y, int len, int promille, int options)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
if (p->customchars >= p->cellwidth || p->predefined_hbar == 1) {
|
||||
serialVFD_init_hbar(drvthis);
|
||||
lib_hbar_static(drvthis, x, y, len, promille, options, p->cellwidth, p->hbar_cc_offset);
|
||||
}
|
||||
else {
|
||||
lib_hbar_static(drvthis, x, y, len, promille, options, 2, 0x2C);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write a big number to the screen.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \param x Horizontal character position (column).
|
||||
* \param num Character to write (0 - 10 with 10 representing ':')
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
serialVFD_num(Driver * drvthis, int x, int num)
|
||||
{
|
||||
@@ -577,10 +601,14 @@ serialVFD_num(Driver * drvthis, int x, int num)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Places an icon on screen
|
||||
/**
|
||||
* Place an icon on the screen.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \param x Horizontal character position (column).
|
||||
* \param y Vertical character position (row).
|
||||
* \param icon synbolic value representing the icon.
|
||||
* \retval 0 Icon has been successfully defined/written.
|
||||
* \retval <0 Server core shall define/write the icon.
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
serialVFD_icon (Driver *drvthis, int x, int y, int icon)
|
||||
@@ -635,10 +663,148 @@ serialVFD_icon (Driver *drvthis, int x, int y, int icon)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get total number of custom characters available.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \return Number of custom characters.
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
serialVFD_get_free_chars (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets up for vertical bars. Call before serialVFD->vbar()
|
||||
//
|
||||
return p->customchars;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Define a custom character and write it to the VFD.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \param n Custom character to define [0 - (p->customchars)].
|
||||
* \param dat Array of 7(=cellheight) bytes, each representing a pixel row
|
||||
* starting from the top to bottom.
|
||||
* The bits in each byte represent the pixels where the LSB
|
||||
* (least significant bit) is the rightmost pixel in each pixel row.
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
serialVFD_set_char (Driver *drvthis, int n, unsigned char *dat)
|
||||
{ //set char in p->custom_char
|
||||
PrivateData *p = drvthis->private_data;
|
||||
unsigned int byte, bit;
|
||||
|
||||
if (n < 0 || n > p->customchars-1)
|
||||
return;
|
||||
if (!dat)
|
||||
return;
|
||||
|
||||
for (byte = 0; byte < p->usr_chr_dot_assignment[0]; byte++) {
|
||||
int letter = 0;
|
||||
|
||||
for (bit = 0; bit < 8; bit++) {
|
||||
int pos = (int) p->usr_chr_dot_assignment[bit+8*byte+1];
|
||||
|
||||
if (pos > 0) {
|
||||
int posbyte = (pos-1) / 5;
|
||||
int posbit = 4 - ((pos-1) % 5);
|
||||
|
||||
letter |= ((dat[posbyte] >> posbit) & 1) << bit;
|
||||
}
|
||||
}
|
||||
p->custom_char[n][byte] = letter;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve brightness.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \param state Brightness state (on/off) for which we want the value.
|
||||
* \return Stored brightness in promille.
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
serialVFD_get_brightness(Driver *drvthis, int state)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
return (state == BACKLIGHT_ON) ? p->on_brightness : p->off_brightness;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set on/off brightness.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \param state Brightness state (on/off) for which we want to store the value.
|
||||
* \param promille New brightness in promille.
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
serialVFD_set_brightness(Driver *drvthis, int state, int promille)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
/* Check it */
|
||||
if (promille < 0 || promille > 1000)
|
||||
return;
|
||||
|
||||
/* store the software value since there is not get */
|
||||
if (state == BACKLIGHT_ON) {
|
||||
p->on_brightness = promille;
|
||||
}
|
||||
else {
|
||||
p->off_brightness = promille;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Turn display backlight on or off.
|
||||
* This does not really toggle the backlight, but tries to handle it more intelligently:
|
||||
* it sets the brightness to the value defined for the related backlight state.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \param on New backlight status.
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
serialVFD_backlight (Driver *drvthis, int on)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
int hardware_value = (on == BACKLIGHT_ON)
|
||||
? p->on_brightness
|
||||
: p->off_brightness;
|
||||
|
||||
// map range [0, 1000] -> [0, 4] that the hardware understands
|
||||
//(4 steps 0-250, 251-500, 501-750, 751-1000)
|
||||
hardware_value /= 251;
|
||||
if (hardware_value != p->hw_brightness) {
|
||||
p->hw_brightness = hardware_value;
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, &p->hw_cmd[p->hw_brightness][1],\
|
||||
p->hw_cmd[p->hw_brightness][0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provide general information about the LCD/VFD display/driver.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \return Constant string with information.
|
||||
*/
|
||||
MODULE_EXPORT const char *
|
||||
serialVFD_get_info (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
strcpy(p->info, "Driver for many serialVFDs from NEC(all FIPC based), Noritake, Futaba and the \"KD Rev2.1\"VFD");
|
||||
return p->info;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set up vertical bars.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
*
|
||||
* \note
|
||||
* Called only by vbar(). Can possibly be included there.
|
||||
* This should also make CCMODE independent of the implementation of the bars.
|
||||
*/
|
||||
static void
|
||||
serialVFD_init_vbar (Driver *drvthis)
|
||||
{
|
||||
@@ -660,9 +826,15 @@ serialVFD_init_vbar (Driver *drvthis)
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Inits horizontal bars...
|
||||
//
|
||||
|
||||
/**
|
||||
* Set up horizontal bars.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
*
|
||||
* \note
|
||||
* Called only by hbar(). Can possibly be included there.
|
||||
* This should also make CCMODE independent of the implementation of the bars.
|
||||
*/
|
||||
static void
|
||||
serialVFD_init_hbar (Driver *drvthis)
|
||||
{
|
||||
@@ -683,143 +855,43 @@ serialVFD_init_hbar (Driver *drvthis)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clears the LCD screen
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
serialVFD_clear (Driver *drvthis)
|
||||
{
|
||||
static void
|
||||
serialVFD_put_char (Driver *drvthis, int n)
|
||||
{ // put userchar in display
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
memset(p->framebuf, ' ', p->width * p->height);
|
||||
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, &p->hw_cmd[set_user_char][1],\
|
||||
p->hw_cmd[set_user_char][0]);// substitute and select Character to overwrite
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, (unsigned char *) &p->usr_chr_load_mapping[n], 1);
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, &p->custom_char[n][0], p->usr_chr_dot_assignment[0]);// overwrite selected Character
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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).
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
serialVFD_string (Driver *drvthis, int x, int y, const char string[])
|
||||
{
|
||||
static void
|
||||
serialVFD_hw_write (Driver *drvthis, int i)
|
||||
{ // finally write character/usercharacter on the display
|
||||
PrivateData *p = drvthis->private_data;
|
||||
int i;
|
||||
|
||||
x--;
|
||||
y--;
|
||||
for (i = 0; string[i] != '\0'; i++) {
|
||||
// Check for buffer overflows...
|
||||
if ((y * p->width) + x + i > (p->width * p->height))
|
||||
break;
|
||||
p->framebuf[(y * p->width) + x + i] = string[i];
|
||||
if (p->framebuf[i] <= 30) { // custom character
|
||||
if (p->display_type == 1) { // KD Rev 2.1 only
|
||||
if (p->last_custom != p->framebuf[i]) {
|
||||
// substitute and select character to overwrite (237)
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, (unsigned char *)"\x1A\xDB", 2);
|
||||
// overwrite selected character
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, &p->custom_char[(int)p->framebuf[i]][0], 7);
|
||||
}
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, (unsigned char *)"\xDB", 1); // write character
|
||||
p->last_custom = p->framebuf[i];
|
||||
}
|
||||
else { // all other displays
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, (unsigned char *) &p->usr_chr_mapping[(int)p->framebuf[i]], 1);
|
||||
}
|
||||
}
|
||||
else if ((p->framebuf[i] == 127) || ((p->framebuf[i] > 127) && (p->ISO_8859_1 != 0))) { // ISO_8859_1 translation for 129 ... 255
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, &p->charmap[p->framebuf[i] - 127], 1);
|
||||
}
|
||||
else {
|
||||
Port_Function[p->use_parallel].write_fkt(drvthis, &p->framebuf[i], 1);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clean-up
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
serialVFD_close (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
if (p != NULL) {
|
||||
Port_Function[p->use_parallel].close_fkt(drvthis);
|
||||
if (p->framebuf)
|
||||
free(p->framebuf);
|
||||
if (p->backingstore)
|
||||
free(p->backingstore);
|
||||
free(p);
|
||||
}
|
||||
|
||||
drvthis->store_private_ptr(drvthis, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the display width in characters
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
serialVFD_width (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
return p->width;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns the display height in characters
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
serialVFD_height (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
return p->height;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Returns the maximum number of custom char slots (not how many
|
||||
// are free at a moment, maybe this isn't even needed...
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
serialVFD_get_free_chars (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
return p->customchars;
|
||||
}
|
||||
/*
|
||||
* Returns the width of a character in pixels
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
serialVFD_cellwidth (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
return p->cellwidth;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns the height of a character in pixels
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
serialVFD_cellheight (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
return p->cellheight;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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).
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
serialVFD_chr (Driver *drvthis, int x, int y, char c)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
if ((x > p->width) || (y > p->height))
|
||||
return;
|
||||
y--;
|
||||
x--;
|
||||
|
||||
p->framebuf[(y * p->width) + x ] = c;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// provides some info about this driver
|
||||
//
|
||||
MODULE_EXPORT const char *
|
||||
serialVFD_get_info (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
strcpy(p->info, "Driver for many serialVFDs from NEC(all FIPC based), Noritake, Futaba and the \"KD Rev2.1\"VFD");
|
||||
return p->info;
|
||||
}
|
||||
|
||||
@@ -60,16 +60,16 @@ MODULE_EXPORT void serialVFD_chr (Driver *drvthis, int x, int y, char c);
|
||||
|
||||
MODULE_EXPORT void serialVFD_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
|
||||
MODULE_EXPORT void serialVFD_hbar (Driver *drvthis, int x, int y, int len, int promille, int options);
|
||||
MODULE_EXPORT void serialVFD_num (Driver *drvthis, int x, int num);
|
||||
MODULE_EXPORT int serialVFD_icon(Driver *drvthis, int x, int y, int icon);
|
||||
|
||||
MODULE_EXPORT void serialVFD_set_char (Driver *drvthis, int n, unsigned char *dat);
|
||||
MODULE_EXPORT int serialVFD_get_free_chars (Driver *drvthis);
|
||||
|
||||
MODULE_EXPORT int serialVFD_get_brightness (Driver *drvthis, int state);
|
||||
MODULE_EXPORT void serialVFD_set_brightness (Driver *drvthis, int state, int promille);
|
||||
MODULE_EXPORT void serialVFD_backlight (Driver *drvthis, int on);
|
||||
MODULE_EXPORT void serialVFD_output (Driver *drvthis, int state);
|
||||
MODULE_EXPORT void serialVFD_num (Driver *drvthis, int x, int num);
|
||||
MODULE_EXPORT int serialVFD_get_free_chars (Driver *drvthis);
|
||||
|
||||
MODULE_EXPORT const char * serialVFD_get_info( Driver *drvthis );
|
||||
|
||||
/** private data for the \c serialVFD driver */
|
||||
|
||||
+133
-44
@@ -40,7 +40,7 @@
|
||||
#include "report.h"
|
||||
|
||||
|
||||
// Variables in the driver module
|
||||
// Variables for the server core
|
||||
MODULE_EXPORT char *api_version = API_VERSION;
|
||||
MODULE_EXPORT int stay_in_foreground = 0;
|
||||
MODULE_EXPORT int supports_multiple = 0;
|
||||
@@ -49,13 +49,13 @@ MODULE_EXPORT char *symbol_prefix = "shuttleVFD_";
|
||||
|
||||
/** private data for the \c shuttleVFD driver */
|
||||
typedef struct shuttleVFD_private_data {
|
||||
usb_dev_handle *dev;
|
||||
int width;
|
||||
int height;
|
||||
int cellwidth;
|
||||
int cellheight;
|
||||
char *framebuf;
|
||||
char *last_framebuf;
|
||||
usb_dev_handle *dev; /**< device handle */
|
||||
int width; /**< display width in characters */
|
||||
int height; /**< display height in characters */
|
||||
int cellwidth; /**< character cell width */
|
||||
int cellheight; /**< character cell hight */
|
||||
char *framebuf; /**< frame buffer */
|
||||
char *last_framebuf; /**< old contents of frame buffer */
|
||||
unsigned long icons;
|
||||
unsigned long last_icons;
|
||||
} PrivateData;
|
||||
@@ -65,10 +65,11 @@ typedef struct shuttleVFD_private_data {
|
||||
//////////////////// For ShuttleVFD Output ///////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void send_packet(Driver *drvthis, char* packet) {
|
||||
static void send_packet(Driver *drvthis, char* packet)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SHUTTLE_VFD_WRITE_ATTEMPTS; ++i) {
|
||||
if (usb_control_msg(p->dev,
|
||||
0x21,
|
||||
@@ -87,7 +88,14 @@ void send_packet(Driver *drvthis, char* packet) {
|
||||
}
|
||||
|
||||
|
||||
MODULE_EXPORT int shuttleVFD_init(Driver *drvthis) {
|
||||
/**
|
||||
* Initialize the driver.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \retval 0 Success.
|
||||
* \retval <0 Error.
|
||||
*/
|
||||
MODULE_EXPORT int shuttleVFD_init(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p;
|
||||
|
||||
// allocate and store private data
|
||||
@@ -131,7 +139,8 @@ MODULE_EXPORT int shuttleVFD_init(Driver *drvthis) {
|
||||
struct usb_device *dev;
|
||||
for (dev = bus->devices; dev != NULL; dev = dev->next) {
|
||||
if (dev->descriptor.idVendor == SHUTTLE_VFD_VENDOR_ID &&
|
||||
(dev->descriptor.idProduct == SHUTTLE_VFD_PRODUCT_ID1 || dev->descriptor.idProduct == SHUTTLE_VFD_PRODUCT_ID2)) {
|
||||
(dev->descriptor.idProduct == SHUTTLE_VFD_PRODUCT_ID1 ||
|
||||
dev->descriptor.idProduct == SHUTTLE_VFD_PRODUCT_ID2)) {
|
||||
p->dev = usb_open(dev);
|
||||
}
|
||||
}
|
||||
@@ -153,8 +162,14 @@ MODULE_EXPORT int shuttleVFD_init(Driver *drvthis) {
|
||||
}
|
||||
|
||||
|
||||
MODULE_EXPORT void shuttleVFD_close(Driver *drvthis) {
|
||||
/**
|
||||
* Close the driver (do necessary clean-up).
|
||||
* \param drvthis Pointer to driver structure.
|
||||
*/
|
||||
MODULE_EXPORT void shuttleVFD_close(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
if (p != NULL) {
|
||||
if (p->dev != NULL) {
|
||||
if (usb_release_interface(p->dev, SHUTTLE_VFD_INTERFACE_NUM) < 0) {
|
||||
@@ -177,52 +192,103 @@ MODULE_EXPORT void shuttleVFD_close(Driver *drvthis) {
|
||||
}
|
||||
|
||||
|
||||
MODULE_EXPORT int shuttleVFD_width(Driver *drvthis) {
|
||||
/**
|
||||
* Return the display width in characters.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \return Number of characters the display is wide.
|
||||
*/
|
||||
MODULE_EXPORT int shuttleVFD_width(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
return p->width;
|
||||
}
|
||||
|
||||
|
||||
MODULE_EXPORT int shuttleVFD_height(Driver *drvthis) {
|
||||
/**
|
||||
* Return the display height in characters.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \return Number of characters the display is high.
|
||||
*/
|
||||
MODULE_EXPORT int shuttleVFD_height(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
return p->height;
|
||||
}
|
||||
|
||||
|
||||
MODULE_EXPORT void shuttleVFD_clear(Driver *drvthis) {
|
||||
/**
|
||||
* 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 shuttleVFD_cellwidth(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
return p->cellwidth;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 shuttleVFD_cellheight(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
return p->cellheight;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the screen.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
*/
|
||||
MODULE_EXPORT void shuttleVFD_clear(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
memset(p->framebuf, ' ', p->width * p->height);
|
||||
p->icons = 0;
|
||||
}
|
||||
|
||||
|
||||
MODULE_EXPORT void shuttleVFD_flush(Driver *drvthis) {
|
||||
/**
|
||||
* Flush data on screen to the VFD.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
*/
|
||||
MODULE_EXPORT void shuttleVFD_flush(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
char packet[SHUTTLE_VFD_PACKET_SIZE];
|
||||
|
||||
// set text
|
||||
if (strncmp(p->last_framebuf, p->framebuf, p->width * p->height) != 0) {
|
||||
// move cursor to front
|
||||
memset(packet, 0, SHUTTLE_VFD_PACKET_SIZE);
|
||||
packet[0] = (1 << 4) + 1;
|
||||
packet[1] = 2;
|
||||
memset(packet, '\0', SHUTTLE_VFD_PACKET_SIZE);
|
||||
packet[0] = 0x11;
|
||||
packet[1] = 0x02;
|
||||
send_packet(drvthis, packet);
|
||||
|
||||
// write framebuf[0-6]
|
||||
memset(packet, 0, SHUTTLE_VFD_PACKET_SIZE);
|
||||
packet[0] = (9 << 4) + 7;
|
||||
memset(packet, '\0', SHUTTLE_VFD_PACKET_SIZE);
|
||||
packet[0] = 0x97;
|
||||
strncpy(&packet[1], &p->framebuf[0], 7);
|
||||
send_packet(drvthis, packet);
|
||||
|
||||
// write framebuf[7-13]
|
||||
memset(packet, 0, SHUTTLE_VFD_PACKET_SIZE);
|
||||
packet[0] = (9 << 4) + 7;
|
||||
memset(packet, '\0', SHUTTLE_VFD_PACKET_SIZE);
|
||||
packet[0] = 0x97;
|
||||
strncpy(&packet[1], &p->framebuf[7], 7);
|
||||
send_packet(drvthis, packet);
|
||||
|
||||
// write framebuf[14-20]
|
||||
memset(packet, 0, SHUTTLE_VFD_PACKET_SIZE);
|
||||
packet[0] = (9 << 4) + 6;
|
||||
memset(packet, '\0', SHUTTLE_VFD_PACKET_SIZE);
|
||||
packet[0] = 0x96;
|
||||
strncpy(&packet[1], &p->framebuf[14], 6);
|
||||
send_packet(drvthis, packet);
|
||||
|
||||
@@ -232,7 +298,7 @@ MODULE_EXPORT void shuttleVFD_flush(Driver *drvthis) {
|
||||
// set icons
|
||||
if (p->last_icons != p->icons) {
|
||||
memset(packet, 0, SHUTTLE_VFD_PACKET_SIZE);
|
||||
packet[0] = (7 << 4) + 4;
|
||||
packet[0] = 0x74;
|
||||
packet[1] = (p->icons >> 15) & 0x1f;
|
||||
packet[2] = (p->icons >> 10) & 0x1f;
|
||||
packet[3] = (p->icons >> 5) & 0x1f;
|
||||
@@ -243,15 +309,24 @@ MODULE_EXPORT void shuttleVFD_flush(Driver *drvthis) {
|
||||
}
|
||||
}
|
||||
|
||||
MODULE_EXPORT void shuttleVFD_string(
|
||||
Driver *drvthis, int x, int y, const char string[]) {
|
||||
|
||||
/**
|
||||
* 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 shuttleVFD_string(Driver *drvthis, int x, int y, const char string[])
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
int i;
|
||||
|
||||
--x; --y;
|
||||
if (y < 0 || y >= p->height)
|
||||
return;
|
||||
|
||||
int i;
|
||||
for (i = 0; (string[i] != '\0') && (x < p->width); ++i, ++x) {
|
||||
if (x >= 0) { // no write left of left border
|
||||
p->framebuf[(y * p->width) + x] = string[i];
|
||||
@@ -260,7 +335,16 @@ MODULE_EXPORT void shuttleVFD_string(
|
||||
}
|
||||
|
||||
|
||||
MODULE_EXPORT void shuttleVFD_chr(Driver *drvthis, int x, int y, char c) {
|
||||
/**
|
||||
* Print a character 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 c Character that gets written.
|
||||
*/
|
||||
MODULE_EXPORT void shuttleVFD_chr(Driver *drvthis, int x, int y, char c)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
--x; --y;
|
||||
@@ -270,7 +354,24 @@ MODULE_EXPORT void shuttleVFD_chr(Driver *drvthis, int x, int y, char c) {
|
||||
}
|
||||
|
||||
|
||||
MODULE_EXPORT int shuttleVFD_icon(Driver *drvthis, int x, int y, int icon) {
|
||||
/**
|
||||
* Place an icon on the screen.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \param x Horizontal character position (column).
|
||||
* \param y Vertical character position (row).
|
||||
* \param icon synbolic value representing the icon.
|
||||
* \retval 0 Icon has been successfully defined/written.
|
||||
* \retval <0 Server core shall define/write the icon.
|
||||
*
|
||||
* \note
|
||||
* For some icons, the special, pre-defined icon symbols on
|
||||
* Shuttle VFDs are used. This is not the intended use of icons.
|
||||
*
|
||||
* \todo
|
||||
* Use output() method for these special "out-of-band" symbols.
|
||||
*/
|
||||
MODULE_EXPORT int shuttleVFD_icon(Driver *drvthis, int x, int y, int icon)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
switch (icon) {
|
||||
@@ -299,15 +400,3 @@ MODULE_EXPORT int shuttleVFD_icon(Driver *drvthis, int x, int y, int icon) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MODULE_EXPORT int shuttleVFD_cellwidth(Driver *drvthis) {
|
||||
PrivateData *p = drvthis->private_data;
|
||||
return p->cellwidth;
|
||||
}
|
||||
|
||||
|
||||
MODULE_EXPORT int shuttleVFD_cellheight(Driver *drvthis) {
|
||||
PrivateData *p = drvthis->private_data;
|
||||
return p->cellheight;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user