harmonize backingstroe name with other drivers; don't force connection type

drivers to define nop-like functions for features they don't support
This commit is contained in:
marschap
2007-11-04 13:25:54 +00:00
parent c76af798c3
commit e6c4b71ff0
8 changed files with 48 additions and 77 deletions
-15
View File
@@ -50,8 +50,6 @@ hd_init_bwct_usb(Driver *drvthis)
char serial[LCD_MAX_WIDTH+1] = DEFAULT_SERIALNO;
p->hd44780_functions->senddata = bwct_usb_HD44780_senddata;
p->hd44780_functions->backlight = bwct_usb_HD44780_backlight;
p->hd44780_functions->scankeypad = bwct_usb_HD44780_scankeypad;
p->hd44780_functions->close = bwct_usb_HD44780_close;
drvthis->set_contrast = bwct_usb_set_contrast;
@@ -189,19 +187,6 @@ int type = (flags == RS_DATA) ? BWCT_LCD_DATA : BWCT_LCD_CMD;
}
void
bwct_usb_HD44780_backlight(PrivateData *p, unsigned char state)
{
}
unsigned char
bwct_usb_HD44780_scankeypad(PrivateData *p)
{
return '\0';
}
void
bwct_usb_HD44780_close(PrivateData *p)
{
-2
View File
@@ -19,9 +19,7 @@
int hd_init_bwct_usb(Driver *drvthis);
void bwct_usb_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
void bwct_usb_HD44780_backlight(PrivateData *p, unsigned char state);
void bwct_usb_set_contrast(Driver *drvthis, int promille);
unsigned char bwct_usb_HD44780_scankeypad(PrivateData *p);
void bwct_usb_HD44780_close(PrivateData *p);
#endif
+12 -12
View File
@@ -1,3 +1,7 @@
/** \file hd44780-ftdi.c
* \c ftdi connection type of \c hd44780 driver for Hitachi HD44780 based LCD displays.
*/
/*
* FTDI/USB driver module for Hitachi HD44780 based LCD displays
* connected to a FT2232C/D chip in 8 bit mode.
@@ -39,7 +43,6 @@ hd_init_ftdi(Driver *drvthis)
p->hd44780_functions->senddata = ftdi_HD44780_senddata;
p->hd44780_functions->backlight = ftdi_HD44780_backlight;
p->hd44780_functions->scankeypad = ftdi_HD44780_scankeypad;
p->hd44780_functions->close = ftdi_HD44780_close;
// Load config
@@ -93,7 +96,8 @@ ftdi_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char fla
// Output data on first channel
int f = ftdi_write_data(&p->ftdic, &ch, 1);
if (f < 0) {
p->hd44780_functions->drv_report(RPT_ERR, "failed to write: %d (%s). Exiting", f, ftdi_get_error_string(&p->ftdic));
p->hd44780_functions->drv_report(RPT_ERR, "failed to write: %d (%s). Exiting",
f, ftdi_get_error_string(&p->ftdic));
exit (-1);
}
@@ -104,7 +108,8 @@ ftdi_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char fla
}
f = ftdi_write_data(&p->ftdic2, &ch, 1);
if (f < 0) {
p->hd44780_functions->drv_report(RPT_ERR, "failed to write: %d (%s). Exiting", f, ftdi_get_error_string(&p->ftdic2));
p->hd44780_functions->drv_report(RPT_ERR, "failed to write: %d (%s). Exiting",
f, ftdi_get_error_string(&p->ftdic2));
exit(-1);
}
@@ -115,7 +120,8 @@ ftdi_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char fla
}
f = ftdi_write_data(&p->ftdic2, &ch, 1);
if (f < 0) {
p->hd44780_functions->drv_report(RPT_ERR, "failed to write: %d (%s). Exiting", f, ftdi_get_error_string(&p->ftdic2));
p->hd44780_functions->drv_report(RPT_ERR, "failed to write: %d (%s). Exiting",
f, ftdi_get_error_string(&p->ftdic2));
exit(-1);
}
}
@@ -130,19 +136,13 @@ ftdi_HD44780_backlight(PrivateData *p, unsigned char state)
f = ftdi_write_data(&p->ftdic2, &state, 1);
if (f < 0) {
p->hd44780_functions->drv_report(RPT_ERR, "failed to write: %d (%s). Exiting", f, ftdi_get_error_string(&p->ftdic2));
p->hd44780_functions->drv_report(RPT_ERR, "failed to write: %d (%s). Exiting",
f, ftdi_get_error_string(&p->ftdic2));
exit(-1);
}
}
unsigned char
ftdi_HD44780_scankeypad(PrivateData *p)
{
return 0;
}
void
ftdi_HD44780_close(PrivateData *p)
{
-1
View File
@@ -9,7 +9,6 @@ int hd_init_ftdi(Driver *drvthis);
void ftdi_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
void ftdi_HD44780_backlight(PrivateData *p, unsigned char state);
unsigned char ftdi_HD44780_scankeypad(PrivateData *p);
void ftdi_HD44780_close(PrivateData *p);
#endif
-1
View File
@@ -157,7 +157,6 @@ hd_init_i2c(Driver *drvthis)
hd44780_functions->senddata = i2c_HD44780_senddata;
hd44780_functions->backlight = i2c_HD44780_backlight;
hd44780_functions->scankeypad = NULL;
// powerup the lcd now
/* We'll now send 0x03 a couple of times,
-16
View File
@@ -48,8 +48,6 @@ extern unsigned int **bitrate_conversion;
extern int convert_bitrate(unsigned int conf_bitrate, size_t *bitrate);
void lis2_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
void lis2_HD44780_backlight(PrivateData *p, unsigned char state);
unsigned char lis2_HD44780_scankeypad(PrivateData *p);
static void clearScreen(int fd);
static void gotoXY(int fd, unsigned char x, unsigned char y);
@@ -122,8 +120,6 @@ int hd_init_lis2(Driver *drvthis)
tcsetattr(p->fd, TCSANOW, &portset);
p->hd44780_functions->senddata = lis2_HD44780_senddata;
p->hd44780_functions->backlight = lis2_HD44780_backlight;
p->hd44780_functions->scankeypad = lis2_HD44780_scankeypad;
common_init(p, IF_8BIT);
@@ -220,18 +216,6 @@ static unsigned char rowNum = 0;
}
void lis2_HD44780_backlight(PrivateData *p, unsigned char state)
{
/* No backlight control */
}
unsigned char lis2_HD44780_scankeypad(PrivateData *p)
{
return '\0';
}
// hardware specific functions common to all device types
/**
+15 -16
View File
@@ -171,8 +171,8 @@ hd_init_serial(Driver *drvthis)
size_t bitrate;
conf_bitrate = drvthis->config_get_int(drvthis->name, "Speed", 0, SERIAL_IF.default_bitrate);
if (conf_bitrate == 0)
conf_bitrate = SERIAL_IF.default_bitrate;
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;
@@ -215,14 +215,13 @@ hd_init_serial(Driver *drvthis)
/* Set TCSANOW mode of serial device */
tcsetattr(p->fd, TCSANOW, &portset);
lastdisplayID = -1;
lastdisplayID = -1;
/* 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;
p->hd44780_functions->close = serial_HD44780_close;
p->hd44780_functions->scankeypad = serial_HD44780_scankeypad;
p->hd44780_functions->close = serial_HD44780_close;
/* Do initialization */
if (SERIAL_IF.if_bits == 8) {
@@ -248,8 +247,8 @@ serial_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char f
/* Do we need a DATA indicator byte? */
if ((SERIAL_IF.data_escape != '\0') &&
(((ch >= SERIAL_IF.data_escape_min) &&
(ch < SERIAL_IF.data_escape_max)) ||
(SERIAL_IF.multiple_displays && displayID != lastdisplayID))) {
(ch < SERIAL_IF.data_escape_max)) ||
(SERIAL_IF.multiple_displays && displayID != lastdisplayID))) {
write(p->fd, &SERIAL_IF.data_escape + displayID, 1);
}
write(p->fd, &ch, 1);
@@ -258,25 +257,25 @@ serial_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char f
write(p->fd, &SERIAL_IF.instruction_escape, 1);
write(p->fd, &ch, 1);
}
lastdisplayID = displayID;
lastdisplayID = displayID;
}
void
serial_HD44780_backlight(PrivateData *p, unsigned char state)
{
unsigned char send[1];
unsigned char send[1];
if (p->have_backlight) {
if (SERIAL_IF.backlight_escape) {
send[0] = SERIAL_IF.backlight_escape;
write(p->fd, &send, 1);
}
if (SERIAL_IF.backlight_on && SERIAL_IF.backlight_off) {
}
if (SERIAL_IF.backlight_on && SERIAL_IF.backlight_off) {
send[0] = state ? SERIAL_IF.backlight_on : SERIAL_IF.backlight_off;
}
else {
send[0] = state ? 0 : 0xFF;
}
write(p->fd, &send, 1);
write(p->fd, &send, 1);
}
}
@@ -302,7 +301,7 @@ serial_HD44780_scankeypad(PrivateData *p)
void
serial_HD44780_close(PrivateData *p)
{
if (SERIAL_IF.end_code)
write(p->fd, &SERIAL_IF.end_code, 1);
close(p->fd);
if (SERIAL_IF.end_code)
write(p->fd, &SERIAL_IF.end_code, 1);
close(p->fd);
}
+21 -14
View File
@@ -376,31 +376,38 @@ HD44780_init(Driver *drvthis)
p->hd44780_functions->set_contrast = NULL;
p->hd44780_functions->set_brightness = NULL;
p->hd44780_functions->readkeypad = NULL;
p->hd44780_functions->scankeypad = HD44780_scankeypad;
p->hd44780_functions->scankeypad = NULL;
p->hd44780_functions->output = NULL;
p->hd44780_functions->close = NULL;
// Do connection type specific display init
// Do local (=connection type specific) display init
if (init_fn(drvthis) != 0)
return -1;
// consistency check: local keypad functions missing => no keypad
if ((p->hd44780_functions->readkeypad == NULL) &&
(p->hd44780_functions->scankeypad == HD44780_scankeypad)) {
p->hd44780_functions->scankeypad = NULL;
p->have_keypad = 0;
}
// consistency check: no local output function => no output
if (p->hd44780_functions->output == NULL)
p->have_output = 0;
// fail if local senddata function was not defined
// consistency check: fail if local senddata function was not defined
if (p->hd44780_functions->senddata == NULL) {
report(RPT_ERR, "%s: incomplete functions for connection type");
return -1;
}
// set scankeypad function if local readkeypad function is defined
if ((p->hd44780_functions->readkeypad != NULL) &&
(p->hd44780_functions->scankeypad == NULL)) {
p->hd44780_functions->scankeypad = HD44780_scankeypad;
}
// consistency check: no local keypad function => no keypad
if (p->hd44780_functions->scankeypad == NULL)
p->have_keypad = 0;
// consistency check: no local backlight function => no backlight
if (p->hd44780_functions->backlight == NULL)
p->have_backlight = 0;
// consistency check: no local output function => no output
if (p->hd44780_functions->output == NULL)
p->have_output = 0;
// Display startup parameters on the LCD
HD44780_clear(drvthis);