2323import audioio
2424import audiocore
2525import neopixel
26- # import busio
2726# import adafruit_lis3dh
2827
2928#-------------------------------------------------------------------------------
3534touch_1 = touchio .TouchIn (board .TOUCH1 )
3635touch_4 = touchio .TouchIn (board .TOUCH4 )
3736
38- audio = audioio .AudioOut (board .A0 )
37+ audio = audioio .AudioOut (board .SPEAKER )
3938
4039backlight = digitalio .DigitalInOut (board .TFT_BACKLIGHT )
4140backlight .direction = digitalio .Direction .OUTPUT
5150pixels .show ()
5251
5352# setup accelerometer
54- # i2c = busio .I2C(board.SCL, board.SDA )
53+ # i2c = board .I2C()
5554# lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c)
5655
5756
@@ -71,9 +70,18 @@ def play_wave(filename):
7170# Display an image on the HalloWing TFT screen
7271
7372def show_image (filename ):
73+ # CircuitPython 6 & 7 compatible
7474 image_file = open (filename , "rb" )
7575 odb = displayio .OnDiskBitmap (image_file )
76- face = displayio .Sprite (odb , pixel_shader = displayio .ColorConverter (), position = (0 , 0 ))
76+ face = displayio .TileGrid (
77+ odb ,
78+ pixel_shader = getattr (odb , 'pixel_shader' , displayio .ColorConverter ())
79+ )
80+
81+ # # CircuitPython 7+ compatible
82+ # odb = displayio.OnDiskBitmap(filename)
83+ # face = displayio.TileGrid(odb, pixel_shader=odb.pixel_shader)
84+
7785 backlight .value = False
7886 splash .append (face )
7987 try :
@@ -92,13 +100,13 @@ def random_colour():
92100# Set 6 random pixels to random colours.
93101# Keep track of which are lit so they can be turned off next time
94102
95- twinkle_indecies = [0 ,0 , 0 , 0 , 0 , 0 ]
103+ twinkle_indices = [0 , 0 , 0 , 0 , 0 , 0 ]
96104
97105def twinkle ():
98106 for p in range (6 ):
99- pixels [twinkle_indecies [p ]] = (0 ,0 , 0 )
100- twinkle_indecies [p ] = randrange (len (pixels ))
101- pixels [twinkle_indecies [p ]] = random_colour ()
107+ pixels [twinkle_indices [p ]] = (0 , 0 , 0 )
108+ twinkle_indices [p ] = randrange (len (pixels ))
109+ pixels [twinkle_indices [p ]] = random_colour ()
102110 pixels .show ()
103111
104112
0 commit comments