File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,10 @@ def print(self, value):
5151 :type value: str or int or float
5252
5353 """
54+ # Attempt to round off so we can still display the value
55+ if isinstance (value , float ) and len (str (value )) > 5 :
56+ value = round (value )
57+
5458 self ._segments .print (value )
5559 self ._segments .show ()
5660
@@ -97,8 +101,10 @@ def brightness(self):
97101 Brightness returns the current display brightness.
98102 0-15 = Dimmest to Brightest Setting
99103 """
100- return self ._segments .brightness
104+ return round ( self ._segments .brightness * 15 )
101105
102106 @brightness .setter
103107 def brightness (self , brightness ):
104- self ._segments .brightness = brightness
108+ if not 0 <= brightness <= 15 :
109+ raise ValueError ('Brightness must be a value between 0 and 15' )
110+ self ._segments .brightness = brightness / 15
Original file line number Diff line number Diff line change @@ -174,8 +174,10 @@ def brightness(self):
174174 Brightness returns the current display brightness.
175175 0-15 = Dimmest to Brightest Setting
176176 """
177- return self ._matrix .brightness
177+ return round ( self ._matrix .brightness * 15 )
178178
179179 @brightness .setter
180180 def brightness (self , brightness ):
181- self ._matrix .brightness = brightness
181+ if not 0 <= brightness <= 15 :
182+ raise ValueError ('Brightness must be a value between 0 and 15' )
183+ self ._matrix .brightness = brightness / 15
You can’t perform that action at this time.
0 commit comments