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

lines drawn with bitmaptools.draw_polygon to a bitmap can partially fail to update a screen #9239

Open
kevinjwalters opened this issue May 11, 2024 · 0 comments

Comments

@kevinjwalters
Copy link

kevinjwalters commented May 11, 2024

CircuitPython version

Adafruit CircuitPython 9.0.4 on 2024-04-16; Adafruit CLUE nRF52840 Express with nRF52840

Code/REPL

### displayio or bitmaptools bug with missing pixels
### perhaps related to dirty region code for efficient screen updates?

### Demonstrated on Adafruit CLUE with 9.0.3 and 9.0.4

import array
import time

import board

import displayio
import bitmaptools


p1 = [(170, 120), (168, 105), (160, 91), (149, 80), (135, 72), (120, 70)]
p2 = [(120, 70), (105, 72), (91, 80), (80, 91), (72, 105), (70, 120)]
p3 = [(70, 120), (72, 135), (80, 149), (91, 160), (105, 168), (120, 170)]
p4 = [(120, 170), (135, 168), (149, 160), (160, 149), (168, 135), (170, 120)]
                  
display = board.DISPLAY
main_group = displayio.Group()
display.root_group = main_group

bmp = displayio.Bitmap(240, 240, 8)
palette = displayio.Palette(8)
palette[1] = 0xe00000
palette[2] = 0x00e000
palette[3] = 0x0000e0
palette[4] = 0xe0e0e0
palette[5] = 0x606060
tg = displayio.TileGrid(bitmap=bmp, pixel_shader=palette)
main_group.append(tg)

pal_idx = 1
for points in (p1, p2, p3, p4):
    bitmaptools.draw_polygon(bmp,
                             array.array("h",[xy[0] for xy in points]), 
                             array.array("h",[xy[1] for xy in points]),      
                             pal_idx,
                             close=False)
    pal_idx += 1
    time.sleep(3)

print("some pixels are missing when drawing p4")

bitmaptools.draw_polygon(bmp,
                         array.array("h",[0, 239]),
                         array.array("h",[0, 239]),
                         pal_idx,
                         close=False)
print("they appear after this line is drawn across whole display")

while True:
    pass

Behavior

Some pixels are missing from the final pass of the for loop for p4. Might be one or two missing for p3 too.

Description

I did this on a CLUE. I'd suggest using that or something with a 240x240xsame-bit-depth resolution display to investigate further/indepdently reproduce.

Additional information

I think there's some code for "dirty" regions of the display signifying needing an update of a rectangular area sent to the physical screen. I'd suspect there is a fault somewhere between bitmaptools and displayio ...

@dhalbert dhalbert added this to the 9.x.x milestone May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants