Skip to content

Commit 15f166a

Browse files
committed
Examples on appdev.App no longer call display_drv.show() themselves
appdev.App drives periodic show() for any display whose needs_refresh is True, and as of pydevices 0d6350a FBDisplay computes that from the underlying display rather than inheriting False. So on a MicroPython dotclock panel the App now presents on its own, and 81 manual show() calls across 35 examples were doing work that is already done. Only examples that build an App were touched. The seven that call show() with no App - framebuf_simpletest, logo, pbm_simpletest and friends - keep theirs: nothing else would ever present for them. Three files had show() as the only statement in a block, and those were rewritten rather than left with a bare pass: piano.py loses the 'changed' flag that existed only to decide whether to present, scroll_touch_test.py loses a guard that guarded nothing else, and tower_climb.py keeps _present() as an explicit no-op because three call sites use it as a seam. Every changed file re-parsed after editing.
1 parent 2f14529 commit 15f166a

35 files changed

Lines changed: 3 additions & 87 deletions

lib/examples/alien/alien.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ def _tick(_=None):
8888
st["yd"] = -abs(st["yd"])
8989
st["col"], st["row"] = col, row
9090
tft_bitmap.bitmap(tft, alien, col, row)
91-
tft.show()
9291
st["last_col"], st["old_row"] = col, row
9392

9493
app.every(_tick, period=10, async_=app.timer_async)

lib/examples/apollo/apollo.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,10 @@ def _pkg_dir(file):
5757

5858
def _init_apollo():
5959
dsky.init_screen()
60-
display_drv.show()
6160

6261
dsky.write_string("42", dsky.prog_pos)
6362
dsky.write_string("01", dsky.verb_pos)
6463
dsky.write_string("23", dsky.noun_pos)
65-
display_drv.show()
6664

6765

6866
def _update_time():
@@ -75,15 +73,13 @@ def _update_time():
7573
_last_time = (y, mo, d, h, m, s)
7674
gc.collect()
7775
dsky.write_string(f"{mem-mem_free():7}", dsky.data3_pos)
78-
display_drv.show()
7976

8077

8178
def _scroll_step():
8279
global _scrolling, _scroll_i
8380
if not _scrolling:
8481
return
8582
display_drv.vscsad(_scroll_i)
86-
display_drv.show()
8783
_scroll_i += 1
8884
if _scroll_i >= _scroll_end:
8985
_scrolling = False
@@ -105,7 +101,6 @@ def _key_release():
105101
dsky.set_button(_pending_key, False)
106102
_pending_key = None
107103
dsky.set_acty(False)
108-
display_drv.show()
109104
_key_busy = False
110105
_key_release_at = None
111106

lib/examples/appdev_encoder_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def draw_line():
2222
color = color_byte << 8 | color_byte
2323
display_drv.fill_rect(0, 0, x_pos, thickness, color)
2424
display_drv.fill_rect(x_pos, 0, w - x_pos, thickness, bg_color)
25-
display_drv.show()
2625

2726

2827
display_drv.vscsad(y_pos)
@@ -73,7 +72,6 @@ def _on_wheel(e):
7372
delta = steps * steps * direction # Quadratic acceleration
7473
y_pos = (y_pos + delta) % h
7574
display_drv.vscsad(y_pos)
76-
display_drv.show()
7775
steps, _accum_x = _whole_steps(_accum_x, raw_x)
7876
if steps != 0:
7977
direction = factor if steps > 0 else -factor

lib/examples/appdev_touch_coords.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def _show():
4848
display_drv.fill_rect(0, 0, W, H, BG)
4949
x, y = TARGETS[idx]
5050
_plus(x, y, FG)
51-
display_drv.show()
5251
_out("[%d/%d] tap (%d, %d)" % (idx + 1, len(TARGETS), x, y))
5352

5453

@@ -71,7 +70,6 @@ def _on_up(e):
7170
if idx >= len(TARGETS):
7271
_out("done %s" % (results,))
7372
display_drv.fill_rect(0, 0, W, H, BG)
74-
display_drv.show()
7573
else:
7674
_show()
7775
timer.sleep_ms(400)

lib/examples/appdev_touch_test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def _draw_target(x, y, half_width, half_height):
6262
y * half_height + ((half_height - 8) // 2),
6363
BG_COLOR,
6464
)
65-
display_drv.show()
6665

6766

6867
def _clear_target(x, y, half_width, half_height):
@@ -73,7 +72,6 @@ def _clear_target(x, y, half_width, half_height):
7372
half_height - 1,
7473
BG_COLOR,
7574
)
76-
display_drv.show()
7775

7876

7977
def _report(touch_rotation_table):
@@ -91,7 +89,6 @@ def _report(touch_rotation_table):
9189
(display_drv.height - 8) // 2,
9290
FG_COLOR,
9391
)
94-
display_drv.show()
9592

9693

9794
# Callback-driven state machine (one path for sync and async).

lib/examples/bmp565_scroll.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,12 @@ def _tick(_=None):
3535
draw_bg(0, j, 0, j, height=1)
3636
st["j"] = j + 1
3737
if st["j"] >= display_drv.height:
38-
display_drv.show()
3938
st["phase"] = "scroll"
4039
return
4140
# scroll phase
4241
i = st["i"]
4342
display_drv.vscsad(i % display_drv.height)
4443
draw_bg(0, i % display_drv.height, 0, i % image.height)
45-
display_drv.show()
4644
st["i"] = i + 1
4745

4846
app.every(_tick, period=1, async_=app.timer_async)

lib/examples/bmp565_scroll_sprite.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ def _tick(_=None):
9393
draw_bg(i % display_drv.width, i % image.height, 1)
9494
st["i"] = i + 1
9595
if i < display_drv.width:
96-
display_drv.show()
9796
return
9897

9998
draw_x = st["scroll"] + st["char_x"]
@@ -116,7 +115,6 @@ def _tick(_=None):
116115
bg,
117116
)
118117
st["shot_location"] = 0
119-
display_drv.show()
120118

121119
app.on(app.events.MOUSEMOTION, _on_motion)
122120
# ~20 fps once scrolling; first columns also tick so quit is always serviced.

lib/examples/bmp565_sprite.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def draw_sprite(
5252

5353

5454
display_drv.fill(bg)
55-
display_drv.show()
5655

5756
point = namedtuple("point", "x y")
5857
step = 3
@@ -101,7 +100,6 @@ def _tick(_=None):
101100
location = point(location.x + step, location.y)
102101
st["location"] = location
103102
draw_sprite(*location, pos, direction)
104-
display_drv.show()
105103
st["pos_i"] = (st["pos_i"] + 1) % len(positions)
106104

107105

lib/examples/bouncing_balls.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ def _tick(_=None):
101101
for ball in balls:
102102
step(ball)
103103
pygraphics.circle(display_drv, int(ball.x), int(ball.y), ball.r, ball.color, True)
104-
display_drv.show()
105104

106105

107106
app.every(_tick, period=10, async_=app.timer_async)

lib/examples/boxlines.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ def poll():
7070
height,
7171
palette.color565(getrandbits(8), getrandbits(8), getrandbits(8)),
7272
)
73-
tft.show()
7473
return False
7574

7675
return poll

0 commit comments

Comments
 (0)