peterhinch / micropython-micro-gui

A lightweight MicroPython GUI library for display drivers based on framebuf, allows input via pushbuttons. See also micropython-touch.
MIT License
247 stars 37 forks source link

Screen is not fully cleared on ssd1306 #19

Closed Leonti closed 1 year ago

Leonti commented 1 year ago

Hi!

First of all, thanks for the amazing library.

I'm writing a UI with it and so far it has everything I needed. Really enjoying it! I'm using it with ssd1306 128x64 which is very small and I noticed that with some of the demos and with my GUI the last line on the bottom and the right-most lines are not cleared, when navigating to another screen.

I proposed a PR here which solved the issue for me, but I'm assuming -1 might have been there for a reason, so not 100% sure if it's the right change.

Here is my hardware setup:

from machine import Pin, I2C, freq
import gc

from drivers.ssd1306.ssd1306 import SSD1306_I2C as SSD
#freq(250_000_000)  # RP2 overclock

# Create and export an SSD instance
i2c = I2C(0, sda=Pin(12), scl=Pin(13))
gc.collect()  # Precaution before instantiating framebuf
ssd = SSD(128, 64, i2c)
gc.collect()
from gui.core.ugui import Display, quiet
# quiet()
# Create and export a Display instance
# Define control buttons
nxt = Pin(11, Pin.IN, Pin.PULL_UP)  # Move to next control
sel = Pin(14, Pin.IN, Pin.PULL_UP)  # Operate current control
prev = Pin(10, Pin.IN, Pin.PULL_UP)  # Move to previous control
increase = Pin(28, Pin.IN, Pin.PULL_UP)  # Increase control's value
decrease = Pin(1, Pin.IN, Pin.PULL_UP)  # Decrease control's value
# display = Display(ssd, nxt, sel, prev)  # 3-button mode
display = Display(ssd, nxt, sel, prev, increase, decrease)  # Encoder mode
peterhinch commented 1 year ago

Fixed by your PR.