Skip to content

Commit 98fa081

Browse files
committed
Merge branch 'main' into pixel_shader_fix
# Conflicts: # Buckaroo_Plant_Care_Bot/buckaroo_plant_care_bot.py
2 parents 7c8e7d2 + afa7683 commit 98fa081

File tree

39 files changed

+1628
-267
lines changed

39 files changed

+1628
-267
lines changed

Baudot_TTY/baudot_tty_GUI.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727

2828
clue.display.brightness = 1.0
29-
screen = displayio.Group(max_size=5)
29+
screen = displayio.Group()
3030

3131
VFD_GREEN = 0x00FFD2
3232
VFD_BG = 0x000505
@@ -65,11 +65,13 @@
6565

6666
messages_labels = {} # dictionary of configured messages_labels
6767

68-
message_group = displayio.Group(max_size=5, scale=1)
68+
message_group = displayio.Group(scale=1)
6969

7070
for message_config in messages_config:
7171
(name, textline, color, x, y) = message_config # unpack tuple into five var names
72-
message_label = label.Label(terminalio.FONT, text=textline, color=color, max_glyphs=50)
72+
message_label = label.Label(
73+
terminalio.FONT, text=textline, color=color, max_glyphs=50
74+
)
7375
message_label.x = x
7476
message_label.y = y
7577
messages_labels[name] = message_label

Baudot_TTY/baudot_tty_ble.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
ble = BLERadio()
2020
uart_server = UARTService()
2121
advertisement = ProvideServicesAdvertisement(uart_server)
22-
ble._adapter.name = "TTY_MACHINE" # pylint: disable=protected-access
22+
ble._adapter.name = "TTY_MACHINE" # pylint: disable=protected-access
2323

2424
# constants for sine wave generation
2525
SIN_LENGTH = 100 # more is less choppy
@@ -148,7 +148,8 @@ def baudot_bit(pitch=bit_1, duration=0.022): # spec says 20ms, but adjusted as
148148
# dac.stop()
149149

150150

151-
def baudot_carrier(duration=0.15): # Carrier is transmitted 150 ms before first character is sent
151+
def baudot_carrier(duration=0.15):
152+
# Carrier is transmitted 150 ms before first character is sent
152153
baudot_bit(carrier, duration)
153154
dac.stop()
154155

Buckaroo_Plant_Care_Bot/buckaroo_plant_care_bot.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,39 @@
1515
board.DISPLAY.brightness = 0.8
1616
clue.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
2121
dry_plant_file = open("dry.bmp", "rb")
2222
dry_plant_bmp = displayio.OnDiskBitmap(dry_plant_file)
23-
dry_plant_sprite = displayio.TileGrid(dry_plant_bmp, pixel_shader=getattr(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+
# )
2432
clue_display.append(dry_plant_sprite)
2533

2634
# draw the happy plant on top (so it can be moved out of the way when needed)
2735
happy_plant_file = open("happy.bmp", "rb")
2836
happy_plant_bmp = displayio.OnDiskBitmap(happy_plant_file)
29-
happy_plant_sprite = displayio.TileGrid(happy_plant_bmp, pixel_shader=getattr(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+
# )
3046
clue_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
3652
title_label = label.Label(terminalio.FONT, text="CLUE Plant", color=0x00FF22)
3753
# Position the label
@@ -45,7 +61,9 @@
4561
soil_label.y = 64
4662
text_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+
)
4967
motor_label.x = 4
5068
motor_label.y = 74
5169
text_group.append(motor_label)
@@ -62,13 +80,15 @@
6280
sense_pin = board.P1
6381
analog = AnalogIn(board.P1)
6482

83+
6584
def 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+
7292
time.sleep(5)
7393

7494
while 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

CircuitPython_Display_Text/background_color_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
display = board.DISPLAY
1414

1515
# Make the display context
16-
main_group = displayio.Group(max_size=10)
16+
main_group = displayio.Group()
1717
display.show(main_group)
1818

1919
reg_label = label.Label(

CircuitPython_Display_Text/background_tight_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
display = board.DISPLAY
1515

1616
# Make the display context
17-
main_group = displayio.Group(max_size=10)
17+
main_group = displayio.Group()
1818
display.show(main_group)
1919

2020
font = bitmap_font.load_font("fonts/Fayette-HandwrittenScript-48.bdf")

CircuitPython_Display_Text/base_alignment_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
display = board.DISPLAY
1515

1616
# Make the display context
17-
main_group = displayio.Group(max_size=10)
17+
main_group = displayio.Group()
1818
display.show(main_group)
1919

2020

CircuitPython_Display_Text/color_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
display = board.DISPLAY
1414

1515
# Make the display context
16-
main_group = displayio.Group(max_size=10)
16+
main_group = displayio.Group()
1717
display.show(main_group)
1818

1919
reg_label = label.Label(

CircuitPython_Display_Text/colormask_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def wheel(pos):
3434
bg_palette[0] = 0xDDDD00
3535

3636
# Make the display context
37-
main_group = displayio.Group(max_size=10)
37+
main_group = displayio.Group()
3838
display.show(main_group)
3939

4040
font = bitmap_font.load_font("fonts/LeagueSpartan-Bold-16.bdf")

CircuitPython_Display_Text/display_text_anchored_position.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
display = board.DISPLAY
1515

1616
# Make the display context
17-
main_group = displayio.Group(max_size=10)
17+
main_group = displayio.Group()
1818
display.show(main_group)
1919
DISPLAY_WIDTH = 320
2020
DISPLAY_HEIGHT = 240
@@ -64,7 +64,7 @@
6464
text_area_bottom_right.anchor_point = (1.0, 1.0)
6565
text_area_bottom_right.anchored_position = (DISPLAY_WIDTH - 8, DISPLAY_HEIGHT - 8)
6666

67-
text_group = displayio.Group(max_size=9)
67+
text_group = displayio.Group()
6868
text_group.append(text_area_top_middle)
6969
text_group.append(text_area_top_left)
7070
text_group.append(text_area_top_right)

CircuitPython_Display_Text/font_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
display = board.DISPLAY
1616

1717
# Make the display context
18-
main_group = displayio.Group(max_size=10)
18+
main_group = displayio.Group()
1919
display.show(main_group)
2020

2121
font = bitmap_font.load_font("fonts/LeagueSpartan-Bold-16.bdf")

CircuitPython_Display_Text/line_spacing_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
display = board.DISPLAY
1414

1515
# Make the display context
16-
main_group = displayio.Group(max_size=10)
16+
main_group = displayio.Group()
1717
display.show(main_group)
1818

1919
# font = bitmap_font.load_font("Fayette-HandwrittenScript-48.bdf")

CircuitPython_Display_Text/padding_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
display = board.DISPLAY
1414

1515
# Make the display context
16-
main_group = displayio.Group(max_size=10)
16+
main_group = displayio.Group()
1717
display.show(main_group)
1818

1919
# font = bitmap_font.load_font("Fayette-HandwrittenScript-48.bdf")

CircuitPython_Display_Text/scale_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
display = board.DISPLAY
1515

1616
# Make the display context
17-
main_group = displayio.Group(max_size=10)
17+
main_group = displayio.Group()
1818
display.show(main_group)
1919

2020
font = terminalio.FONT

CircuitPython_Flying_Toasters/code.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
Licensed under the MIT license.
1212
1313
All text above must be included in any redistribution.
14-
15-
Requires CircuitPython 5.0 or later.
1614
"""
1715

1816
import time
@@ -37,42 +35,38 @@
3735

3836
FIRST_CELL = CELL_1
3937
LAST_CELL = CELL_4
40-
4138
NUMBER_OF_CELLS = (LAST_CELL - FIRST_CELL) + 1
4239

4340
# A boolean array corresponding to the sprites, True if it's part of the animation sequence.
44-
ANIMATED = [_sprite >= FIRST_CELL and _sprite <= LAST_CELL for _sprite in range(NUMBER_OF_SPRITES)]
45-
41+
ANIMATED = [FIRST_CELL <= _sprite <= LAST_CELL for _sprite in range(NUMBER_OF_SPRITES)]
4642

4743
# The chance (out of 10) that toast will enter
4844
CHANCE_OF_NEW_TOAST = 2
4945

50-
# How many sprites to styart with
46+
# How many sprites to start with
5147
INITIAL_NUMBER_OF_SPRITES = 4
5248

53-
# Global variables
54-
display = None
55-
tilegrid = None
56-
5749
seed(int(time.monotonic()))
5850

51+
5952
def make_display():
6053
"""Set up the display support.
6154
Return the Display object.
6255
"""
6356
spi = board.SPI()
6457
while not spi.try_lock():
6558
pass
66-
spi.configure(baudrate=24000000) # Configure SPI for 24MHz
59+
spi.configure(baudrate=24000000) # Configure SPI for 24MHz
6760
spi.unlock()
6861
displayio.release_displays()
6962
display_bus = displayio.FourWire(spi, command=board.D7, chip_select=board.D10, reset=board.D9)
7063

7164
return ST7789(display_bus, width=240, height=240, rowstart=80, auto_refresh=True)
7265

66+
7367
def make_tilegrid():
7468
"""Construct and return the tilegrid."""
75-
group = displayio.Group(max_size=10)
69+
group = displayio.Group()
7670

7771
sprite_sheet, palette = adafruit_imageload.load("/spritesheet-2x.bmp",
7872
bitmap=displayio.Bitmap,
@@ -86,16 +80,19 @@ def make_tilegrid():
8680
display.show(group)
8781
return grid
8882

83+
8984
def random_cell():
9085
return randint(FIRST_CELL, LAST_CELL)
9186

87+
9288
def evaluate_position(row, col):
93-
"""Return whether how long of aa toaster is placable at the given location.
89+
"""Return whether how long of a toaster is placeable at the given location.
9490
:param row: the tile row (0-9)
9591
:param col: the tile column (0-9)
9692
"""
9793
return tilegrid[col, row] == EMPTY
9894

95+
9996
def seed_toasters(number_of_toasters):
10097
"""Create the initial toasters so it doesn't start empty"""
10198
for _ in range(number_of_toasters):
@@ -106,21 +103,25 @@ def seed_toasters(number_of_toasters):
106103
break
107104
tilegrid[col, row] = random_cell()
108105

106+
109107
def next_sprite(sprite):
110108
if ANIMATED[sprite]:
111109
return (((sprite - FIRST_CELL) + 1) % NUMBER_OF_CELLS) + FIRST_CELL
112110
return sprite
113111

112+
114113
def advance_animation():
115114
"""Cycle through animation cells each time."""
116115
for tile_number in range(25):
117116
tilegrid[tile_number] = next_sprite(tilegrid[tile_number])
118117

118+
119119
def slide_tiles():
120120
"""Move the tilegrid one pixel to the bottom-left."""
121121
tilegrid.x -= 1
122122
tilegrid.y += 1
123123

124+
124125
def shift_tiles():
125126
"""Move tiles one spot to the left, and reset the tilegrid's position"""
126127
for row in range(4, 0, -1):
@@ -132,20 +133,23 @@ def shift_tiles():
132133
tilegrid.x = 0
133134
tilegrid.y = -64
134135

136+
135137
def get_entry_row():
136138
while True:
137139
row = randint(0, 4)
138140
if tilegrid[4, row] == EMPTY and tilegrid[3, row] == EMPTY:
139141
return row
140142

143+
141144
def get_entry_column():
142145
while True:
143146
col = randint(0, 3)
144147
if tilegrid[col, 0] == EMPTY and tilegrid[col, 1] == EMPTY:
145148
return col
146149

150+
147151
def add_toaster_or_toast():
148-
"""Maybe add a new toaster or toast on the right and/or top at a randon open location"""
152+
"""Maybe add a new toaster or toast on the right and/or top at a random open location"""
149153
if randint(1, 10) <= CHANCE_OF_NEW_TOAST:
150154
tile = TOAST
151155
else:
@@ -158,6 +162,7 @@ def add_toaster_or_toast():
158162
tile = random_cell()
159163
tilegrid[get_entry_column(), 0] = tile
160164

165+
161166
display = make_display()
162167
tilegrid = make_tilegrid()
163168
seed_toasters(INITIAL_NUMBER_OF_SPRITES)
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)