diff --git a/adafruit_ht16k33/segments.py b/adafruit_ht16k33/segments.py old mode 100644 new mode 100755 index b2dc03e..0d2fc45 --- a/adafruit_ht16k33/segments.py +++ b/adafruit_ht16k33/segments.py @@ -160,6 +160,8 @@ def print(self, value): def __setitem__(self, key, value): self._put(value, key) + if self._auto_write: + self.show() def scroll(self, count=1): """Scroll the display by specified number of places.""" @@ -182,8 +184,6 @@ def _put(self, char, index=0): character = ord(char) * 2 - 64 self._set_buffer(index * 2, CHARS[1 + character]) self._set_buffer(index * 2 + 1, CHARS[character]) - if self._auto_write: - self.show() def _push(self, char): """Scroll the display and add a character at the end.""" @@ -199,6 +199,8 @@ def _text(self, text): def _number(self, number): """Display the specified decimal number.""" + auto_write = self._auto_write + self._auto_write = False string = "{}".format(number) if len(string) > 4: if string.find('.') > 4: @@ -208,6 +210,7 @@ def _number(self, number): if '.' in string: places += 1 self._text(string[:places]) + self._auto_write = auto_write class Seg7x4(Seg14x4): """Numeric 7-segment display. It has the same methods as the alphanumeric display, but only @@ -257,8 +260,6 @@ def _put(self, char, index=0): else: return self._set_buffer(index, NUMBERS[character]) - if self._auto_write: - self.show() class BigSeg7x4(Seg7x4): """Numeric 7-segment display. It has the same methods as the alphanumeric display, but only