harmonize coding style and messages

This commit is contained in:
marschap
2006-04-08 21:05:51 +00:00
parent 1f0028cb6e
commit 3c52181126
10 changed files with 196 additions and 174 deletions
+3 -3
View File
@@ -141,7 +141,7 @@ hd_init_bwct_usb (Driver *drvthis)
done: done:
if (bwct_usb != NULL) { if (bwct_usb != NULL) {
debug(RPT_DEBUG, "hd_init_bwct_usb: opening device succeeded\n"); debug(RPT_DEBUG, "hd_init_bwct_usb: opening device succeeded");
if (usb_claim_interface(bwct_usb, bwct_usb_i) < 0) { if (usb_claim_interface(bwct_usb, bwct_usb_i) < 0) {
#if defined(LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP) #if defined(LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP)
@@ -170,9 +170,9 @@ hd_init_bwct_usb (Driver *drvthis)
int res = usb_control_msg(bwct_usb, USB_TYPE_VENDOR, VENDOR_LCD_CONTRAST, int res = usb_control_msg(bwct_usb, USB_TYPE_VENDOR, VENDOR_LCD_CONTRAST,
(contrast * 255) / 1000, bwct_usb_i, NULL, 0, 1000); (contrast * 255) / 1000, bwct_usb_i, NULL, 0, 1000);
if (res < 0) if (res < 0)
report(RPT_WARNING, "hd_init_bwct_usb: setting contrast failed.\n"); report(RPT_WARNING, "hd_init_bwct_usb: setting contrast failed");
} else { } else {
report(RPT_WARNING, "hd_init_bwct_usb: Using default contrast value.\n"); report(RPT_INFO, "hd_init_bwct_usb: Using default contrast value");
} }
return 0; return 0;
+26 -14
View File
@@ -120,9 +120,10 @@ hd_init_i2c (Driver *drvthis)
/* READ CONFIG FILE */ /* READ CONFIG FILE */
/* Get serial device to use */ /* Get serial device to use */
strncpy(device, drvthis->config_get_string ( drvthis->name , "device" , 0 , DEFAULT_DEVICE),sizeof(device)); strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(device));
device[sizeof(device)-1]=0; device[sizeof(device)-1] = '\0';
report (RPT_INFO,"HD44780: I2C: Using device '%s' and address %u for a %s", device, (p->port & I2C_ADDR_MASK)?"PCA9554(A)":"PCF8574(A)"); report(RPT_INFO,"HD44780: I2C: Using device '%s' and address %u for a %s",
device, (p->port & I2C_ADDR_MASK) ? "PCA9554(A)" : "PCF8574(A)");
// Open the I2C device // Open the I2C device
p->fd = open(device, O_RDWR); p->fd = open(device, O_RDWR);
@@ -160,34 +161,41 @@ hd_init_i2c (Driver *drvthis)
/* We'll now send 0x03 a couple of times, /* We'll now send 0x03 a couple of times,
* which is in fact (FUNCSET | IF_8BIT) >> 4 */ * which is in fact (FUNCSET | IF_8BIT) >> 4 */
i2c_out (p, 0x03); i2c_out (p, 0x03);
if( p->delayBus ) hd44780_functions->uPause (p, 1); if (p->delayBus)
hd44780_functions->uPause(p, 1);
i2c_out(p, enableLines | 0x03); i2c_out(p, enableLines | 0x03);
if( p->delayBus ) hd44780_functions->uPause (p, 1); if (p->delayBus)
hd44780_functions->uPause(p, 1);
i2c_out(p, 0x03); i2c_out(p, 0x03);
hd44780_functions->uPause(p, 15000); hd44780_functions->uPause(p, 15000);
i2c_out(p, enableLines | 0x03); i2c_out(p, enableLines | 0x03);
if( p->delayBus ) hd44780_functions->uPause (p, 1); if (p->delayBus)
hd44780_functions->uPause(p, 1);
i2c_out(p, 0x03); i2c_out(p, 0x03);
hd44780_functions->uPause(p, 5000); hd44780_functions->uPause(p, 5000);
i2c_out(p, enableLines | 0x03); i2c_out(p, enableLines | 0x03);
if( p->delayBus ) hd44780_functions->uPause (p, 1); if (p->delayBus)
hd44780_functions->uPause(p, 1);
i2c_out(p, 0x03); i2c_out(p, 0x03);
hd44780_functions->uPause(p, 100); hd44780_functions->uPause(p, 100);
i2c_out(p, enableLines | 0x03); i2c_out(p, enableLines | 0x03);
if( p->delayBus ) hd44780_functions->uPause (p, 1); if (p->delayBus)
hd44780_functions->uPause(p, 1);
i2c_out(p, 0x03); i2c_out(p, 0x03);
hd44780_functions->uPause(p, 100); hd44780_functions->uPause(p, 100);
// now in 8-bit mode... set 4-bit mode // now in 8-bit mode... set 4-bit mode
i2c_out(p, 0x02); i2c_out(p, 0x02);
if( p->delayBus ) hd44780_functions->uPause (p, 1); if (p->delayBus)
hd44780_functions->uPause(p, 1);
i2c_out(p, enableLines | 0x02); i2c_out(p, enableLines | 0x02);
if( p->delayBus ) hd44780_functions->uPause (p, 1); if (p->delayBus)
hd44780_functions->uPause(p, 1);
i2c_out(p, 0x02); i2c_out(p, 0x02);
hd44780_functions->uPause(p, 100); hd44780_functions->uPause(p, 100);
@@ -218,15 +226,19 @@ i2c_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char fla
enableLines = EN; enableLines = EN;
i2c_out(p, portControl | h); i2c_out(p, portControl | h);
if( p->delayBus ) p->hd44780_functions->uPause (p, 1); if (p->delayBus)
p->hd44780_functions->uPause(p, 1);
i2c_out(p, enableLines | portControl | h); i2c_out(p, enableLines | portControl | h);
if( p->delayBus ) p->hd44780_functions->uPause (p, 1); if (p->delayBus)
p->hd44780_functions->uPause(p, 1);
i2c_out(p, portControl | h); i2c_out(p, portControl | h);
i2c_out(p, portControl | l); i2c_out(p, portControl | l);
if( p->delayBus ) p->hd44780_functions->uPause (p, 1); if (p->delayBus)
p->hd44780_functions->uPause(p, 1);
i2c_out(p, enableLines | portControl | l); i2c_out(p, enableLines | portControl | l);
if( p->delayBus ) p->hd44780_functions->uPause (p, 1); if (p->delayBus)
p->hd44780_functions->uPause(p, 1);
i2c_out(p, portControl | l); i2c_out(p, portControl | l);
} }
+3 -3
View File
@@ -64,14 +64,14 @@ hd_init_lcdserializer (Driver *drvthis)
/* READ CONFIG FILE */ /* READ CONFIG FILE */
/* Get serial device to use */ /* Get serial device to use */
strncpy(device, drvthis->config_get_string ( drvthis->name , "device" , 0 , DEFAULT_DEVICE),sizeof(device)); strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(device));
device[sizeof(device)-1]=0; device[sizeof(device)-1] = '\0';
report(RPT_INFO, "HD44780: LCD Serializer: Using device: %s", device); report(RPT_INFO, "HD44780: LCD Serializer: Using device: %s", device);
// Set up io port correctly, and open it... // Set up io port correctly, and open it...
p->fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY); p->fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
if (p->fd == -1) { if (p->fd == -1) {
report(RPT_ERR, "HD44780: LCD Serializer: could not open device %s (%s)\n", device, strerror(errno)); report(RPT_ERR, "HD44780: LCD Serializer: could not open device %s (%s)", device, strerror(errno));
return -1; return -1;
} }
+5 -6
View File
@@ -65,14 +65,15 @@ int hd_init_lis2 (Driver *drvthis)
/* READ CONFIG FILE */ /* READ CONFIG FILE */
/* Get serial device to use */ /* Get serial device to use */
strncpy(device, drvthis->config_get_string ( drvthis->name , "device" , 0 , DEFAULT_DEVICE),sizeof(device)); strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(device));
device[sizeof(device)-1]=0; device[sizeof(device)-1] = '\0';
printf("HD44780: LCD Serializer: Using device: %s", device); report(RPT_INFO, "HD44780: LCD Serializer: Using device: %s", device);
// Set up io port correctly, and open it... // Set up io port correctly, and open it...
p->fd = open(device, O_RDWR | O_NOCTTY); p->fd = open(device, O_RDWR | O_NOCTTY);
if (p->fd == -1) { if (p->fd == -1) {
printf("HD44780: LCD Serializer: could not open device %s (%s)\n", device, strerror(errno)); report(RPT_ERR, "HD44780: LCD Serializer: could not open device %s (%s)",
device, strerror(errno));
return -1; return -1;
} }
@@ -95,8 +96,6 @@ int hd_init_lis2 (Driver *drvthis)
/* Set TCSANOW mode of serial device */ /* Set TCSANOW mode of serial device */
tcsetattr(p->fd, TCSANOW, &portset); tcsetattr(p->fd, TCSANOW, &portset);
p->hd44780_functions->senddata = lis2_HD44780_senddata; p->hd44780_functions->senddata = lis2_HD44780_senddata;
p->hd44780_functions->backlight = lis2_HD44780_backlight; p->hd44780_functions->backlight = lis2_HD44780_backlight;
p->hd44780_functions->scankeypad = lis2_HD44780_scankeypad; p->hd44780_functions->scankeypad = lis2_HD44780_scankeypad;
+4 -3
View File
@@ -68,14 +68,15 @@ hd_init_picanlcd (Driver *drvthis)
/* READ CONFIG FILE */ /* READ CONFIG FILE */
/* Get serial device to use */ /* Get serial device to use */
strncpy(device, drvthis->config_get_string ( drvthis->name , "device" , 0 , DEFAULT_DEVICE),sizeof(device)); strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(device));
device[sizeof(device)-1]=0; device[sizeof(device)-1] = '\0';
report(RPT_INFO,"HD44780: PIC-an-LCD: Using device: %s", device); report(RPT_INFO,"HD44780: PIC-an-LCD: Using device: %s", device);
// Set up io port correctly, and open it... // Set up io port correctly, and open it...
p->fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY); p->fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
if (p->fd == -1) { if (p->fd == -1) {
report(RPT_ERR, "HD44780: PIC-an-LCD: could not open device %s (%s)\n", device, strerror(errno)); report(RPT_ERR, "HD44780: PIC-an-LCD: could not open device %s (%s)",
device, strerror(errno));
return -1; return -1;
} }
+31 -21
View File
@@ -132,7 +132,7 @@ HD44780_init (Driver * drvthis)
// Alocate and store private data // Alocate and store private data
p = (PrivateData *) malloc(sizeof(PrivateData)); p = (PrivateData *) malloc(sizeof(PrivateData));
if( ! p ) if (p == NULL)
return -1; return -1;
if (drvthis->store_private_ptr( drvthis, p)) if (drvthis->store_private_ptr( drvthis, p))
return -1; return -1;
@@ -156,10 +156,10 @@ HD44780_init (Driver * drvthis)
p->lastline = drvthis->config_get_bool( drvthis->name, "lastline", 0, 1 ); p->lastline = drvthis->config_get_bool( drvthis->name, "lastline", 0, 1 );
// Get and search for the connection type // Get and search for the connection type
s = drvthis->config_get_string( drvthis->name, "connectiontype", 0, "4bit" ); s = drvthis->config_get_string( drvthis->name, "ConnectionType", 0, "4bit" );
for (i = 0; connectionMapping[i].name != NULL && strcmp (s, connectionMapping[i].name) != 0; i++); for (i = 0; connectionMapping[i].name != NULL && strcmp (s, connectionMapping[i].name) != 0; i++);
if (connectionMapping[i].name == NULL) { if (connectionMapping[i].name == NULL) {
report (RPT_ERR, "HD44780_init: Unknown connection type: %s", s); report(RPT_ERR, "%s: unknown ConnectionType: %s", drvthis->name, s);
return -1; // fatal error return -1; // fatal error
} else { } else {
p->connectiontype_index = i; p->connectiontype_index = i;
@@ -173,7 +173,7 @@ HD44780_init (Driver * drvthis)
s = drvthis->config_get_string( drvthis->name, "vspan", 0, "" ); s = drvthis->config_get_string( drvthis->name, "vspan", 0, "" );
if ( s[0] != 0 ) { if ( s[0] != 0 ) {
if (parse_span_list (&(p->spanList), &(p->numLines), &(p->dispVOffset), &(p->numDisplays), &(p->dispSizes), s) == -1) { if (parse_span_list (&(p->spanList), &(p->numLines), &(p->dispVOffset), &(p->numDisplays), &(p->dispSizes), s) == -1) {
report (RPT_ERR, "HD44780_init: invalid vspan value: %s", s ); report(RPT_ERR, "%s: invalid vspan value: %s", drvthis->name, s);
return -1; return -1;
} }
} }
@@ -183,7 +183,7 @@ HD44780_init (Driver * drvthis)
if ( sscanf( s, "%dx%d", &(p->width), &(p->height) ) != 2 if ( sscanf( s, "%dx%d", &(p->width), &(p->height) ) != 2
|| (p->width <= 0) || (p->width > LCD_MAX_WIDTH) || (p->width <= 0) || (p->width > LCD_MAX_WIDTH)
|| (p->height <= 0) || (p->height > LCD_MAX_HEIGHT)) { || (p->height <= 0) || (p->height > LCD_MAX_HEIGHT)) {
report (RPT_ERR, "HD44780_init: Cannot read size: %s", s ); report(RPT_ERR, "%s: cannot read Size %s", drvthis->name, s);
} }
// default case for when spans aren't indicated // default case for when spans aren't indicated
@@ -196,19 +196,20 @@ HD44780_init (Driver * drvthis)
p->numLines = p->height; p->numLines = p->height;
} }
} else } else
report (RPT_ERR, "Error mallocing"); report(RPT_ERR, "%s: error mallocing", drvthis->name);
} }
if (p->numDisplays == 0) { if (p->numDisplays == 0) {
if ((p->dispVOffset = (int *) malloc (sizeof (int))) && (p->dispSizes = (int *) malloc (sizeof (int)))) { if ((p->dispVOffset = (int *) malloc(sizeof(int))) &&
(p->dispSizes = (int *) malloc(sizeof(int)))) {
p->dispVOffset[0] = 0; p->dispVOffset[0] = 0;
p->dispSizes[0] = p->height; p->dispSizes[0] = p->height;
p->numDisplays = 1; p->numDisplays = 1;
} else } else
report (RPT_ERR, "Error mallocing"); report(RPT_ERR, "%s: error mallocing", drvthis->name);
} }
if (timing_init() == -1) { if (timing_init() == -1) {
report(RPT_ERR, "timing_init: failed (%s)\n", strerror(errno)); report(RPT_ERR, "%s: timing_init() failed (%s)", drvthis->name, strerror(errno));
return -1; return -1;
} }
@@ -219,7 +220,8 @@ HD44780_init (Driver * drvthis)
struct sched_param param; struct sched_param param;
param.sched_priority = 1; param.sched_priority = 1;
if ((sched_setscheduler(0, SCHED_RR, &param)) == -1) { if ((sched_setscheduler(0, SCHED_RR, &param)) == -1) {
report (RPT_ERR, "HD44780_init: failed (%s)", strerror (errno)); report(RPT_ERR, "%s: sched_setscheduler() failed (%s)",
drvthis->name, strerror(errno));
return -1; return -1;
} }
} }
@@ -227,14 +229,16 @@ HD44780_init (Driver * drvthis)
// Allocate framebuffer // Allocate framebuffer
p->framebuf = (unsigned char *) malloc(p->width * p->height); p->framebuf = (unsigned char *) malloc(p->width * p->height);
if (!p->framebuf) { if (p->framebuf == NULL) {
report(RPT_ERR, "%s: unable to allocate framebuffer", drvthis->name);
//HD44780_close(); //HD44780_close();
return -1; return -1;
} }
// Allocate and clear the buffer for incremental updates // Allocate and clear the buffer for incremental updates
p->lcd_contents = (unsigned char *) malloc (p->width * p->height); p->lcd_contents = (unsigned char *) malloc (p->width * p->height);
if (!p->lcd_contents) { if (p->lcd_contents == NULL) {
report(RPT_ERR, "%s: unable to allocate framebuffer backing store", drvthis->name);
return -1; return -1;
} }
memset(p->lcd_contents, 0, p->width * p->height); memset(p->lcd_contents, 0, p->width * p->height);
@@ -243,6 +247,7 @@ HD44780_init (Driver * drvthis)
p->cc_buf = (unsigned char *) malloc(NUM_CCs * p->cellheight); p->cc_buf = (unsigned char *) malloc(NUM_CCs * p->cellheight);
p->cc_dirty = (unsigned char *) malloc(NUM_CCs); p->cc_dirty = (unsigned char *) malloc(NUM_CCs);
if (!p->cc_buf || !p->cc_dirty) { if (!p->cc_buf || !p->cc_dirty) {
report(RPT_ERR, "%s: error mallocing", drvthis->name);
return -1; return -1;
} }
memset(p->cc_buf, 0, NUM_CCs * p->cellheight); memset(p->cc_buf, 0, NUM_CCs * p->cellheight);
@@ -294,7 +299,7 @@ HD44780_init (Driver * drvthis)
p->output_state = 999999; p->output_state = 999999;
if ((p->hd44780_functions = (HD44780_functions *) malloc(sizeof(HD44780_functions))) == NULL) { if ((p->hd44780_functions = (HD44780_functions *) malloc(sizeof(HD44780_functions))) == NULL) {
report (RPT_ERR, "Error mallocing"); report(RPT_ERR, "%s: error mallocing", drvthis->name);
return -1; return -1;
} }
p->hd44780_functions->uPause = uPause; p->hd44780_functions->uPause = uPause;
@@ -312,15 +317,13 @@ HD44780_init (Driver * drvthis)
sprintf(buf, "USB %s%s%s", sprintf(buf, "USB %s%s%s",
(p->have_backlight ? " bl" : ""), (p->have_backlight ? " bl" : ""),
(p->have_keypad ? " key" : ""), (p->have_keypad ? " key" : ""),
(p->have_output?" out":"") (p->have_output ? " out" : ""));
);
} }
else { else {
sprintf (buf, "LPT 0x%x%s%s%s", p->port, sprintf(buf, "LPT 0x%03X%s%s%s", p->port,
(p->have_backlight ? " bl" : ""), (p->have_backlight ? " bl" : ""),
(p->have_keypad ? " key" : ""), (p->have_keypad ? " key" : ""),
(p->have_output?" out":"") (p->have_output ? " out" : ""));
);
} }
HD44780_string (drvthis, 1, 2, buf); HD44780_string (drvthis, 1, 2, buf);
HD44780_flush (drvthis); HD44780_flush (drvthis);
@@ -372,9 +375,15 @@ HD44780_close(Driver *drvthis)
{ {
PrivateData *p = (PrivateData *) drvthis->private_data; PrivateData *p = (PrivateData *) drvthis->private_data;
if(p->framebuf) free( p->framebuf ); if (p != NULL) {
if(p->lcd_contents) free( p->lcd_contents ); if (p->framebuf)
free(p->framebuf);
if (p->lcd_contents)
free(p->lcd_contents);
free(p); free(p);
}
drvthis->store_private_ptr(drvthis, NULL); drvthis->store_private_ptr(drvthis, NULL);
} }
@@ -1147,7 +1156,8 @@ HD44780_get_key(Driver *drvthis)
// It's a new keypress // It's a new keypress
p->pressed_key_time = curr_time; p->pressed_key_time = curr_time;
p->pressed_key_repetitions = 0; p->pressed_key_repetitions = 0;
report( RPT_INFO, "HD44780_get_key: Key pressed: %s (%d,%d)\n", keystr, scancode&0x0F, (scancode&0xF0)>>4 ); report(RPT_INFO, "HD44780_get_key: Key pressed: %s (%d,%d)",
keystr, scancode&0x0F, (scancode&0xF0)>>4 );
} }
} }