Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial broadcom 2d accel code #8349

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

cleverca22
Copy link

@cleverca22 cleverca22 commented Aug 30, 2023

the initial 2d accel code, tested and working on a pi-zero
it should work on the entire vc4 family, bcm2836/2836/2837, just need to update BCM_PERIPH_BASE_VIRT, or find an existing constant that does the same job

will work on it more tomorrow, but am open to comments

features:

  • displaying a bitmap at set coords, with 1:1 scale
  • up/down scaling
  • sprite wide alpha
  • moving the REPL framebuffer into a sprite
  • properly handling colors
  • vsync updating
  • aarch64 support
  • bcm2711 support

example code.py:

import videocore
import gifio
import time

sprite = videocore.Sprite()
gif = gifio.OnDiskGif("/discord-minecraft.gif")
start = time.monotonic()
next_delay = gif.next_frame()
end = time.monotonic()
overhead = end - start
sprite.image = gif.bitmap

start = time.monotonic()
videocore.HvsChannel1.set_sprite_list([sprite])
end = time.monotonic()
refresh = end-start
print("refresh time:")
print(refresh)

xinc = 3;
yinc = 4;

x = 5
y = 5

while True:
  time.sleep(max(0, next_delay - overhead))
  next_delay = gif.next_frame()
  if (x > 0) and (x < 100):
    x += xinc
  else:
    xinc = xinc * -1
    x += xinc

  if (y > 0) and (y < 100):
    y += yinc
  else:
    yinc = yinc * -1
    y += yinc

  if x < 0:
    x = 0
  if y < 0:
    y = 0
  sprite.x = x
  sprite.y = y
  start = time.monotonic()
  videocore.HvsChannel1.set_sprite_list([sprite])
  end = time.monotonic()
  refresh = end-start
  #print("refresh time:")
  #print(refresh)

expose color_order and pixel_format to python
add a demo/test code.py
@tannewt
Copy link
Member

tannewt commented Aug 30, 2023

What do you think about adapting Sprite to the TileGrid API and changing the displayio implementation instead? That way existing code would work including the default terminal.

@dhalbert dhalbert marked this pull request as draft October 25, 2023 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants