rdagger / micropython-ssd1351

MicroPython SSD1351 OLED Display Driver
MIT License
58 stars 13 forks source link

Problem with draw_rectangle at edges of display area #7

Closed tonygo closed 1 year ago

tonygo commented 1 year ago

from time import sleep from ssd1351 import Display, color565 from machine import Pin, SPI

Set up display for Pi Pico

spi = SPI(1, baudrate=13000000, sck=Pin(10), mosi=Pin(11)) display = Display(spi, dc=Pin(14), cs=Pin(9), rst=Pin(8))

Define some colours

red = color565(255,0,0) green = color565(0,255,0) blue = color565(0,0,255) white = color565(255,255,255) black = 0

display.clear() display.fill_rectangle(0,0,128,96,red) # Fill the screen red

display.draw_rectangle(0,0,128,96,green) # Problem line - Try changing 96 to 95

Turn corner pixels white - Works correctly

display.draw_pixel(0,0,white) display.draw_pixel(0,95,white) display.draw_pixel(127,0,white) display.draw_pixel(127,95,white)

The fillrectangle works as expected and reaches all edges of the screen. However, I would expect draw rectangle to outline the edge pixels but it only does the top and bottom edges, the sides are not changed. If to we change to 96 to 95 we get the edges but the bottom line is raised one pixel.

rdagger commented 1 year ago

There was a bug in the draw_vline method. I fixed it and added a demo to test the display boundaries.

tonygo commented 1 year ago

Thank you very much. I'm enjoying using this board.