espp icon indicating copy to clipboard operation
espp copied to clipboard

fix(display_drivers): store mirror x/y values and invert them in the rotation function to work with touch

Open finger563 opened this issue 1 year ago • 3 comments

Description

  • Add mirror_x and mirror_y variables to the display drivers which are copied from the config.
  • Update the display drivers' rotate() functions to additionally account for the mirror_x and mirror_y settings, similar to how they were accounting for the swap_xy setting.
  • Update the display drivers' rotate() functions to flip the bits instead of or-ing them

Motivation and Context

It was found that the latest changes from #265 which added the rotate function caused lvgl to not properly match the touch location with the screen location (found in https://github.com/esp-cpp/esp-box-emu/pull/87).

This PR addresses that issue (which was tested specifically with the ST7789 used in the ESP32-S3-BOX, but which was applied similarly to the ili9341 and gc9a01 components).

How has this been tested?

  • Building and running the main code within https://github.com/esp-cpp/esp-box-emu/pull/87
  • Building and running the examples on the appropriate hardware:
    • esp-box/example
    • matouch-rotary-display/example
    • t-deck/example
    • t-dongle-s3/example
    • wrover-kit/example

Note, that while this change is principally targeting fixing the mapping of touch coordinates, not all the examples above have touchscreens - but were tested for completeness.

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

Types of changes

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] Documentation Update
  • [ ] Hardware (schematic, board, system design) change
  • [x] Software change

Checklist:

  • [ ] My change requires a change to the documentation.
  • [ ] I have added / updated the documentation related to this change via either README or WIKI

Software

  • [ ] I have added tests to cover my changes.
  • [ ] I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
  • [x] All new and existing tests passed.
  • [x] My code follows the code style of this project.

finger563 avatar Aug 17 '24 20:08 finger563

@abrondijk Can you test this change on your systems? I needed this for fully functioning touch input on the esp-box (for the esp-box-emu project), but I want to make sure this doesn't mess up others' projects.

finger563 avatar Aug 17 '24 20:08 finger563

:white_check_mark:Static analysis result - no issues found! :white_check_mark:

github-actions[bot] avatar Aug 17 '24 20:08 github-actions[bot]

@finger563 Sure, I'll run this on our hardware either today or tomorrow!

abrondijk avatar Aug 17 '24 21:08 abrondijk

@finger563 Appears to be working just fine and does not break any of our stuff!

abrondijk avatar Aug 19 '24 14:08 abrondijk

@finger563 Appears to be working just fine and does not break any of our stuff!

@abrondijk that's awesome, glad to hear it! I'm working through some odd behavior on the t-deck w.r.t. the touch screen coordinates in portrait and portrait inverted mode, but once that's fixed I'll merge this :)

finger563 avatar Aug 19 '24 15:08 finger563