145
145
0x40 , # -
146
146
)
147
147
148
-
149
148
class Seg14x4 (HT16K33 ):
150
149
"""Alpha-numeric, 14-segment display."""
151
150
def print (self , value ):
@@ -262,10 +261,11 @@ class BigSeg7x4(Seg7x4):
262
261
supports displaying a limited set of characters."""
263
262
def __init__ (self , i2c , address = 0x70 , auto_write = True ):
264
263
super ().__init__ (i2c , address , auto_write )
264
+ self .colon = Colon (self , 2 )
265
265
266
266
@property
267
267
def ampm (self ):
268
- return (self ._get_buffer (0x04 ) & 0x10 ) >> 4
268
+ return bool (self ._get_buffer (0x04 ) & 0x10 )
269
269
270
270
@ampm .setter
271
271
def ampm (self , value ):
@@ -277,8 +277,34 @@ def ampm(self, value):
277
277
if self ._auto_write :
278
278
self .show ()
279
279
280
- def print (self , value ):
281
- ampm = self .ampm
282
- super ().print (value )
283
- if ampm :
284
- self .ampm = ampm
280
+ """need something like this to keep ampm indicator
281
+ and colons from being turned off with print?"""
282
+ # def print(self, value):
283
+ # ampm = self.ampm
284
+ # super().print(value)
285
+ # if ampm:
286
+ # self.ampm = ampm
287
+
288
+ class Colon ():
289
+ """Helper class for controlling the colons. Not intended for direct use."""
290
+ MASKS = (0x02 , 0x0C )
291
+
292
+ def __init__ (self , disp , num_of_colons = 1 ):
293
+ self ._disp = disp
294
+ self ._num_of_colons = num_of_colons
295
+
296
+ def __setitem__ (self , key , value ):
297
+ if key > self ._num_of_colons - 1 :
298
+ raise ValueError ("Trying to set a non-existant colon." )
299
+ current = self ._disp ._get_buffer (0x04 )
300
+ if value :
301
+ self ._disp ._set_buffer (0x04 , current | self .MASKS [key ])
302
+ else :
303
+ self ._disp ._set_buffer (0x04 , current & ~ self .MASKS [key ])
304
+ if self ._disp .auto_write :
305
+ self ._disp .show ()
306
+
307
+ def __getitem__ (self , key ):
308
+ if key > self ._num_of_colons - 1 :
309
+ raise ValueError ("Trying to access a non-existant colon." )
310
+ return bool (self ._disp ._get_buffer (0x04 ) & self .MASKS [key ])
0 commit comments