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

Re-enable paralleldisplaybus on ESP #8862

Merged
merged 5 commits into from
Feb 8, 2024
Merged

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented Jan 30, 2024

Add lilygo t-display s3 because it has a parallel display.

Fixes #8437

Add lilygo t-display s3 because it has a parallel display.

Fixes micropython#8437
@tannewt tannewt added this to the 9.0.0 milestone Jan 30, 2024
@tannewt tannewt requested a review from jepler January 30, 2024 19:39
@kreier
Copy link

kreier commented Feb 4, 2024

Changes in 18 files is a lot. I copied the changes to my local build, compiled the image and uploaded the created firmware.bin to my T-Display S3 with esptool write_flash 0x0 firmware.bin. It appears as FTHRS3BOOT flash drive after reset. Now I copied the firmware.uf2 into this drive and the board is now running Circuitpython 9.0.0 with display:

IMG_9216

The MADCTL value 0x60 seems to be correct - as shown with the rotation=0 in the board.c. Great progress, I would never gotten that far myself! Thanks @tannewt Scott!

I have only two observations. The flash chip should have 16 MByte but in Windows the total size indicated is 5.66 MB. And the only BUTTON in pins.c is the right one at GPIO14. The other T-Display boards with ESP32 and rp2040 also have two buttons, and we agreed on a new build for the 4M variant of the ESP32 recently (#8787 ) to label the GPIO0 button as BUTTON0 and the button on the right side (GPIO35 for the ESP32) as BUTTON1. Can we keep this assignment for the S3 variant, so GPIO0 would also become BUTTON0 and GPIO14 would also be BUTTON1?

@kreier
Copy link

kreier commented Feb 4, 2024

Two problems are solved. I had already flashed another CircuitPython image to this board prior to trying this new build here. The old image was compiled for 8MB and I think the partition scheme was carried over and not overwritten. After now erasing the flash first and then flash the firmware.bin with the esptool it appeared right away as CIRCUITPY USB flash drive in Windows with a capacity of 13.6 MByte.

Don't know yet how to get into the UF2 boot mode where I could just drop a new firmware.uf2 in to uf2-drive and get an updated firmware, but this might be an ESP32-S3 specific problem. It always worked with rp2040 boards and generally everything offered by Adafruit .

@kreier
Copy link

kreier commented Feb 4, 2024

Pin description for STEMMA connector is also working correctly. Warning of missing pull up resistors if nothing is connected, and finding attached bus devices.

IMG_9218

@kreier
Copy link

kreier commented Feb 5, 2024

The 8 parallel lines connecting to the display really speed up the graphic output. A simple 1000x "Hello world" gets around 5x faster:

import board, displayio, time
board.DISPLAY.root_group = displayio.CIRCUITPYTHON_TERMINAL
start = time.monotonic()
for i in range(1000):
    print("Hello world!", end=" ")
print(f"\nThis took {time.monotonic() - start} seconds.")

New 1.89 seconds versus 10.3 seconds. Without rendering to the build-in display (serial) its 1.27 seconds. Looking forward to some high-fps applications with CircuitPython (Some examples in Arduino with 57 fps are posted on Youtube)

@tannewt
Copy link
Member Author

tannewt commented Feb 5, 2024

Don't know yet how to get into the UF2 boot mode where I could just drop a new firmware.uf2 in to uf2-drive and get an updated firmware, but this might be an ESP32-S3 specific problem. It always worked with rp2040 boards and generally everything offered by Adafruit .

On ESP you need to install UF2 separately. The RP2040 has it in ROM and adafruit boards usually have it factory installed.

The other T-Display boards with ESP32 and rp2040 also have two buttons, and we agreed on a new build for the 4M variant of the ESP32 recently (#8787 ) to label the GPIO0 button as BUTTON0 and the button on the right side (GPIO35 for the ESP32) as BUTTON1. Can we keep this assignment for the S3 variant, so GPIO0 would also become BUTTON0 and GPIO14 would also be BUTTON1?

Yup, will look at this.

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tannewt This now has merge conflicts.

Has a decision been made about the button pin names?

@tannewt
Copy link
Member Author

tannewt commented Feb 7, 2024

@tannewt This now has merge conflicts.

Has a decision been made about the button pin names?

I intend to do it. Just haven't gotten to it. Will do tomorrow hopefully.

@tannewt
Copy link
Member Author

tannewt commented Feb 7, 2024

Ok @dhalbert and @kreier please take another look. It should be good to go.

@dhalbert dhalbert merged commit 8210f22 into adafruit:main Feb 8, 2024
344 checks passed
@kreier
Copy link

kreier commented Feb 9, 2024

Thanks @tannewt for the good work! And standardizing the button names for all T-Display boards!

@dsteidley
Copy link

When I try to use the ST7789 driver for this, I get an error:
Traceback (most recent call last):
File "code.py", line 14, in
AttributeError: 'module' object has no attribute 'SPI'

The code was the example at https://github.com/adafruit/Adafruit_CircuitPython_ST7789

... and the 'module' is 'board'

I am gathering from the above conversation that LilyGo isn't using SPI to drive the ST7789. Can you help point me in the direction of how to get the CircuitPython Adafruit_gfx library going? The display works... I can get the REPL display on it, and the Hello World test from above. I think I need to dive into the DisplayIO driver?

Sorry if this is too far off topic, but the context seemed relevant.

@SeanTheITGuy
Copy link

SeanTheITGuy commented Mar 28, 2024

If f you're using the tdisplay-s3, its a parallelbusdisplay and I believe it's already set up on boot for use feom the import board module. Just use display = board.DISPLAY instead of trying to use a LCD driver or initialize a bus. Its all done under the hood.

Also, best place for this sort of question is the adafruit discord in the #help-with-circuitpython channel

@todbot
Copy link

todbot commented Mar 28, 2024

Yep, @dsteidley I just verified what @SeanTheITGuy said is correct: just installing the CircuitPython for the LilyGo TDisplay S3 automatically creates the display and you can get it for your own purposes with display = board.DISPLAY.

If you do want to create your own, it looks like the equivalent is something like the below. But what I'd like to know:
why is rowstart & colstart swapped and rotation=270 compared to lilygo_tdisplay_s3/board.c?

"""
LilyGo T-Display S3 display hand-setup
"""
import time
import board
import digitalio
import displayio
import paralleldisplaybus
import adafruit_st7789
displayio.release_displays()
lcd_power = digitalio.DigitalInOut(board.LCD_POWER_ON)   # IO15
lcd_power.switch_to_output(value=True)
display_bus = paralleldisplaybus.ParallelBus(
    # IO39,40,41,42,43,44,45,46,47,48
    data_pins = (board.LCD_D0, board.LCD_D1, board.LCD_D2, board.LCD_D3,
                 board.LCD_D4, board.LCD_D5, board.LCD_D6, board.LCD_D7),
    command = board.LCD_DC,      # IO7,
    chip_select = board.LCD_CS,  # IO6,
    write = board.LCD_WR,        # IO8,
    read = board.LCD_RD,         # IO9,
    reset = board.LCD_RST,       # IO5,
    frequency = 15_000_000,
)
display = adafruit_st7789.ST7789(display_bus, width=320, height=170, rotation=270, colstart=35)
while True:
    print(time.monotonic(), "this is on screen")
    time.sleep(0.2)

@SeanTheITGuy
Copy link

when rotated 270 (-90) degrees, the columns become rows, so colstart instead of rowstart makes sense, right? As to WHY it's rotated, I'd guess it comes down to how the individuals who wrote board.c vs that demo code wanted to hold the t-display.

@RetiredWizard
Copy link

RetiredWizard commented Mar 28, 2024

There were several PRs like #8772 / #8773 which eliminated the screen rotation of the display by updating the display init strings in the core board files. The library init strings probably haven't been updated the same way which is why you still need to specify the old rotation/rowstart/colstart values.

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

Successfully merging this pull request may close these issues.

Re-enable parallelbus on ESP
7 participants