lcd_st7920: Use a longer delay at the start of each command/data

It appears the st7920 requires a longer delay when switching from
command to data mode (and vice-versa).  Slower MCUs don't show a
problem because the klipper command processing time results in a
sufficient delay.  However, some of the faster MCUs can process
klipper commands fast enough that the next st7920 transfer is sent too
fast.  Add an additional delay to account for this.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-06-22 22:07:48 -04:00
parent 74de181e59
commit f08a0c5e93
4 changed files with 33 additions and 22 deletions

View file

@ -161,7 +161,9 @@ HD44780_chars = [
# ST7920 (128x64 graphics) lcd chip
######################################################################
ST7920_DELAY = .000020 # Spec says 72us, but faster is possible in practice
# Spec says 72us, but faster is possible in practice
ST7920_CMD_DELAY = .000020
ST7920_SYNC_DELAY = .000045
class ST7920:
char_right_arrow = '\x1a'
@ -182,7 +184,6 @@ class ST7920:
self.mcu = mcu
self.oid = self.mcu.create_oid()
self.mcu.add_config_object(self)
self.chip_delay = config.getfloat('chip_delay', ST7920_DELAY, minval=0.)
self.send_data_cmd = self.send_cmds_cmd = None
self.is_extended = False
# framebuffers
@ -195,9 +196,10 @@ class ST7920:
def build_config(self):
self.mcu.add_config_cmd(
"config_st7920 oid=%u cs_pin=%s sclk_pin=%s sid_pin=%s"
" delay_ticks=%d" % (
" sync_delay_ticks=%d cmd_delay_ticks=%d" % (
self.oid, self.pins[0], self.pins[1], self.pins[2],
self.mcu.seconds_to_clock(self.chip_delay)))
self.mcu.seconds_to_clock(ST7920_SYNC_DELAY),
self.mcu.seconds_to_clock(ST7920_CMD_DELAY)))
cmd_queue = self.mcu.alloc_command_queue()
self.send_cmds_cmd = self.mcu.lookup_command(
"st7920_send_cmds oid=%c cmds=%*s", cq=cmd_queue)