OSDN Git Service

Bug fixed the lcd control.
[bluetank/bluetank.git] / firm / bare_metal / common / lcd.c
index 8f2f596..5689813 100644 (file)
@@ -115,14 +115,14 @@ void lcd_init(void)
     DATA(0x02); DELAY_US(1); E_ON(); DELAY_US(1); E_OFF(); DELAY_US(1000);
     DATA(0x02); DELAY_US(1); E_ON(); DELAY_US(1); E_OFF(); DELAY_US(1000);
     DATA(0x08); DELAY_US(1); E_ON(); DELAY_US(1); E_OFF(); DELAY_US(1000);
-    DELAY_US(40);
+    DELAY_US(50);
 
     /*
      * Display ON/OFF Control
      */
     DATA(0x00); DELAY_US(1); E_ON(); DELAY_US(1); E_OFF(); DELAY_US(1000);
     DATA(0x0C); DELAY_US(1); E_ON(); DELAY_US(1); E_OFF(); DELAY_US(1000);
-    DELAY_US(40);
+    DELAY_US(50);
 
     /*
      * Display Clear
@@ -136,7 +136,7 @@ void lcd_init(void)
      */
     DATA(0x00); DELAY_US(1); E_ON(); DELAY_US(1); E_OFF(); DELAY_US(1000);
     DATA(0x06); DELAY_US(1); E_ON(); DELAY_US(1); E_OFF(); DELAY_US(1000);
-    DELAY_US(40);
+    DELAY_US(50);
 }
 
 void lcd_clear(void)
@@ -159,7 +159,7 @@ void lcd_entry_mode_set(bool increment, bool shifted)
     write_command(0x04
             | (increment ? (1 << 1) : (0 << 1))
             | (shifted ? (1 << 0) : (0 << 0)));
-    DELAY_US(40);
+    DELAY_US(50);
 }
 
 void lcd_display(bool display, bool cursor, bool blink)
@@ -169,7 +169,7 @@ void lcd_display(bool display, bool cursor, bool blink)
             | (display ? (1 << 2) : (0 << 2))
             | (cursor ? (1 << 1) : (0 << 1))
             | (blink ? (1 << 0) : (0 << 0)));
-    DELAY_US(40);
+    DELAY_US(50);
 }
 
 void lcd_cursor_shift(Direction dir)
@@ -178,7 +178,7 @@ void lcd_cursor_shift(Direction dir)
     write_command(0x10
             | (0 << 3)
             | ((Right == dir) ? (1 << 2) : (0 << 2)));
-    DELAY_US(40);
+    DELAY_US(50);
 }
 
 void lcd_display_shift(Direction dir)
@@ -187,7 +187,7 @@ void lcd_display_shift(Direction dir)
     write_command(0x10
             | (1 << 3)
             | ((Right == dir) ? (1 << 2) : (0 << 2)));
-    DELAY_US(40);
+    DELAY_US(50);
 }
 
 void lcd_goto(uint8_t x, uint8_t y)
@@ -196,14 +196,14 @@ void lcd_goto(uint8_t x, uint8_t y)
     RS_OFF();
     write_command(0x80
             | (addr & 0x7f));
-    DELAY_US(40);
+    DELAY_US(50);
 }
 
 void lcd_putc(char c)
 {
     RS_ON();
     write_command(c);
-    DELAY_US(46);
+    DELAY_US(50);
 }
 
 void lcd_puts(char *str)
@@ -295,16 +295,16 @@ void lcd_font_draw_line(
 
 void lcd_font_setup_single(FontSet *fs, UserFont index)
 {
-    uint8_t addr = 0;
+    uint8_t addr = 8 * (int)index;
     int i = (int)index, j;
     for (j = 0; j < LCD_FONT_HEIGHT; j++) {
         RS_OFF();
         write_command(0x40 | (addr & 0x3f));
-        DELAY_US(40);
+        DELAY_US(50);
 
         RS_ON();
         write_command(fs->fontlist[i].data[j]);
-        DELAY_US(46);
+        DELAY_US(50);
 
         addr++;
     }
@@ -318,11 +318,11 @@ void lcd_font_setup_all(FontSet *fs)
         for (j = 0; j < LCD_FONT_HEIGHT; j++) {
             RS_OFF();
             write_command(0x40 | (addr & 0x3f));
-            DELAY_US(40);
+            DELAY_US(50);
 
             RS_ON();
             write_command(fs->fontlist[i].data[j]);
-            DELAY_US(46);
+            DELAY_US(50);
 
             addr++;
         }