2828
2929NUM_PIXELS = 72 # LED strip length
3030PIXEL_PINS = board .SDA , board .SCL # Data, clock pins for DotStars
31- PIXEL_ORDER = 'brg' # Pixel color order
32- PATH = '/bmps-72px' # Folder containing BMP images (or '' for root path)
33- TEMPFILE = '/led.dat' # Working file for LED data (will be clobbered!)
34- FLIP_SCREEN = False # If True, turn CLUE screen & buttons upside-down
35- GAMMA = 2.4 # Correction factor for perceptually linear brightness
31+ PIXEL_ORDER = 'bgr' # Pixel color order
32+ PATH = '/bmps-72px' # Folder with BMP images (or '' for root path)
33+ TEMPFILE = '/led.dat' # Working file for LED data (will be clobbered!)
34+ FLIP_SCREEN = False # If True, turn CLUE screen & buttons upside-down
35+ GAMMA = 2.4 # Correction for perceptually linear brightness
36+ BRIGHTNESS_RANGE = 0.15 , 0.75 # Min, max brightness (0.0-1.0)
3637TIMES = ['1/8' , '1/4' , '1/3' , '1/2' , '2/3' , '1' , '1.5' , '2' , '3' , '4' ]
3738TIMES .sort (key = eval ) # Ensure times are shortest-to-longest
3839
3940# Temporary line during development, delete before use:
40- PIXEL_ORDER = 'gbr' # Old DotStar strip with different color order
41+ # PIXEL_ORDER = 'gbr' # Old DotStar strip with different color order
4142
4243
4344def centered_label (text , y_pos , scale ):
@@ -63,25 +64,33 @@ class ClueLightPainter:
6364
6465 # pylint: disable=too-many-arguments
6566 def __init__ (self , flip , path , tempfile , num_pixels , pixel_order ,
66- pixel_pins , gamma ):
67+ pixel_pins , gamma , brightness ):
6768 """
6869 App constructor. Follow up with a call to ClueLightPainter.run().
6970 Arguments:
70- flip (boolean) : If True, CLUE display and buttons are
71- flipped 180 degrees from normal (makes
72- wiring easier in some situations).
73- path (string) : Directory containing BMP images.
74- tempfile (string) : Full path/filename of temporary working
75- file for LED data (will be clobbered).
76- num_pixels (int) : LED strip length.
77- pixel_order (string) : LED data order, e.g. 'grb'.
78- pixel_pins (tuple) : Board pin for LED data output (SPI data
79- and clock pins respectively).
80- gamma (float) : Correction for perceptual linearity.
71+ flip (boolean) : If True, CLUE display and buttons are
72+ flipped 180 degrees from normal (makes
73+ wiring easier in some situations).
74+ path (string) : Directory containing BMP images.
75+ tempfile (string) : Full path/filename of temporary working
76+ file for LED data (will be clobbered).
77+ num_pixels (int) : LED strip length.
78+ pixel_order (string) : LED data order, e.g. 'grb'.
79+ pixel_pins (tuple) : Board pin for LED data output (SPI data
80+ and clock pins respectively).
81+ gamma (float) : Correction for perceptual linearity.
82+ brightness (2 floats) : Minimum and maximum LED brightness
83+ settings, each 0.0 (off) to 1.0 (full
84+ brightness). Too-low brightness levels
85+ just don't photograph well. Too-high
86+ levels may draw more current than the
87+ battery can provide, board may lock up
88+ and may even need CircuitPython re-flash.
8189 """
8290 self .bmp2led = BMP2LED (num_pixels , pixel_order , gamma )
8391 self .path = path
8492 self .tempfile = tempfile
93+ self .brightness_range = brightness
8594
8695 # The SPI peripheral is locked and config'd once here and never
8796 # relinquished, to save some time on every row (need them issued
@@ -204,8 +213,9 @@ def load_image(self):
204213 # The 0.9 here is an empirical guesstimate; playback is ever-so-
205214 # slightly slower than benchmark speed due to button testing.
206215 rows = int (duration * self .rows_per_second * 0.9 + 0.5 )
207- # Remap brightness from 0.0-1.0 to 15-100%
208- brightness = 0.15 + self .brightness * 0.85
216+ # Remap brightness from 0.0-1.0 to brightness_range.
217+ brightness = (self .brightness_range [0 ] + self .brightness *
218+ (self .brightness_range [1 ] - self .brightness_range [0 ]))
209219 try :
210220 self .num_rows = self .bmp2led .process (self .path + '/' +
211221 self .images [self .image_num ],
@@ -507,4 +517,5 @@ def run(self):
507517
508518
509519ClueLightPainter (FLIP_SCREEN , PATH , TEMPFILE ,
510- NUM_PIXELS , PIXEL_ORDER , PIXEL_PINS , GAMMA ).run ()
520+ NUM_PIXELS , PIXEL_ORDER , PIXEL_PINS , GAMMA ,
521+ BRIGHTNESS_RANGE ).run ()
0 commit comments