From 868b3430cb929d03f9c1adfd9ce2c0771374cb09 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Tue, 29 Jan 2019 15:10:01 -0800 Subject: [PATCH 1/3] Fixed flicker for printing numbers --- adafruit_ht16k33/segments.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) mode change 100644 => 100755 adafruit_ht16k33/segments.py diff --git a/adafruit_ht16k33/segments.py b/adafruit_ht16k33/segments.py old mode 100644 new mode 100755 index b2dc03e..c9a74a4 --- a/adafruit_ht16k33/segments.py +++ b/adafruit_ht16k33/segments.py @@ -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 @@ -306,4 +309,4 @@ def __setitem__(self, key, value): def __getitem__(self, key): if key > self._num_of_colons - 1: raise ValueError("Trying to access a non-existent colon.") - return bool(self._disp._get_buffer(0x04) & self.MASKS[key]) + return bool(self._disp._get_buffer(0x04) & self.MASKS[key]) \ No newline at end of file From e0c52f117353f28cf9ae2ef7b18ae9b7176dd51d Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Tue, 29 Jan 2019 15:14:05 -0800 Subject: [PATCH 2/3] Added final newline --- adafruit_ht16k33/segments.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_ht16k33/segments.py b/adafruit_ht16k33/segments.py index c9a74a4..0b5e5dd 100755 --- a/adafruit_ht16k33/segments.py +++ b/adafruit_ht16k33/segments.py @@ -309,4 +309,4 @@ def __setitem__(self, key, value): def __getitem__(self, key): if key > self._num_of_colons - 1: raise ValueError("Trying to access a non-existent colon.") - return bool(self._disp._get_buffer(0x04) & self.MASKS[key]) \ No newline at end of file + return bool(self._disp._get_buffer(0x04) & self.MASKS[key]) From 3f204cb5ac1654ad19b3a4613644087451d503ab Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Tue, 29 Jan 2019 17:21:09 -0800 Subject: [PATCH 3/3] Fixed text flickering as well --- adafruit_ht16k33/segments.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/adafruit_ht16k33/segments.py b/adafruit_ht16k33/segments.py index 0b5e5dd..0d2fc45 100755 --- 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.""" @@ -260,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