@@ -149,7 +149,7 @@ class SlideShow:
149
149
slideshow.brightness -= 0.001
150
150
"""
151
151
152
- def __init__ (self , display , backlight_pwm , * , folder = "/" , order = PlayBackOrder .ALPHABETICAL ,
152
+ def __init__ (self , display , backlight_pwm = None , * , folder = "/" , order = PlayBackOrder .ALPHABETICAL ,
153
153
loop = True , dwell = 3 , fade_effect = True , auto_advance = True ,
154
154
direction = PlayBackDirection .FORWARD ):
155
155
self .loop = loop
@@ -184,13 +184,17 @@ def __init__(self, display, backlight_pwm, *, folder="/", order=PlayBackOrder.AL
184
184
self ._current_image = - 1
185
185
self ._image_file = None
186
186
self ._brightness = 0.5
187
+ # 4.0.0 Beta 2 replaces Sprite with TileGrid so use either.
188
+ self ._sprite_class = getattr (displayio , "Sprite" , displayio .TileGrid )
187
189
188
190
# Setup the display
189
191
self ._group = displayio .Group ()
190
192
self ._display = display
191
193
display .show (self ._group )
192
194
193
195
self ._backlight_pwm = backlight_pwm
196
+ if not backlight_pwm and fade_effect :
197
+ self ._display .auto_brightness = False
194
198
195
199
# Show the first image
196
200
self .advance ()
@@ -221,8 +225,14 @@ def _reorder_images(self):
221
225
self ._file_list = sorted (self ._file_list , key = lambda x : random .random ())
222
226
223
227
def _set_backlight (self , brightness ):
224
- full_brightness = 2 ** 16 - 1
225
- self ._backlight_pwm .duty_cycle = int (full_brightness * brightness )
228
+ if self ._backlight_pwm :
229
+ full_brightness = 2 ** 16 - 1
230
+ self ._backlight_pwm .duty_cycle = int (full_brightness * brightness )
231
+ else :
232
+ try :
233
+ self ._display .brightness = brightness
234
+ except RuntimeError :
235
+ pass
226
236
227
237
@property
228
238
def brightness (self ):
@@ -303,7 +313,7 @@ def advance(self):
303
313
if not odb :
304
314
raise RuntimeError ("No valid images" )
305
315
306
- sprite = displayio . Sprite (odb , pixel_shader = displayio .ColorConverter (), position = (0 , 0 ))
316
+ sprite = self . _sprite_class (odb , pixel_shader = displayio .ColorConverter (), position = (0 , 0 ))
307
317
self ._group .append (sprite )
308
318
self ._display .wait_for_frame ()
309
319
0 commit comments