1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-09 19:29:27 +08:00

Change init payload sequence within jhd1313m1 driver Start() func.

+ code transposed from github.com/Seeed-Studio/Grove_LCD_RGB_Backlight/blob/master/rgb_lcd.cpp.

+ this fix ensures that the 2 lcd lines are addressable.
This commit is contained in:
stan 2017-11-05 16:56:51 +01:00
parent 9f153dbce4
commit 4d1612bb57

View File

@ -126,15 +126,32 @@ func (h *JHD1313M1Driver) Start() (err error) {
return err
}
time.Sleep(50000 * time.Microsecond)
payload := []byte{LCD_CMD, LCD_FUNCTIONSET | LCD_2LINE}
if _, err := h.lcdConnection.Write(payload); err != nil {
if _, err := h.lcdConnection.Write(payload); err != nil {
return err
}
// SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
// according to datasheet, we need at least 40ms after power rises above 2.7V
// before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
time.Sleep(50 * time.Millisecond)
// this is according to the hitachi HD44780 datasheet
// page 45 figure 23
// Send function set command sequence
init_payload := []byte{LCD_CMD, LCD_FUNCTIONSET | LCD_2LINE}
if _, err := h.lcdConnection.Write(init_payload); err != nil {
return err
}
// wait more than 4.1ms
time.Sleep(4500 * time.Microsecond)
// second try
if _, err := h.lcdConnection.Write(init_payload); err != nil {
return err
}
time.Sleep(150 * time.Microsecond)
// third go
if _, err := h.lcdConnection.Write(init_payload); err != nil {
return err
}
time.Sleep(100 * time.Microsecond)
if _, err := h.lcdConnection.Write([]byte{LCD_CMD, LCD_DISPLAYCONTROL | LCD_DISPLAYON}); err != nil {
return err
}