boochow / MicroPython-ST7735

ST7735 TFT LCD driver for MicroPython
191 stars 64 forks source link

landscape mode #4

Closed nexus166 closed 3 years ago

nexus166 commented 3 years ago

hi!

First of all, I can't thank you enough! This library is the only solution I've found to get the TFT to work on my M5StickC with the latest MicroPython code release and ESP-IDF!

My issue is I can't find a way to use the screen in landscape mode, meaning printing text horizontally. I've messed around a lot with the rotation/offset but I could only achieve "portrait" mode which on the StickC is not feasible given the 80x160 size and the position on the wrist when used in combo with the armband.

I have set ScreenSize = (80, 160) and this is my initialization code (AXP192 setup is already handled):

from ST7735 import TFT
from sysfont import sysfont
import machine
from machine import SPI
tft = TFT(SPI(1, baudrate=27000000, polarity=0, phase=0, bits=8, firstbit=SPI.MSB, sck=machine.Pin(13), mosi=machine.Pin(15), miso=machine.Pin(36)), 23, 18, 5)
tft.initb2()
tft._offset = 25, 0
# un-invert colors
tft.rgb(False)
tft.invertcolor(True)
tft.rotation(2) # anything else results in only parts of the screen being used

Thanks in advance :)

nexus166 commented 3 years ago

just had to swap offset and screen size values

nexus166 commented 3 years ago

@boochow you might be interested in this https://github.com/nexus166/st77xx_mpy, it is a fork of st7789 driver adapted to function decently with st7735 too. I also just published a docker build environment that can be used to easily inject C drivers/apps in the micropython firmware, the result is a much faster experience with the display!