Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using SX1262 on Lilygo T-Deck causes the display to stop working #26

Open
Crdguy opened this issue Mar 9, 2024 · 2 comments
Open

Using SX1262 on Lilygo T-Deck causes the display to stop working #26

Crdguy opened this issue Mar 9, 2024 · 2 comments

Comments

@Crdguy
Copy link

Crdguy commented Mar 9, 2024

Hello,

I have been using this library on the Lilygo T-Deck and it works great. I also created a tft_config.py which I have added below in case it could be added to the repo:

""" LilyGo T-DECK 320x240 ST7789 display """

from machine import Pin, freq
import s3lcd

BACKLIGHT = Pin(42, Pin.OUT)
TOUCH = Pin(16, Pin.OUT)
KB_PWR = Pin(10, Pin.OUT)  # enabling the KB_PWR pin also enables display - "peripheral" power

KB_PWR.off()
KB_PWR.on()

TFA = 0
BFA = 0
WIDE = 1
TALL = 0

freq(240_000_000)


def config(rotation=0, options=0):
    """Configure the display and return an ESPLCD instance."""
    BACKLIGHT.value(1)

    bus = s3lcd.SPI_BUS(
        1,
        mosi=41,
        sck=40,
        dc=11,
        cs=12,
        pclk=80_000_000,
        swap_color_bytes=False,  # true - blue, false - yellow
    )

    return s3lcd.ESPLCD(
        bus,
        240,
        320,
        inversion_mode=True,
        color_space=s3lcd.BGR,
        rotation=rotation,
        options=options,
    )


def deinit(tft, display_off=False):
    """Take an ESPLCD instance and Deinitialize the display."""
    tft.deinit()
    if display_off:
        BACKLIGHT.value(0)

Unfortunately I have hit a problem while trying to operate the LoRa module at the same time - it causes the TFT display to stop working, and everything I have tried so far has not been able to activate it again. To control the LoRa module, I have used this library: https://github.com/ehong-tl/micropySX126X

To reproduce this issue:

lcd = tft_config.config(1, 0)
lcd.init()

# do anything with the LCD here
sx1262 = SX1262(spi_bus=2, clk=40, mosi=41, miso=38, cs=9, irq=45, rst=17, gpio=13)
status = self.sx1262.begin(freq=434, bw=125.0, sf=7, syncWord=0x12, power=14,
                                        currentLimit=60, preambleLength=8, implicit=False, implicitLen=0xFF,
                                        crcOn=True, txIq=False, rxIq=False, tcxoVoltage=1.7, useRegulatorLDO=False,
                                        blocking=True)

# at this point the display ceases to show any updates, although it can be deinit and init again
lcd.fill(s3lcd.WHITE)
lcd.show()  # nothing is displayed on the screen

I have tried controlling the CS pins by setting the LoRa's CS to low and the TFT to high before trying to display anything on the screen, but this does not help. I have also tried using deinit and init to recreate the SPI object, which produces a visual "refresh" but does not allow the screen to be updated.

Any help on trying to fix this problem would be much appreciated - thanks

@russhughes
Copy link
Owner

I don't think you can use the same clk and mosi pins with two different spi_bus objects.

@c-logic
Copy link
Contributor

c-logic commented Jun 29, 2024

have you a solution for the 2 SPI Devices on same bus problem ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants