@@ -44,7 +44,7 @@ def update_score_text():
4444 Update the score text on the display for each player
4545 """
4646 for _ in range (2 ):
47- out_str = f"p{ _ + 1 } score: { player_scores [_ ]} "
47+ out_str = f"p{ _ + 1 } score: { player_scores [_ ]} "
4848 score_lbls [_ ].text = out_str
4949
5050
@@ -62,7 +62,7 @@ def update_score_text():
6262# initial state is title screen
6363CUR_STATE = STATE_TITLE
6464
65- request_display_config (320 ,240 )
65+ request_display_config (320 , 240 )
6666display = supervisor .runtime .display
6767
6868# main group will hold all the visual elements
@@ -304,13 +304,15 @@ def update_score_text():
304304 device , 0
305305 )
306306
307- _possible_interface_index , _possible_endpoint_address = adafruit_usb_host_descriptors .find_boot_mouse_endpoint (
308- device )
307+ _possible_interface_index , _possible_endpoint_address = (
308+ adafruit_usb_host_descriptors .find_boot_mouse_endpoint (device ))
309+
309310 if _possible_interface_index is not None and _possible_endpoint_address is not None :
310311 mouse = device
311312 mouse_interface_index = _possible_interface_index
312313 mouse_endpoint_address = _possible_endpoint_address
313- print (f"mouse interface: { mouse_interface_index } endpoint_address: { hex (mouse_endpoint_address )} " )
314+ print (f"mouse interface: { mouse_interface_index } " , end = "" )
315+ print (f"endpoint_address: { hex (mouse_endpoint_address )} " )
314316
315317mouse_was_attached = None
316318if mouse is not None :
@@ -324,6 +326,7 @@ def update_score_text():
324326 # set configuration on the mouse so we can use it
325327 mouse .set_configuration ()
326328
329+
327330def atexit_callback ():
328331 """
329332 re-attach USB devices to kernel if needed.
@@ -333,6 +336,7 @@ def atexit_callback():
333336 if mouse_was_attached and not mouse .is_kernel_driver_active (0 ):
334337 mouse .attach_kernel_driver (0 )
335338
339+
336340atexit .register (atexit_callback )
337341
338342# Buffer to hold data read from the mouse
@@ -396,8 +400,8 @@ def atexit_callback():
396400
397401 # if both cards were the same i.e. they found a match
398402 if (
399- card_tgs [cards_flipped_this_turn [0 ]][0 ]
400- == card_tgs [cards_flipped_this_turn [1 ]][0 ]
403+ card_tgs [cards_flipped_this_turn [0 ]][0 ]
404+ == card_tgs [cards_flipped_this_turn [1 ]][0 ]
401405 ):
402406
403407 # set the cards tile index to show a blank spot instead of a card
@@ -414,8 +418,8 @@ def atexit_callback():
414418 # of cards then the code knows the game is over because each pair is worth 1
415419 # point
416420 if (
417- player_scores [0 ] + player_scores [1 ]
418- >= (grid_size [0 ] * grid_size [1 ]) // 2
421+ player_scores [0 ] + player_scores [1 ]
422+ >= (grid_size [0 ] * grid_size [1 ]) // 2
419423 ):
420424
421425 # if the player's scores are equal
@@ -498,7 +502,8 @@ def atexit_callback():
498502 # button bounding box
499503 if play_again_btn .contains (coords ):
500504 # set next code file to this one
501- supervisor .set_next_code_file (__file__ , working_directory = Path (__file__ ).parent .absolute ())
505+ supervisor .set_next_code_file (__file__ ,
506+ working_directory = Path (__file__ ).parent .absolute ())
502507 # reload
503508 supervisor .reload ()
504509
0 commit comments