peterhinch / micropython-font-to-py

A Python 3 utility to convert fonts to Python source capable of being frozen as bytecode
MIT License
388 stars 70 forks source link

Issues updating text #61

Closed Colddisguise closed 6 months ago

Colddisguise commented 6 months ago

Been spending a several weeks working on getting text updates to work on a Waveshare 3.7" eink display with the ultimate goal of making a clock. I can blit text to the screen, but once something has been 'blitted' I cannot remove it from the screen. I've tried writing a white rectangle over the text then re-blitting the (new) text but to no avail--the same original text stays on the screen with the new text on top making it unreadable. In my latest iteration I run through a loop and instead of replacing the text in the previous blit, it continues to add to the line of text. I am using the writer.py code.

Anyone have any ideas on how to achieve this?

`from Pico_ePaper import Eink, EinkPIO import framebuf from writer import Writer import time import gc import micropython import utime from uarray import array

class DummyDevice(framebuf.FrameBuffer): def init(self, width, height, buf_format): self.width = width self.height = height self._buf = bytearray(self.width * self.height // 8) super().init(self._buf, self.width, self.height, buf_format) self.fill(1)

epd = Eink(rotation=90)

epd = EinkPIO(rotation=90, use_partial_buffer=True)

epd.fill() #clear screen epd.show() epd.sleep()

time.sleep(1)

dummy = DummyDevice(epd.width, epd.height, framebuf.MONO_HLSB)

wri = Writer(dummy, AptosMonoBold108) # verbose = False to suppress console output Writer.set_textpos(dummy, 0, 0) # In case a previous test has altered this

x=0

while True:

print(x)
epd.reinit()
wri.set_clip(row_clip=True, col_clip=True, wrap=True)
wri.printstring(str(x), invert=True)
epd.blit(dummy, 0, 0, key=1)
epd.show()
epd.fill(0xff) # try to clear screen, doesn't work
gc.collect()
epd.sleep()
x = x+1
time.sleep(1)`
peterhinch commented 6 months ago

Writing ePaper device drivers is not simple. There are several ePaper drivers supported by nano-gui, see the supported displays doc. Making a clock display using a supported display and the nano-gui Label class would be simple, and I would be in a position to offer any help you required. That is my suggested solution.

Re the Eink and EinkPIO classes I have no knowledge of these. You'd be better off seeking support from their authors.