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

Espressif: Use i2s peripheral for parallel LCD displays #5378

Merged
merged 6 commits into from
Sep 24, 2021

Conversation

jepler
Copy link
Member

@jepler jepler commented Sep 21, 2021

This enables non-consecutive pins and higher effective clock rates. It successfully drives the 2.8" TFT LCD in parallel mode (but so did the previous code).

My testing board is an Espressif Kaluga and the code is

import board
import displayio
import paralleldisplay
    
    
_DISPLAY_D0 = board.IO8
_DISPLAY_CS = board.IO2
_DISPLAY_CD = board.IO3  
_DISPLAY_WR = board.IO4
_DISPLAY_RD = board.IO5
_DISPLAY_RESET = board.IO6
_DISPLAY_BACKLIGHT = board.IO7
    
_INIT_SEQUENCE = (
    b"\x01\x80\x80"  # Software reset then delay 0x80 (128ms)
    b"\xEF\x03\x03\x80\x02"
    b"\xCF\x03\x00\xC1\x30"
    b"\xED\x04\x64\x03\x12\x81"
    b"\xE8\x03\x85\x00\x78"
    b"\xCB\x05\x39\x2C\x00\x34\x02"
    b"\xF7\x01\x20"  
    b"\xEA\x02\x00\x00"
    b"\xc0\x01\x23"  # Power control VRH[5:0]
    b"\xc1\x01\x10"  # Power control SAP[2:0];BT[3:0]
    b"\xc5\x02\x3e\x28"  # VCM control
    b"\xc7\x01\x86"  # VCM control2
    b"\x36\x01\x38"  # Memory Access Control
    b"\x37\x01\x00"  # Vertical scroll zero
    b"\x3a\x01\x55"  # COLMOD: Pixel Format Set
    b"\xb1\x02\x00\x18"  # Frame Rate Control (In Normal Mode/Full Colors)
    b"\xb6\x03\x08\x82\x27"  # Display Function Control
    b"\xF2\x01\x00"  # 3Gamma Function Disable
    b"\x26\x01\x01"  # Gamma curve selected
    b"\xe0\x0f\x0F\x31\x2B\x0C\x0E\x08\x4E\xF1\x37\x07\x10\x03\x0E\x09\x00"  # Set Gamma
    b"\xe1\x0f\x00\x0E\x14\x03\x11\x07\x31\xC1\x48\x08\x0F\x0C\x31\x36\x0F"  # Set Gamma
    b"\x11\x80\x78"  # Exit Sleep then delay 0x78 (120ms)
    b"\x29\x80\x78"  # Display on then delay 0x78 (120ms)
)   
    
displayio.release_displays()
    
BUS = paralleldisplay.ParallelBus(data0=_DISPLAY_D0, command=_DISPLAY_CD, chip_select=_DISPLAY_CS, write=_DISPLAY_WR, read=_DISPLAY_RD, reset=_DISPLAY_RESET, frequency=2_500_000)
display = displayio.Display(BUS, init_sequence=_INIT_SEQUENCE, width=320, height=240, backlight_pin=_DISPLAY_BACKLIGHT)

.. most boards can't support non-sequential pins, so share the
implementation of the error routine so we get an identical message.
@ladyada ladyada requested a review from kmatch98 September 21, 2021 21:25
Copy link
Collaborator

@kmatch98 kmatch98 left a comment

Choose a reason for hiding this comment

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

Read through the code. Looks like more efficient and clearer use of the i2s peripheral (and esp’s library) to give more flexibility and also add 16 bit parallel LCD.

Good reuse of code for older _construct function.

Did not test on hardware.

@jepler jepler requested a review from gamblor21 September 23, 2021 18:50
The observed does not match the datasheet, so go with what was
observed.
@jepler jepler force-pushed the esp32s2-paralleldisplay-i2s branch from 298ea57 to a97e46b Compare September 23, 2021 19:25
Copy link
Member

@gamblor21 gamblor21 left a comment

Choose a reason for hiding this comment

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

Tested on an UnexpectedMaker TinyS2 with the Adafruit 480x320 TFT breakout. Could only test non-sequential pins as I did not have 8 pins together, but no issues. Tried a few different display frequencies with no issues. Looked over the code and I saw no issues there.

@jepler jepler merged commit 10fdc80 into adafruit:main Sep 24, 2021
@jepler
Copy link
Member Author

jepler commented Sep 24, 2021

hah, I forgot I hadn't acually tested non-consecutive pins 🤣 so thanks for that @gamblor21

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.

3 participants