Closed jdtsmith closed 3 years ago
I will look into this. I haven't done much with the Hershey fonts since version 1.12 so they may need some changes.
I have fixed the segfault issue but I'm not seeing the rotation issue.
from machine import Pin, SPI
import st7789
rot=0
tft = st7789.ST7789(
SPI(1, baudrate=30000000, sck=Pin(18), mosi=Pin(19)),
135, 240,
reset=Pin(23, Pin.OUT),
cs=Pin(5, Pin.OUT),
dc=Pin(16, Pin.OUT),
backlight=Pin(4, Pin.OUT),
rotation=rot)
tft.init()
print("before rotation:", tft.width(), tft.height())
tft.rotation(rot)
print("after rotation:", tft.width(), tft.height())
For rot= 0, 1, 2, 3 tft.width() and tft.height() return the numbers I would expect.
rot=0
before rotation: 135 240
after rotation: 135 240
rot=1
before rotation: 240 135
after rotation: 240 135
rot=2
before rotation: 135 240
after rotation: 135 240
rot=3
before rotation: 240 135
after rotation: 240 135
Great, thanks! The draw
segfaults are confirmed to be fixed in some testing. I did notice that draw
insists on 5 or more arguments, despite the docs mentioning that fg
and bg
are both optional.
Also, do you have any tips or build settings for building your firmware files for the various targets like TTGO display? As mentioned mine following your default instructions with MPv1.16 uses too much RAM.
See https://github.com/russhughes/st7789_mpy/issues/40#issuecomment-904740149 for information about making more flash space available if you are running out of flash. If you are running out of RAM you need to reduce your buffer_size=64800 if possible. The only reason to have a buffer that size would be for fullscreen bitmaps. You could tile or split your bitmaps to reduce the RAM needed or use jpg's with the SLOW draw method. You can save RAM by freezing your bitmaps in flash so they can be read directly from flash with little RAM use.
I will fix the parameter issue tonight.
Thanks. Even with dynamic buffer allocation I don't have enough RAM for a JPG (though perhaps with SLOW it would work). Something like 60K (mine) vs. 109K (yours) free. I'll looking into altering the app boundary.
The write method returns the width of the string as printed in pixels since it could be using a proportional spaced front. The REPL will print any returned values. You should not see prints when run using import.
This always gets me. Thanks.
First thanks very much for doing this. I've wanted to move off the Loboris port to mainline MP for an old project, and a decent feature-full driver for my TTGO display was the sticking point.
I've been experimenting with your new v1.16 firmware.bin (Lily TTGO T-Display 135x240), and have encountered some issues with the
draw
command, using the concepts from the "hershey.py" example.First a couple minor things: the
gotheng
andromant
are not frozen in, so this example only runs if those are removed. Also, therotation=
keyword to theST7789
method does not alter the logicalwidth()
andheight()
, unlike a separate call torotation()
.More concerning is that the
draw
method leads to non-drawing, freezes, or segfaults when used at the MP prompt, or indeed anywhere outside its creation context.For example, with this simple
main.py
:The following occurs directly at the prompt:
This occurs whether or not I let the driver dynamically allocate memory or set the buffer size in advance (as here). What is strange is if I put this single call to
draw
at the end ofmain.py
it works as expected.I can get the
hershey.py
example working (once I removed the missing fonts). But ONLY if I initialize and immediately use theST7789
object in the same context (e.g. in that example module'smain
). I can't import theST7789
object from another module, pass it in as an argument to another method, or use it from the REPL, etc. — this always leads to freezes or segfaults.I haven't seen this with normal bitmap fonts, only the Hershey fonts and their
draw
method.Thanks again for your work on this.