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

A suggestion on LCD peripheral (IDFGH-7191) #8790

Closed
LucivorLin opened this issue Apr 18, 2022 · 11 comments
Closed

A suggestion on LCD peripheral (IDFGH-7191) #8790

LucivorLin opened this issue Apr 18, 2022 · 11 comments
Labels
Resolution: Done Issue is done internally Status: Resolved Issue is done internally Type: Feature Request Feature request for IDF

Comments

@LucivorLin
Copy link

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when I use LCD peripherals.
SPI master settings cannot be configured in function esp_lcd_new_panel_io_spi(), but I want to change TX to LSB first, to ensure the color of my LCD is correct.

Describe the solution you'd like

in /esp-idf/components/esp_lcd/src/sep_lcd_panel_io_spi.c,

spi_device_interface_config_t devcfg = {
        .flags = SPI_DEVICE_HALFDUPLEX,

The flag can be set as a parameter to ensure the flexibility of the SPI master device driving the screen.

Describe alternatives you've considered

Give some extra functions of API to change these settings.

Chinese

LCD外设生成的SPI主设备难以更改flag参数,但有屏幕修改LSB/MSB等一些需求。

@LucivorLin LucivorLin added the Type: Feature Request Feature request for IDF label Apr 18, 2022
@espressif-bot espressif-bot added the Status: Opened Issue is new label Apr 18, 2022
@github-actions github-actions bot changed the title A suggestion on LCD peripheral A suggestion on LCD peripheral (IDFGH-7191) Apr 18, 2022
@Alvin1Zhang
Copy link
Collaborator

Thanks for reporting.

@suda-morris
Copy link
Collaborator

@LucivorLin Yes, we didn't expose all the underlying spi device flags to LCD IO layer by design (because not all spi flags are suitable for LCD). But left the space to extend them in the future by adding more flags into esp_lcd_panel_io_spi_config_t.flags.
Which flag in your case want to have? SPI_DEVICE_TXBIT_LSBFIRST or SPI_DEVICE_RXBIT_LSBFIRST or SPI_DEVICE_BIT_LSBFIRST?

@LucivorLin
Copy link
Author

@suda-morris SPI_DEVICE_TXBIT_LSBFIRST is I want.

@suda-morris
Copy link
Collaborator

@LucivorLin
spi-lcd-support-transmit-lsb-first.patch.zip

Is this patch sufficient for you? Sorry I don't have an LCD at hand that acquires an LSB first transmission.

Ways to apply the patch:

  1. decompress the zip file, and get the .patch file (e.g. my_fix.patch)
  2. cd $IDF_PATH , check out the master branch
  3. git apply my_fix.patch or git am my_fix.patch

@espressif-bot espressif-bot added Status: In Progress Work is in progress Status: Reviewing Issue is being reviewed and removed Status: Opened Issue is new Status: In Progress Work is in progress labels Apr 18, 2022
@LucivorLin
Copy link
Author

After apply the patch, what should I do?
Since the flags of esp_lcd_new_panel_io_spi didn't change, I would like to ensure my operation is correct.

xxx@LAPTOP-XXXXXXXX MINGW64 /e/Softwares/ESP/Container/esp-idf (master)
$ git apply temp/spi-lcd-support-transmit-lsb-first.patch
error: can't open patch 'temp/spi-lcd-support-transmit-lsb-first.patch': Permission denied

xxx@LAPTOP-XXXXXXXX MINGW64 /e/Softwares/ESP/Container/esp-idf (master)
$ git am temp/spi-lcd-support-transmit-lsb-first.patch

xxx@LAPTOP-XXXXXXXX MINGW64 /e/Softwares/ESP/Container/esp-idf (master)

Should there be any reaction of the latter command line? @suda-morris

@suda-morris
Copy link
Collaborator

@LucivorLin The patch file extracted from the attached zip file is 0001-lcd-spi-lcd-support-transmit-lsb-first.patch. Maybe you didn't decompress it successfully?

@LucivorLin
Copy link
Author

LucivorLin commented Apr 19, 2022

Now I successfully applied, and I added .flags.lsb_first = 1 in esp_lcd_panel_io_spi_config_t io_config.
However, since I am new to ESP-IDF master branch, I cannot build the project as before, the error shows as follow:

Traceback (most recent call last):
  File "E:/Softwares/ESP/Container/esp-idf/tools/ldgen/ldgen.py", line 16, in <module>
    from ldgen.entity import EntityDB
  File "E:\Softwares\ESP\Container\esp-idf\tools\ldgen\ldgen\entity.py", line 12, in <module>
    from pyparsing import (Group, Literal, OneOrMore, ParseException, SkipTo, Suppress, White, Word, ZeroOrMore, alphas,
ImportError: cannot import name 'rest_of_line' from 'pyparsing' (e:\Softwares\ESP\Tools\python_env\idf4.4_py3.8_env\lib\site-packages\pyparsing.py)
[2/8] Performing build step for 'bootloader'
[1/1] cmd.exe /C "cd /D E:\ESP32_Projects\S2_projects\lvgl\build\bootloader\esp-idf\esptool_py && e:\Softwares\ESP\Tools\python_env\idf4.4_py3.8_env\Scripts\python.exe E:/Softwares/ESP/Container/esp-idf/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x1000 E:/ESP32_Projects/S2_projects/lvgl/build/bootloader/bootloader.bin"
Bootloader binary size 0x5100 bytes. 0x1f00 bytes (28%) free.
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

@suda-morris

@suda-morris
Copy link
Collaborator

suda-morris commented Apr 19, 2022

the pyparsing dependency of ldgen has been upgraded on master branch. I guess you need to rerun the "install.sh" script to install the python environment needed for master branch. Currently you're using the idf 4.4 environment for compiling the master branch (e:\Softwares\ESP\Tools\python_env\idf4.4_py3.8_env)

Alternatively, I guess this patch can also be applied to 4.4 release branch. 🤔

@LucivorLin
Copy link
Author

Well, I tried using the patch in v4.4.
However, the LCD cannot work, I think it may be because of the priority of the operator in C language.
Is that better to change the code from

spi_device_interface_config_t devcfg = {
        .flags = SPI_DEVICE_HALFDUPLEX | io_config->flags.lsb_first ? SPI_DEVICE_TXBIT_LSBFIRST : 0,

to

spi_device_interface_config_t devcfg = {
        .flags = SPI_DEVICE_HALFDUPLEX | (io_config->flags.lsb_first ? SPI_DEVICE_TXBIT_LSBFIRST : 0),

?
@suda-morris

@suda-morris
Copy link
Collaborator

@LucivorLin Ah yes, my bad. Nice found. So with your fix, does that work now?

@LucivorLin
Copy link
Author

It works properly now.

@espressif-bot espressif-bot added Resolution: Done Issue is done internally Status: Resolved Issue is done internally and removed Status: Reviewing Issue is being reviewed labels Apr 21, 2022
tore-espressif pushed a commit to tore-espressif/esp-idf that referenced this issue Apr 22, 2022
espressif-bot pushed a commit that referenced this issue Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Resolved Issue is done internally Type: Feature Request Feature request for IDF
Projects
None yet
Development

No branches or pull requests

4 participants