-
Notifications
You must be signed in to change notification settings - Fork 28
Add support for 1.2" 4-Digit 7-Segment Displays #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
1009122
8fe0f4c
d1e7c17
df0b5bc
e7e452d
8adfaee
debd029
30ba1db
5d25dc3
aff4185
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,7 +145,6 @@ | |
0x40, # - | ||
) | ||
|
||
|
||
class Seg14x4(HT16K33): | ||
"""Alpha-numeric, 14-segment display.""" | ||
def print(self, value): | ||
|
@@ -256,3 +255,50 @@ def _put(self, char, index=0): | |
else: | ||
return | ||
self._set_buffer(index, NUMBERS[character]) | ||
|
||
class BigSeg7x4(Seg7x4): | ||
"""Numeric 7-segment display. It has the same methods as the alphanumeric display, but only | ||
supports displaying a limited set of characters.""" | ||
def __init__(self, i2c, address=0x70, auto_write=True): | ||
super().__init__(i2c, address, auto_write) | ||
self.colon = Colon(self, 2) | ||
|
||
@property | ||
def ampm(self): | ||
"""The AM/PM indicator.""" | ||
return bool(self._get_buffer(0x04) & 0x10) | ||
|
||
@ampm.setter | ||
def ampm(self, value): | ||
current = self._get_buffer(0x04) | ||
if value: | ||
self._set_buffer(0x04, current | 0x10) | ||
else: | ||
self._set_buffer(0x04, current & ~0x10) | ||
if self._auto_write: | ||
self.show() | ||
|
||
#pylint: disable=W0212 | ||
class Colon(): | ||
"""Helper class for controlling the colons. Not intended for direct use.""" | ||
MASKS = (0x02, 0x0C) | ||
|
||
def __init__(self, disp, num_of_colons=1): | ||
self._disp = disp | ||
self._num_of_colons = num_of_colons | ||
|
||
def __setitem__(self, key, value): | ||
if key > self._num_of_colons - 1: | ||
raise ValueError("Trying to set a non-existent colon.") | ||
current = self._disp._get_buffer(0x04) | ||
if value: | ||
self._disp._set_buffer(0x04, current | self.MASKS[key]) | ||
else: | ||
self._disp._set_buffer(0x04, current & ~self.MASKS[key]) | ||
if self._disp.auto_write: | ||
self._disp.show() | ||
|
||
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]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest adding the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved it to inside the class. The disables apparently work at a code block level, so I think this should limit to with the class itself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We prefer you use the spelled out version of the disables. Please update this to reflect the error in that format. For example:
# pylint: disable=too-many-arguments
.