Skip to content

Commit 850a23c

Browse files
authored
Merge pull request #30 from makermelissa/flicker-fix
Fixed Flicker for Numbers when Autowrite is on
2 parents b7f233e + 3f204cb commit 850a23c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

adafruit_ht16k33/segments.py

100644100755
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ def print(self, value):
160160

161161
def __setitem__(self, key, value):
162162
self._put(value, key)
163+
if self._auto_write:
164+
self.show()
163165

164166
def scroll(self, count=1):
165167
"""Scroll the display by specified number of places."""
@@ -182,8 +184,6 @@ def _put(self, char, index=0):
182184
character = ord(char) * 2 - 64
183185
self._set_buffer(index * 2, CHARS[1 + character])
184186
self._set_buffer(index * 2 + 1, CHARS[character])
185-
if self._auto_write:
186-
self.show()
187187

188188
def _push(self, char):
189189
"""Scroll the display and add a character at the end."""
@@ -199,6 +199,8 @@ def _text(self, text):
199199

200200
def _number(self, number):
201201
"""Display the specified decimal number."""
202+
auto_write = self._auto_write
203+
self._auto_write = False
202204
string = "{}".format(number)
203205
if len(string) > 4:
204206
if string.find('.') > 4:
@@ -208,6 +210,7 @@ def _number(self, number):
208210
if '.' in string:
209211
places += 1
210212
self._text(string[:places])
213+
self._auto_write = auto_write
211214

212215
class Seg7x4(Seg14x4):
213216
"""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):
257260
else:
258261
return
259262
self._set_buffer(index, NUMBERS[character])
260-
if self._auto_write:
261-
self.show()
262263

263264
class BigSeg7x4(Seg7x4):
264265
"""Numeric 7-segment display. It has the same methods as the alphanumeric display, but only

0 commit comments

Comments
 (0)