1515board .DISPLAY .brightness = 0.8
1616clue .pixel .fill (0 ) # turn off NeoPixel
1717
18- clue_display = displayio .Group (max_size = 4 )
18+ clue_display = displayio .Group ()
1919
2020# draw the dry plant
2121dry_plant_file = open ("dry.bmp" , "rb" )
2222dry_plant_bmp = displayio .OnDiskBitmap (dry_plant_file )
23- dry_plant_sprite = displayio .TileGrid (dry_plant_bmp , pixel_shader = displayio .ColorConverter ())
23+ # CircuitPython 6 & 7 compatible
24+ dry_plant_sprite = displayio .TileGrid (
25+ dry_plant_bmp ,
26+ pixel_shader = getattr (dry_plant_bmp , "pixel_shader" , displayio .ColorConverter ()),
27+ )
28+ # CircuitPython 7 compatible
29+ # dry_plant_sprite = displayio.TileGrid(
30+ # dry_plant_bmp, pixel_shader=dry_plant_bmp.pixel_shader
31+ # )
2432clue_display .append (dry_plant_sprite )
2533
2634# draw the happy plant on top (so it can be moved out of the way when needed)
2735happy_plant_file = open ("happy.bmp" , "rb" )
2836happy_plant_bmp = displayio .OnDiskBitmap (happy_plant_file )
29- happy_plant_sprite = displayio .TileGrid (happy_plant_bmp , pixel_shader = displayio .ColorConverter ())
37+ # CircuitPython 6 & 7 compatible
38+ happy_plant_sprite = displayio .TileGrid (
39+ happy_plant_bmp ,
40+ pixel_shader = getattr (happy_plant_bmp , "pixel_shader" , displayio .ColorConverter ()),
41+ )
42+ # CircuitPython 7 compatible
43+ # happy_plant_sprite = displayio.TileGrid(
44+ # happy_plant_bmp, pixel_shader=happy_plant_bmp.pixel_shader
45+ # )
3046clue_display .append (happy_plant_sprite )
3147
3248# Create text
3349# first create the group
34- text_group = displayio .Group (max_size = 3 , scale = 3 )
50+ text_group = displayio .Group (scale = 3 )
3551# Make a label
3652title_label = label .Label (terminalio .FONT , text = "CLUE Plant" , color = 0x00FF22 )
3753# Position the label
4561soil_label .y = 64
4662text_group .append (soil_label )
4763
48- motor_label = label .Label (terminalio .FONT , text = "Motor off" , color = 0xFF0000 , max_glyphs = 9 )
64+ motor_label = label .Label (
65+ terminalio .FONT , text = "Motor off" , color = 0xFF0000 , max_glyphs = 9
66+ )
4967motor_label .x = 4
5068motor_label .y = 74
5169text_group .append (motor_label )
6280sense_pin = board .P1
6381analog = AnalogIn (board .P1 )
6482
83+
6584def read_and_average (ain , times , wait ):
6685 asum = 0
6786 for _ in range (times ):
6887 asum += ain .value
6988 time .sleep (wait )
7089 return asum / times
7190
91+
7292time .sleep (5 )
7393
7494while True :
@@ -86,7 +106,7 @@ def read_and_average(ain, times, wait):
86106 motor .value = True
87107 motor_label .text = "Motor ON"
88108 motor_label .color = 0x00FF00
89- buzzer .duty_cycle = 2 ** 15
109+ buzzer .duty_cycle = 2 ** 15
90110 time .sleep (0.5 )
91111
92112 # always turn off quickly
0 commit comments