71
71
_NVM_RESOLUTION = const (1 )
72
72
_NVM_EFFECT = const (2 )
73
73
_NVM_MODE = const (3 )
74
+ _NVM_TIMELAPSE_RATE = const (4 )
74
75
75
76
76
77
class PyCameraBase : # pylint: disable=too-many-instance-attributes,too-many-public-methods
@@ -168,7 +169,25 @@ class PyCameraBase: # pylint: disable=too-many-instance-attributes,too-many-pub
168
169
"Sepia" ,
169
170
"Solarize" ,
170
171
)
171
- modes = ("JPEG" , "GIF" , "GBOY" , "STOP" )
172
+
173
+ timelapse_rates = (
174
+ 5 ,
175
+ 10 ,
176
+ 20 ,
177
+ 30 ,
178
+ 60 ,
179
+ 90 ,
180
+ 60 * 2 ,
181
+ 60 * 3 ,
182
+ 60 * 4 ,
183
+ 60 * 5 ,
184
+ 60 * 10 ,
185
+ 60 * 15 ,
186
+ 60 * 30 ,
187
+ 60 * 60
188
+ )
189
+
190
+ modes = ("JPEG" , "GIF" , "GBOY" , "STOP" , "LAPS" )
172
191
173
192
_INIT_SEQUENCE = (
174
193
b"\x01 \x80 \x78 " # _SWRESET and Delay 120ms
@@ -249,13 +268,13 @@ def make_debounced_expander_pin(pin_no):
249
268
def make_camera_ui (self ):
250
269
"""Create displayio widgets for the standard camera UI"""
251
270
self ._sd_label = label .Label (
252
- terminalio .FONT , text = "SD ??" , color = 0x0 , x = 150 , y = 10 , scale = 2
271
+ terminalio .FONT , text = "SD ??" , color = 0x0 , x = 170 , y = 10 , scale = 2
253
272
)
254
273
self ._effect_label = label .Label (
255
274
terminalio .FONT , text = "EFFECT" , color = 0xFFFFFF , x = 4 , y = 10 , scale = 2
256
275
)
257
276
self ._mode_label = label .Label (
258
- terminalio .FONT , text = "MODE" , color = 0xFFFFFF , x = 150 , y = 10 , scale = 2
277
+ terminalio .FONT , text = "MODE" , color = 0xFFFFFF , x = 170 , y = 10 , scale = 2
259
278
)
260
279
self ._topbar = displayio .Group ()
261
280
self ._res_label = label .Label (
@@ -268,8 +287,19 @@ def make_camera_ui(self):
268
287
self ._botbar .append (self ._effect_label )
269
288
self ._botbar .append (self ._mode_label )
270
289
290
+ self ._timelapsebar = displayio .Group (x = 0 , y = 180 )
291
+ self ._timelapse_rate_label = label .Label (
292
+ terminalio .FONT , text = "Time" , color = 0xFFFFFF , x = 150 , y = 10 , scale = 2
293
+ )
294
+ self ._timelapsestatus_label = label .Label (
295
+ terminalio .FONT , text = "Status" , color = 0xFFFFFF , x = 0 , y = 10 , scale = 2
296
+ )
297
+ self ._timelapsebar .append (self ._timelapse_rate_label )
298
+ self ._timelapsebar .append (self ._timelapsestatus_label )
299
+
271
300
self .splash .append (self ._topbar )
272
301
self .splash .append (self ._botbar )
302
+ self .splash .append (self ._timelapsebar )
273
303
274
304
def init_accelerometer (self ):
275
305
"""Initialize the accelerometer"""
@@ -338,6 +368,7 @@ def init_camera(self, init_autofocus=True) -> None:
338
368
self .camera .saturation = 3
339
369
self .resolution = microcontroller .nvm [_NVM_RESOLUTION ]
340
370
self .mode = microcontroller .nvm [_NVM_MODE ]
371
+ self .timelapse_rate = microcontroller .nvm [_NVM_TIMELAPSE_RATE ]
341
372
342
373
if init_autofocus :
343
374
self .autofocus_init ()
@@ -461,6 +492,9 @@ def select_setting(self, setting_name):
461
492
self ._res_label .text = self .resolutions [self ._resolution ]
462
493
self ._mode_label .color = 0xFFFFFF
463
494
self ._mode_label .background_color = 0x0
495
+ self ._timelapse_rate_label .color = 0xFFFFFF
496
+ self ._timelapse_rate_label .background_color = 0x0
497
+
464
498
if setting_name == "effect" :
465
499
self ._effect_label .color = 0x0
466
500
self ._effect_label .background_color = 0xFFFFFF
@@ -478,6 +512,13 @@ def select_setting(self, setting_name):
478
512
self ._res_label .text = "LED CLR"
479
513
self ._res_label .color = 0x0
480
514
self ._res_label .background_color = 0xFFFFFF
515
+ elif setting_name == "led_color" :
516
+ self ._res_label .text = "LED CLR"
517
+ self ._res_label .color = 0x0
518
+ self ._res_label .background_color = 0xFFFFFF
519
+ elif setting_name == "timelapse_rate" :
520
+ self ._timelapse_rate_label .color = 0x0
521
+ self ._timelapse_rate_label .background_color = 0xFFFFFF
481
522
self .display .refresh ()
482
523
483
524
@property
@@ -538,6 +579,24 @@ def resolution(self, res):
538
579
self ._res_label .text = self .resolutions [res ]
539
580
self .display .refresh ()
540
581
582
+
583
+ @property
584
+ def timelapse_rate (self ):
585
+ """Get or set the amount of time between timelapse shots"""
586
+ return self ._timelapse_rate
587
+
588
+ @timelapse_rate .setter
589
+ def timelapse_rate (self , setting ):
590
+ setting = (setting + len (self .timelapse_rates )) % len (self .timelapse_rates )
591
+ self ._timelapse_rate = setting
592
+ if self .timelapse_rates [setting ] < 60 :
593
+ self ._timelapse_rate_label .text = "%d S" % self .timelapse_rates [setting ]
594
+ else :
595
+ self ._timelapse_rate_label .text = "%d M" % (self .timelapse_rates [setting ] / 60 )
596
+ microcontroller .nvm [_NVM_TIMELAPSE_RATE ] = setting
597
+ self .display .refresh ()
598
+
599
+
541
600
def init_display (self ):
542
601
"""Initialize the TFT display"""
543
602
# construct displayio by hand
0 commit comments