Skip to content

Commit d1e7c17

Browse files
author
caternuson
committed
added AM/PM indicator control
1 parent 775c44e commit d1e7c17

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

adafruit_ht16k33/segments.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,29 @@ def _put(self, char, index=0):
256256
else:
257257
return
258258
self._set_buffer(index, NUMBERS[character])
259+
260+
class BigSeg7x4(Seg7x4):
261+
"""Numeric 7-segment display. It has the same methods as the alphanumeric display, but only
262+
supports displaying a limited set of characters."""
263+
def __init__(self, i2c, address=0x70, auto_write=True):
264+
super().__init__(i2c, address, auto_write)
265+
266+
@property
267+
def ampm(self):
268+
return (self._get_buffer(0x04) & 0x10) >> 4
269+
270+
@ampm.setter
271+
def ampm(self, value):
272+
current = self._get_buffer(0x04)
273+
if value:
274+
self._set_buffer(0x04, current | 0x10)
275+
else:
276+
self._set_buffer(0x04, current & ~0x10)
277+
if self._auto_write:
278+
self.show()
279+
280+
def print(self, value):
281+
ampm = self.ampm
282+
super().print(value)
283+
if ampm:
284+
self.ampm = ampm

0 commit comments

Comments
 (0)