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

Fix partial refresh of displayio.TileGrid #4876

Merged
merged 2 commits into from
Jun 21, 2021

Conversation

t-ikegami
Copy link

This PR fixes a partial refresh of displayio.TileGrid. The original code works only for limited combinations of DISPLAY.rotation and TileGrid.{flip_x, flip_y, transpose_xy}. The following is a test code to check the algorithm (tested on Wio Terminal).

import board
import time
import displayio as dpio
import bitmaptools as bmt

disp = board.DISPLAY
bmp = dpio.Bitmap(200, 150, 2)
pal = dpio.Palette(2)
pal[0] = 0xFFFFFF
pal[1] = 0x0000FF
tg = dpio.TileGrid(bmp, pixel_shader = pal)
g = dpio.Group()
g.append(tg)
disp.show(g)

tg.x = 20
tg.y = 10

def draw() :
  bmp.fill(0)
  disp.refresh()
  bmt.fill_region(bmp, 110, 10, 190, 60, 1)
  disp.refresh()
  time.sleep(1)

def do_test() :
  tg.flip_x = tg.flip_y = tg.transpose_xy = False
  draw()    # top right

  tg.flip_x = True
  draw()    # top left

  tg.flip_y = True
  draw()    # bottom left

  tg.transpose_xy = True
  draw()    # top right

  tg.flip_x = False
  draw()    # bottom right

  tg.flip_y = False
  draw()    # bottom left

  tg.transpose_xy = False
  draw()    # top right

disp.auto_refresh = False

disp.rotation = 0
do_test()

disp.rotation = 90
do_test()

disp.rotation = 180
do_test()

disp.rotation = 270
do_test()

disp.rotation = 0
disp.auto_refresh = True

@tannewt tannewt self-requested a review June 21, 2021 22:27
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@tannewt tannewt merged commit 0f54124 into adafruit:main Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants