Description
CircuitPython version
Adafruit CircuitPython 9.1.4 on 2024-09-17; M5Stack Dial with ESP32S3
Code/REPL
import time
import board
import displayio
import vectorio
display = board.DISPLAY
def show_and_count_loops_per_second(num_reads: int) -> None:
time_ms = time.monotonic_ns() // 1e6
next_lps_time = time_ms + 1000
lps_counter = 0
while num_reads > 0:
lps_counter += 1
time_ms = time.monotonic_ns() // 1e6
if time_ms > next_lps_time:
print(f"Loops per second: {lps_counter}")
num_reads -= 1
next_lps_time += 1000
lps_counter = 0
print("Empty loop")
show_and_count_loops_per_second(5)
print("\nCreate a vectorio rectangle as big as the screen")
palette = displayio.Palette(1)
palette[0] = 0x125690
rectangle = vectorio.Rectangle(pixel_shader=palette, width=display.width, height=display.height, x=0, y=0)
rectangle_group = displayio.Group()
rectangle_group.append(rectangle)
display.root_group = rectangle_group
show_and_count_loops_per_second(5)
print("\nChange rectangle color")
palette[0] = 0xFFFF00
show_and_count_loops_per_second(5)
Behavior
Empty loop
Loops per second: 64892
Loops per second: 64707
Loops per second: 64781
Loops per second: 64704
Loops per second: 64682
Create a vectorio rectangle as big as the screen
Loops per second: 64931
Loops per second: 74644
Loops per second: 74662
Loops per second: 74627
Loops per second: 74573
Change rectangle color
Loops per second: 8342
Loops per second: 8644
Loops per second: 8801
Loops per second: 8806
Loops per second: 8698
Description
There's something wrong with the vectorio display update, once the palette color change the microcontroller slow down and never recover. To replicate the bug I made the above example.
First the script run an emty loop and measure how many loops are performed in a second. It runs about 65k loops per second,
After the script create a rectangle with vectiorio as big as the screen and measure the looping time again. Now it runs about 75k loops per second. It make sense, the display do not show anymore the console.
Finally the script change the palette color of the rectange and measure for the third time the empty looping time. The loops per second drop below 9k and never recover even after the screen updates are done
Additional information
No response