diff --git a/server/drivers/g15-num.c b/server/drivers/g15-num.c new file mode 100644 index 0000000..3b91576 --- /dev/null +++ b/server/drivers/g15-num.c @@ -0,0 +1,505 @@ +#define G15_BIGNUM_LEN 1032 + +/* + * This data should really be inverted so that 1=black + * but, for now, make sure to set canvas->mode_reverse + * before drawing one of these overlays. + */ + +short g15_bignum_data[11][G15_BIGNUM_LEN] = { + { /* 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,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,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,0,0,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1, + 1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1, + 1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1, + 1,1,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1, + 1,1,1,1,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1, + 1,1,1,1,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1, + 1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1, + 1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1, + 1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,1, + 1,1,1,0,0,0,1,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 1,0,0,0,0,0,0,0,0, + 1,1,0,0,0,0,0,0,1, + 1,1,1,0,0,0,0,1,1, + 1,1,1,1,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,1,1,1,1,1 + } +}; diff --git a/server/drivers/g15.c b/server/drivers/g15.c new file mode 100644 index 0000000..1a8926f --- /dev/null +++ b/server/drivers/g15.c @@ -0,0 +1,459 @@ +/* This is the LCDproc driver for the LCD on the Logitech G15 keyboard + + Copyright (C) 2006 Anthony J. Mirabella. + + 2006-07-23 Version 1.0: Most functions should be implemented and working + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + + + ============================================================================== +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "lcd.h" +#include "g15.h" + +#include "report.h" +#include "lcd_lib.h" + +/* Vars for the server core */ +MODULE_EXPORT char *api_version = API_VERSION; +MODULE_EXPORT int stay_in_foreground = 0; +MODULE_EXPORT int supports_multiple = 0; +MODULE_EXPORT char *symbol_prefix = "g15_"; + +// Find the proper usb device and initialize it +// +MODULE_EXPORT int g15_init (Driver *drvthis) +{ + PrivateData *p; + + /* Allocate and store private data */ + p = (PrivateData *) calloc(1, sizeof(PrivateData)); + if (p == NULL) + return -1; + if (drvthis->store_private_ptr(drvthis, p)) + return -1; + + /* Initialize the PrivateData structure */ + p->width = G15_CHAR_WIDTH; + p->height = G15_CHAR_HEIGHT; + p->cellwidth = G15_CELL_WIDTH; + p->cellheight = G15_CELL_HEIGHT; + p->backlight_state = BACKLIGHT_ON; + p->g15screen_fd = 0; + + if((p->g15screen_fd = new_g15_screen(G15_G15RBUF)) < 0) + { + report(RPT_ERR, "%s: Sorry, cant connect to the G15daemon", drvthis->name); + return -1; + } + + /* make sure the canvas is there... */ + p->canvas = (g15canvas *) malloc(sizeof(g15canvas)); + if (p->canvas == NULL) { + report(RPT_ERR, "%s: unable to create canvas", drvthis->name); + return -1; + } + + /* make sure the backingstore is there... */ + p->backingstore = (g15canvas *) malloc(sizeof(g15canvas)); + if (p->backingstore == NULL) { + report(RPT_ERR, "%s: unable to create framebuffer backing store", drvthis->name); + return -1; + } + + g15r_initCanvas(p->canvas); + g15r_initCanvas(p->backingstore); + p->canvas->buffer[0] = G15_LCD_WRITE_CMD; + p->backingstore->buffer[0] = G15_LCD_WRITE_CMD; + +// ret = setLCDBrightness(G15_BRIGHTNESS_BRIGHT); + + return 0; +} + +// Close the connection to the LCD +// +MODULE_EXPORT void g15_close (Driver *drvthis) +{ + PrivateData *p = drvthis->private_data; + + g15_close_screen(p->g15screen_fd); + + if (p != NULL) { + if (p->canvas) + free(p->canvas); + + if (p->backingstore) + free(p->backingstore); + + free(p); + } + drvthis->store_private_ptr(drvthis, NULL); +} + +// Returns the display width in characters +// +MODULE_EXPORT int g15_width (Driver *drvthis) +{ + PrivateData *p = drvthis->private_data; + + return p->width; +} + +// Returns the display height in characters +// +MODULE_EXPORT int g15_height (Driver *drvthis) +{ + PrivateData *p = drvthis->private_data; + + return p->height; +} + +// Returns the width of a character in pixels +// +MODULE_EXPORT int g15_cellwidth (Driver *drvthis) +{ + PrivateData *p = drvthis->private_data; + + return p->cellwidth; +} + +// Returns the height of a character in pixels +// +MODULE_EXPORT int g15_cellheight (Driver *drvthis) +{ + PrivateData *p = drvthis->private_data; + + return p->cellheight; +} + +// Clears the LCD screen +// +MODULE_EXPORT void g15_clear (Driver *drvthis) +{ + PrivateData *p = drvthis->private_data; + + g15r_clearScreen(p->canvas, 0); + g15r_clearScreen(p->backingstore, 0); +} + +// Blasts a single frame onscreen, to the lcd... +// +MODULE_EXPORT void g15_flush (Driver *drvthis) +{ + PrivateData *p = drvthis->private_data; + + if (memcmp(p->backingstore->buffer, p->canvas->buffer, G15_BUFFER_LEN * sizeof(unsigned char)) == 0) + return; + + memcpy(p->backingstore->buffer, p->canvas->buffer, G15_BUFFER_LEN * sizeof(unsigned char)); + + g15_send(p->g15screen_fd,(char*)p->canvas->buffer,1048); +} + +// Character function for the lcdproc driver API +// +MODULE_EXPORT void g15_chr (Driver *drvthis, int x, int y, char c) +{ + PrivateData *p = drvthis->private_data; + + y--; + x--; + if ((x > p->width) || (y > p->height)) + return; + + g15r_renderCharacterLarge(p->canvas, x, y, c, 0, 0); +} + +// Prints a string on the lcd display, at position (x,y). The +// upper-left is (1,1), and the lower right should be (20,5). +// +MODULE_EXPORT void g15_string (Driver *drvthis, int x, int y, 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; + g15r_renderCharacterLarge(p->canvas, x + i, y, string[i], 0, 0); + } +} + +// Draws an icon on the screen +MODULE_EXPORT int g15_icon (Driver *drvthis, int x, int y, int icon) +{ + PrivateData *p = drvthis->private_data; + + x--; + y--; + + switch (icon) { + case ICON_BLOCK_FILLED: + { + int px1 = x * p->cellwidth; + int py1 = y * p->cellheight; + int px2 = px1 + (p->cellwidth - 2); + int py2 = py1 + (p->cellheight - 2); + g15r_pixelBox(p->canvas, px1, py1, px2, py2, G15_COLOR_BLACK, 1, G15_PIXEL_FILL); + break; + } + case ICON_HEART_FILLED: + { + g15r_renderCharacterLarge(p->canvas, x, y, G15_ICON_HEART_FILLED, 0, 0); + break; + } + case ICON_HEART_OPEN: + { + p->canvas->mode_reverse = 1; + g15r_renderCharacterLarge(p->canvas, x, y, G15_ICON_HEART_OPEN, 0, 0); + p->canvas->mode_reverse = 0; + break; + } + case ICON_ARROW_UP: + { + g15r_renderCharacterLarge(p->canvas, x , y, G15_ICON_ARROW_UP, 0, 0); + break; + } + case ICON_ARROW_DOWN: + { + g15r_renderCharacterLarge(p->canvas, x, y, G15_ICON_ARROW_DOWN, 0, 0); + break; + } + case ICON_ARROW_LEFT: + { + g15r_renderCharacterLarge(p->canvas, x, y, G15_ICON_ARROW_LEFT, 0, 0); + break; + } + case ICON_ARROW_RIGHT: + { + g15r_renderCharacterLarge(p->canvas, x, y, G15_ICON_ARROW_RIGHT, 0, 0); + break; + } + case ICON_CHECKBOX_OFF: + { + g15r_renderCharacterLarge(p->canvas, x, y, G15_ICON_CHECKBOX_OFF, 0, 0); + break; + } + case ICON_CHECKBOX_ON: + { + g15r_renderCharacterLarge(p->canvas, x, y, G15_ICON_CHECKBOX_ON, 0, 0); + break; + } + case ICON_CHECKBOX_GRAY: + { + g15r_renderCharacterLarge(p->canvas, x, y, G15_ICON_CHECKBOX_GRAY, 0, 0); + break; + } + case ICON_STOP: + { + g15r_renderCharacterLarge(p->canvas, x, y, G15_ICON_STOP, 0, 0); + break; + } + case ICON_PAUSE: + { + g15r_renderCharacterLarge(p->canvas, x, y, G15_ICON_PAUSE, 0, 0); + break; + } + case ICON_PLAY: + { + g15r_renderCharacterLarge(p->canvas, x, y, G15_ICON_PLAY, 0, 0); + break; + } + case ICON_PLAYR: + { + g15r_renderCharacterLarge(p->canvas, x, y, G15_ICON_PLAYR, 0, 0); + break; + } + case ICON_FF: + { + g15r_renderCharacterLarge(p->canvas, x, y, G15_ICON_FF, 0, 0); + break; + } + case ICON_FR: + { + g15r_renderCharacterLarge(p->canvas, x, y, G15_ICON_FR, 0, 0); + break; + } + case ICON_NEXT: + { + g15r_renderCharacterLarge(p->canvas, x, y, G15_ICON_NEXT, 0, 0); + break; + } + case ICON_PREV: + { + g15r_renderCharacterLarge(p->canvas, x, y, G15_ICON_PREV, 0, 0); + break; + } + case ICON_REC: + { + g15r_renderCharacterLarge(p->canvas, x, y, G15_ICON_REC, 0, 0); + break; + } + default: + return -1; /* Let the core do other icons */ + } + + return 0; +} + +// Draws a horizontal bar growing to the right +// +MODULE_EXPORT void g15_hbar(Driver *drvthis, int x, int y, int len, int promille, int options) +{ + PrivateData *p = drvthis->private_data; + + x--; + y--; + + int total_pixels = ((long) 2 * len * p->cellwidth + 1) * promille / 2000; + int px1 = x * p->cellwidth; + int py1 = y * p->cellheight; + int px2 = px1 + total_pixels; + int py2 = py1 + (p->cellheight - 2); + + g15r_pixelBox(p->canvas, px1, py1, px2, py2, G15_COLOR_BLACK, 1, G15_PIXEL_FILL); +} + +// Draws a vertical bar growing up +// +MODULE_EXPORT void g15_vbar(Driver *drvthis, int x, int y, int len, int promille, int options) +{ + PrivateData *p = drvthis->private_data; + + x--; + + int total_pixels = ((long) 2 * len * p->cellwidth + 1) * promille / 2000; + int px1 = x * p->cellwidth; + int py1 = y * p->cellheight - total_pixels; + int px2 = px1 + (p->cellwidth - 2); + int py2 = py1 + total_pixels; + + g15r_pixelBox(p->canvas, px1, py1, px2, py2, G15_COLOR_BLACK, 1, G15_PIXEL_FILL); + +} + +// Return one char from the Keyboard +// +MODULE_EXPORT const char * g15_get_key (Driver *drvthis) +{ + PrivateData *p = drvthis->private_data; + + unsigned int key_state = 0; + + if(send(p->g15screen_fd, "k", 1, MSG_OOB)<1) /* request key status */ + report(RPT_INFO, "%s: Error in send to g15daemon", drvthis->name); + + recv(p->g15screen_fd, &key_state , sizeof(key_state),0); + + if (key_state & G15_KEY_G1) + return "Escape"; + else if (key_state & G15_KEY_L1) + return "Enter"; + else if (key_state & G15_KEY_L2) + return "Left"; + else if (key_state & G15_KEY_L3) + return "Up"; + else if (key_state & G15_KEY_L4) + return "Down"; + else if (key_state & G15_KEY_L5) + return "Right"; + else + return NULL; +} + +// Set the backlight +// +MODULE_EXPORT void g15_backlight(Driver *drvthis, int on) +{ + PrivateData *p = drvthis->private_data; + + if (p->backlight_state == on) + return; + + p->backlight_state = on; + + char msgbuf[256]; + + switch (on) { + case BACKLIGHT_ON: + { + msgbuf[0]=G15_BRIGHTNESS_BRIGHT|G15DAEMON_BACKLIGHT; + send(p->g15screen_fd,msgbuf,1,MSG_OOB); + break; + } + case BACKLIGHT_OFF: + { + msgbuf[0]=G15_BRIGHTNESS_DARK|G15DAEMON_BACKLIGHT; + send(p->g15screen_fd,msgbuf,1,MSG_OOB); + break; + } + default: + { + break; + } + } +} + +MODULE_EXPORT void g15_num(Driver * drvthis, int x, int num) +{ + PrivateData *p = drvthis->private_data; + + x--; + int ox = x * p->cellwidth; + + if ((num < 0) || (num > 10)) + return; + + int width = 0; + int height = 43; + + if ((num >= 0) && (num <=9)) + width = 24; + else + width = 9; + + int i=0; + + for (i=0;i<(width*height);++i) + { + int color = (g15_bignum_data[num][i] ? G15_COLOR_WHITE : G15_COLOR_BLACK); + int px = ox + i % width; + int py = i / width; + g15r_setPixel(p->canvas, px, py, color); + } +} diff --git a/server/drivers/g15.h b/server/drivers/g15.h new file mode 100644 index 0000000..8af363c --- /dev/null +++ b/server/drivers/g15.h @@ -0,0 +1,90 @@ +/* This is the LCDproc driver for the LCD on the Logitech G15 keyboard + + Copyright (C) 2006 Anthony J. Mirabella. + + 2006-07-23 Version 1.0: Most functions should be implemented and working + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 */ + +#ifndef G15_H_ +#define G15_H_ + +//#include +#include +#include +#include "lcd.h" + +typedef struct driver_private_data { + /* dimensions */ + int width, height; + int cellwidth, cellheight; + /* file descriptor for g15daemon socket */ + int g15screen_fd; + /* canvas for LCD contents */ + g15canvas *canvas; + g15canvas *backingstore; + /* status indicators */ + int backlight_state; +} PrivateData; + +#define G15_OFFSET 32 +#define G15_PX_WIDTH 160 +#define G15_PX_HEIGHT 43 +#define G15_CHAR_WIDTH 20 +#define G15_CHAR_HEIGHT 5 +#define G15_CELL_WIDTH 8 +#define G15_CELL_HEIGHT 8 +#define G15_LCD_WRITE_CMD 0x03 +#define G15_USB_ENDPT 2 +#define G15_ICON_HEART_FILLED 3 +#define G15_ICON_HEART_OPEN 3 +#define G15_ICON_ARROW_UP 24 +#define G15_ICON_ARROW_DOWN 25 +#define G15_ICON_ARROW_RIGHT 26 +#define G15_ICON_ARROW_LEFT 27 +#define G15_ICON_CHECKBOX_ON 7 +#define G15_ICON_CHECKBOX_OFF 9 +#define G15_ICON_CHECKBOX_GRAY 10 +#define G15_ICON_STOP 254 +#define G15_ICON_PAUSE 186 +#define G15_ICON_PLAY 16 +#define G15_ICON_PLAYR 17 +#define G15_ICON_FF 175 +#define G15_ICON_FR 174 +#define G15_ICON_NEXT 242 +#define G15_ICON_PREV 243 +#define G15_ICON_REC 7 +#define G15_BIGNUM_LEN 1032 + +extern short g15_bignum_data[11][G15_BIGNUM_LEN]; + +MODULE_EXPORT int g15_init (Driver *drvthis); +MODULE_EXPORT void g15_close (Driver *drvthis); +MODULE_EXPORT int g15_width (Driver *drvthis); +MODULE_EXPORT int g15_height (Driver *drvthis); +MODULE_EXPORT int g15_cellwidth (Driver *drvthis); +MODULE_EXPORT int g15_cellheight (Driver *drvthis); +MODULE_EXPORT void g15_clear (Driver *drvthis); +MODULE_EXPORT void g15_flush (Driver *drvthis); +MODULE_EXPORT void g15_string (Driver *drvthis, int x, int y, char string[]); +MODULE_EXPORT void g15_chr (Driver *drvthis, int x, int y, char c); +MODULE_EXPORT int g15_icon (Driver *drvthis, int x, int y, int icon); +MODULE_EXPORT void g15_hbar(Driver *drvthis, int x, int y, int len, int promille, int options); +MODULE_EXPORT void g15_vbar(Driver *drvthis, int x, int y, int len, int promille, int options); +MODULE_EXPORT const char * g15_get_key (Driver *drvthis); +MODULE_EXPORT void g15_backlight(Driver *drvthis, int on); +MODULE_EXPORT void g15_num(Driver * drvthis, int x, int num); + +#endif /*G15_H_*/ diff --git a/server/drivers/hd44780-serial.c b/server/drivers/hd44780-serial.c new file mode 100644 index 0000000..ccfe3a5 --- /dev/null +++ b/server/drivers/hd44780-serial.c @@ -0,0 +1,256 @@ +/* + * Driver for serial connected hd44780 LCDs + * Copyright (C) 2006 Matteo Pillon + * + * Some parts are based on the original pic-an-lcd driver code + * Copyright (C) 1997, Matthias Prinke + * 1998, Richard Rognlie + * 1999, Ethan Dicks + * 1999-2000, Benjamin Tse + * 2001, Rene Wagner + * 2001-2002, Joris Robijn + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "hd44780-serial.h" +#include "hd44780-low.h" + +#include "report.h" + +#include +#include +#include + +#include +#include +#include +#include + +#include + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#define SERIAL_IF serial_interfaces[p->serial_type] + +/* bitrate conversion */ +unsigned int bitrate_conversion[][2] = { + { 50, B50 }, + { 75, B75 }, + { 110, B110 }, + { 134, B134 }, + { 150, B150 }, + { 200, B200 }, + { 300, B300 }, + { 600, B600 }, + { 1200, B1200 }, + { 1800, B1800 }, + { 2400, B2400 }, + { 4800, B4800 }, + { 9600, B9600 }, + { 19200, B19200 }, + { 38400, B38400 }, + { 57600, B57600 }, + { 115200, B115200 }, + { 230400, B230400 }, + { 460800, B460800 }, + { 500000, B500000 }, + { 576000, B576000 }, + { 921600, B921600 }, + { 1000000, B1000000 }, + { 1152000, B1152000 }, + { 1500000, B1500000 }, + { 2000000, B2000000 }, + { 2500000, B2500000 }, + { 3000000, B3000000 }, + { 3500000, B3500000 }, + { 4000000, B4000000 } +}; + +int convert_bitrate(unsigned int conf_bitrate, size_t *bitrate) { + int counter; + for ( counter=0 ; counterprivate_data; + + struct termios portset; + char device[256] = DEFAULT_DEVICE; + + /* READ CONFIG FILE */ + + /* Get interface type */ + int counter; + char conf_serialif[SERIALIF_NAME_LENGTH]; + + strncpy(conf_serialif, drvthis->config_get_string(drvthis->name, "connectiontype", 0, ""), SERIALIF_NAME_LENGTH); + conf_serialif[SERIALIF_NAME_LENGTH-1]='\0'; + p->serial_type=0; + for (counter=0; counter<(sizeof(serial_interfaces)/sizeof(SerialInterface)); counter++) { + if (strcasecmp(conf_serialif, serial_interfaces[counter].name) == 0) { + p->serial_type=counter; + break; + } + } + if (p->serial_type != counter) { + report(RPT_ERR, "HD44780: serial: serial interface %s unknown", conf_serialif); + report(RPT_ERR, "HD44780: serial: available interfaces:"); + for (counter=0; counter<(sizeof(serial_interfaces)/sizeof(SerialInterface)); counter++) + report(RPT_ERR, " %s", serial_interfaces[counter].name); + return -1; + } + + report (RPT_INFO,"HD44780: serial: device type: %s", SERIAL_IF.name); + + /* Check if user knows the capabilities of his hardware ;-) */ + if (p->have_keypad && !(SERIAL_IF.keypad)) { + report (RPT_ERR, "HD44780: serial: keypad is not supported by %s", SERIAL_IF.name); + report (RPT_ERR, "HD44780: serial: check your configuration file and disable it"); + return -1; + } + if (p->have_backlight && !(SERIAL_IF.backlight)) { + report (RPT_ERR, "HD44780: serial: backlight control is not supported by %s", SERIAL_IF.name); + report (RPT_ERR, "HD44780: serial: check your configuration file and disable it"); + return -1; + } + + /* Get bitrate */ + unsigned int conf_bitrate; + size_t bitrate; + + conf_bitrate=atoi( drvthis->config_get_string(drvthis->name, "Speed", 0, "0") ); + if (conf_bitrate==0) + conf_bitrate=SERIAL_IF.default_bitrate; + if (convert_bitrate(conf_bitrate, &bitrate)) { + report(RPT_ERR, "HD44780: serial: invalid configured bitrate speed"); + return -1; + } + report (RPT_INFO,"HD44780: serial: using speed: %d", conf_bitrate); + + /* Get serial device to use */ + strncpy(device, drvthis->config_get_string(drvthis->name, "device", 0, DEFAULT_DEVICE), sizeof(device)); + device[sizeof(device)-1]=0; + report (RPT_INFO,"HD44780: serial: using device: %s", device); + + /* Set up io port correctly, and open it... */ + p->fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY); + if (p->fd == -1) { + report(RPT_ERR, "HD44780: serial: could not open device %s (%s)", device, strerror(errno)); + return -1; + } + + /* Get serial device parameters */ + tcgetattr(p->fd, &portset); + + /* We use RAW mode */ +#ifdef HAVE_CFMAKERAW + /* The easy way */ + cfmakeraw( &portset ); +#else + /* The hard way */ + portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP + | INLCR | IGNCR | ICRNL | IXON ); + portset.c_oflag &= ~OPOST; + portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN ); + portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS ); + portset.c_cflag |= CS8 | CREAD | CLOCAL ; +#endif + /* Set port speed */ + cfsetospeed(&portset, bitrate); + cfsetispeed(&portset, B0); + + /* Set TCSANOW mode of serial device */ + tcsetattr(p->fd, TCSANOW, &portset); + + /* Assign functions */ + p->hd44780_functions->senddata = serial_HD44780_senddata; + p->hd44780_functions->backlight = serial_HD44780_backlight; + if (p->have_keypad) + p->hd44780_functions->scankeypad = serial_HD44780_scankeypad; + + /* Do initialization */ + if (SERIAL_IF.if_bits == 8) { + report (RPT_INFO,"HD44780: serial: initializing with 8 bits interface"); + common_init (p, IF_8BIT); + } else { + report (RPT_INFO,"HD44780: serial: initializing with 4 bits interface"); + common_init (p, IF_4BIT); + } + + return 0; +} + +// serial_HD44780_senddata +void +serial_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch) +{ + /* Filter illegally sent escape characters (for interfaces without data escape) */ + if (flags == RS_DATA && SERIAL_IF.data_escape==0 && ch==SERIAL_IF.instruction_escape) + ch='?'; + + if (flags == RS_DATA) { + /* Do we need a DATA indicator byte? */ + if( SERIAL_IF.data_escape!=0 && chfd, &SERIAL_IF.data_escape, 1 ); + } + write( p->fd, &ch, 1 ); + } + else { + write( p->fd, &SERIAL_IF.instruction_escape, 1 ); + write( p->fd, &ch, 1 ); + } +} + +void +serial_HD44780_backlight (PrivateData *p, unsigned char state) +{ + /* TODO */ + if(p->have_backlight); + return 0; +} + +unsigned char +serial_HD44780_scankeypad (PrivateData *p) +{ + unsigned char buffer = 0; + char hangcheck = 100; + read(p->fd, &buffer, 1); + if (buffer == SERIAL_IF.keypad_escape) { + while(hangcheck>0) { + /* Check if I can read another byte */ + if (read(p->fd, &buffer, 1) == 1) { + return buffer; + } + hangcheck--; + } + } + return 0; +} diff --git a/server/drivers/hd44780-serial.h b/server/drivers/hd44780-serial.h new file mode 100644 index 0000000..d36fe72 --- /dev/null +++ b/server/drivers/hd44780-serial.h @@ -0,0 +1,36 @@ +#ifndef HD44780_SERIAL_H +#define HD44780_SERIAL_H + +#include "lcd.h" /* for Driver */ + +#define SERIALIF_NAME_LENGTH 20 + +#define DEFAULT_DEVICE "/dev/lcd" + +typedef struct SerialInterface { + char name[SERIALIF_NAME_LENGTH]; + char instruction_escape; + char data_escape; + char data_escape_max; /* data escape upper limit */ + unsigned int default_bitrate; + char if_bits; + char keypad; + char keypad_escape; + char backlight; + char backlight_escape; +} SerialInterface; + +/* List of connectiontypes managed by this driver, if you change + something here, remember also to change hd44780-drivers.h */ +static const SerialInterface serial_interfaces[] = { + /* name instr data ^ bitrate bits K esc B esc */ + {"picanlcd", 0x11, 0x12, 0x20, 9600, 8, 0, 0, 0, 0 }, + {"lcdserializer", 0xFE, 0, 0, 9600, 8, 0, 0, 0, 0 }, + {"los-panel", 0xFE, 0, 0, 9600, 4, 1, 0xFE, 1, 0 }, + {"vdr-lcd", 0xFE, 0, 0, 9600, 4, 0, 0, 0, 0 } +}; + +/* initialize this particular driver */ +int hd_init_serial (Driver *drvthis); + +#endif