From ff368e708993a778f997cab6cbc0c93179b7cd69 Mon Sep 17 00:00:00 2001 From: gfk Date: Tue, 25 Dec 2001 18:01:45 +0000 Subject: [PATCH] Fix my (incorrect) fix (with a good one I hope). Also reimplemented delayMult in the driver. --- server/drivers/hd44780.c | 18 +++++++++--------- server/drivers/timing.h | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/server/drivers/hd44780.c b/server/drivers/hd44780.c index 80116e9..c4e935c 100644 --- a/server/drivers/hd44780.c +++ b/server/drivers/hd44780.c @@ -96,6 +96,7 @@ char have_keypad = 0; // off by default char have_backlight = 0; // off by default char extIF = 0; // off by default char delayBus = 0; // Delay if the computer can send data too fast over +int delayMult = 0; // Delay multiplier for slow displays // its bus to LPT port // These vars is not static, so it's accessable from @@ -153,7 +154,6 @@ void HD44780_draw_frame (char *dat); char HD44780_getkey (); void HD44780_position (int x, int y); -//static void uPause (int delayCalls); unsigned char HD44780_scankeypad(); static int parse_span_list (int *spanListArray[], int *spLsize, int *dispOffsets[], int *dOffsize, int *dispSizeArray[], char *spanlist); @@ -310,11 +310,11 @@ void common_init () { hd44780_functions->senddata (0, RS_INSTR, ONOFFCTRL | DISPON | CURSOROFF | CURSORNOBLINK); - hd44780_functions->uPause (40); + hd44780_functions->uPause (40*delayMult); hd44780_functions->senddata (0, RS_INSTR, CLEAR); - hd44780_functions->uPause (1600); + hd44780_functions->uPause (1600*delayMult); hd44780_functions->senddata (0, RS_INSTR, HOMECURSOR); - hd44780_functions->uPause (1600); + hd44780_functions->uPause (1600*delayMult); } ///////////////////////////////////////////////////////////////// @@ -350,7 +350,7 @@ HD44780_position (int x, int y) DDaddr += HD44780->wid; hd44780_functions->senddata (dispID, RS_INSTR, POSITION | DDaddr); - hd44780_functions->uPause (40); // Minimum exec time for all commands + hd44780_functions->uPause (40*delayMult); // Minimum exec time for all commands } ///////////////////////////////////////////////////////////////// @@ -419,7 +419,7 @@ HD44780_flush_box (int lft, int top, int rgt, int bot) for (x = lft; x <= rgt; x++) { hd44780_functions->senddata (spanList[y], RS_DATA, HD44780->framebuf[(y * HD44780->wid) + x]); - hd44780_functions->uPause (40); // Minimum exec time for all commands + hd44780_functions->uPause (40*delayMult); // Minimum exec time for all commands } //write(fd, HD44780->framebuf[(y*HD44780->wid)+lft, rgt-lft+1]); } @@ -685,7 +685,7 @@ HD44780_set_char (int n, char *dat) return; hd44780_functions->senddata (0, RS_INSTR, SETCHAR | n * 8); - hd44780_functions->uPause (40); // Minimum exec time for all commands + hd44780_functions->uPause (40*delayMult); // Minimum exec time for all commands for (row = 0; row < HD44780->cellhgt; row++) { letter = 0; @@ -694,7 +694,7 @@ HD44780_set_char (int n, char *dat) letter |= (dat[(row * HD44780->cellwid) + col] > 0); } hd44780_functions->senddata (0, RS_DATA, letter); - hd44780_functions->uPause (40); // Minimum exec time for all commands + hd44780_functions->uPause (40*delayMult); // Minimum exec time for all commands } } @@ -769,7 +769,7 @@ HD44780_draw_frame (char *dat) HD44780_position(x,y); } hd44780_functions->senddata( spanList[y], RS_DATA, HD44780_charmap[(unsigned char)dat[(y * wid) + x]]); - hd44780_functions->uPause (40); // Minimum exec time for all commands + hd44780_functions->uPause (40*delayMult); // Minimum exec time for all commands lcd_contents[(y*wid)+x] = dat[(y*wid)+x]; } else { diff --git a/server/drivers/timing.h b/server/drivers/timing.h index a437c1f..c481a26 100644 --- a/server/drivers/timing.h +++ b/server/drivers/timing.h @@ -98,9 +98,9 @@ static inline void timing_uPause (int usecs) { delay_time.tv_nsec = remaining.tv_nsec; } #else // using I/O timing - // Assuming every port I/O takes 1ms, we'll do at least one. - int i=0; - do { port_in (port); } while (i++ < usecs/1000); + // Assuming every port I/O takes 1us + for (int i=0; i < usecs; ++i) + port_in(port); #endif }