diff --git a/octoprint_hd44780/__init__.py b/octoprint_hd44780/__init__.py index 1a02b0a..0b7b9a6 100644 --- a/octoprint_hd44780/__init__.py +++ b/octoprint_hd44780/__init__.py @@ -113,6 +113,8 @@ class LCD_HD44780(octoprint.plugin.StartupPlugin, if self._lcd_updating: return + bytes_per_send_cycle = int(self.cols*(self.rows/2)) + self._lcd_updating = True line1 = self._line1.ljust(self.cols, ' ') @@ -122,12 +124,12 @@ class LCD_HD44780(octoprint.plugin.StartupPlugin, message = line1 + line3 self._lcd_send_byte(self._lcd_line1, self._lcd_cmd) - for i in range(self.cols*self.rows/2): + for i in range(bytes_per_send_cycle): self._lcd_send_byte(ord(message[i]), self._lcd_chr) message = line2 + line4 self._lcd_send_byte(self._lcd_line2, self._lcd_cmd) - for i in range(self.cols*self.rows/2): + for i in range(bytes_per_send_cycle): self._lcd_send_byte(ord(message[i]), self._lcd_chr) self._lcd_updating = False