OLED Library Writer, Clear to end of line

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
stanely
Posts: 13
Joined: Fri Jan 17, 2020 5:19 am
Location: Ohio, USA

OLED Library Writer, Clear to end of line

Post by stanely » Fri Jan 24, 2020 6:28 am

I'm using Peter Hinch's (@ pythoncoder) Writer library. It is an excellent tool and is making my programming much more enjoyable and easier. One of the things I'm doing is updating info on single lines. This works well, but I'm struggling to clear the display to the end of line because sometimes there's prior info that needs erased. I've got a workaround where I set:

Writer.set_clip(True, True, False)

So the writer is set to clip a line, and I send a bunch of extra spaces to overwrite what might be there from a previous write. Is there a better way to do this automatically?

User avatar
pythoncoder
Posts: 3935
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: OLED Library Writer, Clear to end of line

Post by pythoncoder » Sat Jan 25, 2020 7:12 am

I think this is the only way to do it. I guess a useful enhancement would be to implement a clear_line() method which would clear the line from the current insertion point to the end. This could be called before or after writing a string. However the Writer class is intended to be minimal and I have various options which build on this.

You could try nano-gui which builds on the Writer. This implements a Label class which can display variable length text in a field of defined size.
Peter Hinch

stanely
Posts: 13
Joined: Fri Jan 17, 2020 5:19 am
Location: Ohio, USA

Re: OLED Library Writer, Clear to end of line

Post by stanely » Tue Jan 28, 2020 8:21 pm

I came up with another way to clear to end of line and am wondering if it will be faster than what I'm doing now. My ESP32 (Heltec WiFi Kit) implementation has a reset pin on the OLED, and I can clear the whole thing by flipping that pin. The Writer documentation talks about blitting, so I'm guessing when I do an ssd.show() only that line is written.

Is it faster to reset the screen and rewrite the whole thing or send a bunch of extra blanks on just one line that gets clipped? My screen has one line of large font and 2 lines of small font.

User avatar
pythoncoder
Posts: 3935
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: OLED Library Writer, Clear to end of line

Post by pythoncoder » Wed Jan 29, 2020 10:27 am

The GUI library I mentioned clears Label fields before rendering text to them. It does this by drawing a filled rectangle of the correct size to the area.
Peter Hinch

Post Reply