@@ -159,8 +159,6 @@ class PyCamera: # pylint: disable=too-many-instance-attributes,too-many-public-
159159 # espcamera.FrameSize.P_FHD, # 1080x1920
160160 espcamera .FrameSize .QSXGA , # 2560x1920
161161 )
162- combined_list = list (zip (resolutions , resolution_to_frame_size ))
163- print (combined_list )
164162
165163 effects = (
166164 "Normal" ,
@@ -172,7 +170,7 @@ class PyCamera: # pylint: disable=too-many-instance-attributes,too-many-public-
172170 "Sepia" ,
173171 "Solarize" ,
174172 )
175- modes = ("JPEG" , "GIF" , "STOP" )
173+ modes = ("JPEG" , "GIF" , "GBOY" , " STOP" )
176174
177175 _INIT_SEQUENCE = (
178176 b"\x01 \x80 \x78 " # _SWRESET and Delay 120ms
@@ -451,7 +449,10 @@ def select_setting(self, setting_name):
451449 self ._effect_label .background_color = 0x0
452450 self ._res_label .color = 0xFFFFFF
453451 self ._res_label .background_color = 0x0
454- self ._res_label .text = self .resolutions [self ._resolution ]
452+ if self .mode_text in ("GIF" , "GBOY" ):
453+ self ._res_label .text = ""
454+ else :
455+ self ._res_label .text = self .resolutions [self ._resolution ]
455456 self ._mode_label .color = 0xFFFFFF
456457 self ._mode_label .background_color = 0x0
457458 if setting_name == "effect" :
@@ -490,7 +491,7 @@ def mode(self, setting):
490491 self ._mode_label .text = self .modes [setting ]
491492 if self .modes [setting ] == "STOP" :
492493 self .stop_motion_frame = 0
493- if self .modes [setting ] == "GIF" :
494+ if self .modes [setting ] in ( "GIF" , "GBOY" ) :
494495 self ._res_label .text = ""
495496 else :
496497 self .resolution = self .resolution # kick it to reset the display
@@ -531,15 +532,15 @@ def resolution(self, res):
531532 self ._res_label .text = self .resolutions [res ]
532533 self .display .refresh ()
533534
534- def init_display (self ):
535+ def init_display (self , reset = True ):
535536 """Initialize the TFT display"""
536537 # construct displayio by hand
537538 displayio .release_displays ()
538539 self ._display_bus = displayio .FourWire (
539540 self ._spi ,
540541 command = board .TFT_DC ,
541542 chip_select = board .TFT_CS ,
542- reset = board .TFT_RESET ,
543+ reset = board .TFT_RESET if reset else None ,
543544 baudrate = 60_000_000 ,
544545 )
545546 self .display = board .DISPLAY
@@ -567,7 +568,7 @@ def display_message(self, message, color=0xFF0000, scale=3):
567568 text_area = label .Label (terminalio .FONT , text = message , color = color , scale = scale )
568569 text_area .anchor_point = (0.5 , 0.5 )
569570 if not self .display :
570- self .init_display ()
571+ self .init_display (None )
571572 text_area .anchored_position = (self .display .width / 2 , self .display .height / 2 )
572573
573574 # Show it
@@ -587,7 +588,9 @@ def mount_sd_card(self):
587588 self ._card_power .value = True
588589 card_cs = DigitalInOut (board .CARD_CS )
589590 card_cs .switch_to_output (False )
590- # deinit display and SPI
591+ # deinit display and SPI bus because we need to drive all SD pins LOW
592+ # to ensure nothing, not even an I/O pin, could possibly power the SD
593+ # card
591594 self .deinit_display ()
592595 self ._spi .deinit ()
593596 sckpin = DigitalInOut (board .SCK )
@@ -611,7 +614,7 @@ def mount_sd_card(self):
611614 vfs = storage .VfsFat (self .sdcard )
612615 print ("mount vfs @" , time .monotonic () - self ._timestamp )
613616 storage .mount (vfs , "/sd" )
614- self .init_display ()
617+ self .init_display (None )
615618 self ._image_counter = 0
616619 self ._sd_label .text = "SD OK"
617620 self ._sd_label .color = 0x00FF00
0 commit comments