Skip to content

Touch input is mirrored on the display in touch_demo.py #4

Open
@CsErik2001

Description

@CsErik2001

Description

When touching the screen, the circles are drawn at the opposite location of the touch input. For example, if I touch the top-left corner, the circle appears in the bottom-right corner. It seems like the x and y coordinates are being mirrored.

Steps to reproduce

  1. Run the provided demo code on an ESP32 with a CYD touchscreen.
  2. Touch anywhere on the display.
  3. Observe that the circle is drawn in the opposite location from where you touched.

Expected behavior

The circle should appear where the screen is touched, without mirroring the coordinates.

Code causing the issue

The following lines seem to be the cause of the mirroring:

y = (cyd.display.height - 1) - y
x = (cyd.display.width - 1) - x

Suggested fix:

Remove the mirroring and only ensure the circles are drawn within the screen boundaries:

y = min(max(y, r+1), cyd.display.height - r - 1)
x = min(max(x, r+1), cyd.display.width - r - 1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions