Skip to content

Commit 0701060

Browse files
MichaelBellGadgetoid
authored andcommitted
Fix bad apple example
1 parent 4934c25 commit 0701060

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

examples/badapple.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1+
# Bad Apple on Presto.
2+
#
3+
# To create the badapple240x240.bin file for the SD card see
4+
# https://github.com/MichaelBell/badapple/tree/presto
5+
# and use the "bit_dump240.py" script in that repo.
6+
17
from time import ticks_us
28

39
import machine
410
import micropython
511
from picographics import DISPLAY_PRESTO, PicoGraphics
12+
613
from presto import Presto
714

815
machine.freq(264000000)
916

10-
import machine
11-
import sdcard
12-
import uos
17+
import sdcard # noqa: E402
18+
import uos # noqa: E402
1319

1420
try:
1521
# Setup for SD Card
@@ -24,7 +30,7 @@
2430

2531
# Setup for the Presto display
2632
presto = Presto()
27-
display = PicoGraphics(DISPLAY_PRESTO, buffer=memoryview(presto))
33+
display = PicoGraphics(DISPLAY_PRESTO, buffer=memoryview(presto.presto))
2834
WIDTH, HEIGHT = display.get_bounds()
2935

3036
# Read the bad apple video file from the SD card
@@ -35,10 +41,11 @@
3541
tick_increment = 1000000 // 30
3642
next_tick = ticks_us()
3743

44+
3845
# This Micropython Viper function is compiled to native code
3946
# for maximum execution speed.
4047
@micropython.viper
41-
def render(data:ptr8, x:int, y:int, next_tick:int): # noqa: F821
48+
def render(data: ptr8, x: int, y: int, next_tick: int): # noqa: F821
4249
for i in range(0, 1024, 2):
4350
# The encoded video data is an array of span lengths and
4451
# greyscale colour values
@@ -59,7 +66,7 @@ def render(data:ptr8, x:int, y:int, next_tick:int): # noqa: F821
5966
y += 1
6067
x = 0
6168
if y >= 240:
62-
presto.update(display)
69+
presto.update()
6370

6471
# Wait until the next frame at 15FPS
6572
next_tick += 1000000 // 15
@@ -69,6 +76,7 @@ def render(data:ptr8, x:int, y:int, next_tick:int): # noqa: F821
6976

7077
return x, y, next_tick
7178

79+
7280
# Read out the file and render
7381
while True:
7482
data = video.read(1024)

0 commit comments

Comments
 (0)