Skip to content

Eliminate race condition to improve coordinate accuracy and reliability. #18

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

Merged
merged 2 commits into from
Dec 30, 2021
Merged

Eliminate race condition to improve coordinate accuracy and reliability. #18

merged 2 commits into from
Dec 30, 2021

Conversation

CedarGroveStudios
Copy link
Contributor

@CedarGroveStudios CedarGroveStudios commented Dec 29, 2021

Was experiencing occasional touch coordinate errors, particularly when rapidly pressing the touchscreen. The existing code measured the x and y coordinates then would check to see if the z (pressed) value exceeded the touch threshold value. In some cases, the x and/or y coordinate value would reflect a measurement made before or while the screen was being pressed, resulting in a significant coordinate offset error even when averaged.

The modification changes the logic; the x and y values are not measured until after the z value exceeds the threshold, assuring coordinate accuracy and stability.

Tests without the changes experienced approximately 2 errors per 50 presses. The error rate dropped to 0 with the updated code. Tests were performed using CircuitPython 7.0.0 on a PyPortal Titano using DisplayIO Buttons and VectorIO objects.

@dhalbert dhalbert requested a review from a team December 30, 2021 03:30
Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

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

Looks good to me. Tested on PyPortal with Display_Button and simpletest from this library. Thanks for the improvement @CedarGroveStudios

@FoamyGuy FoamyGuy merged commit 52e6386 into adafruit:main Dec 30, 2021
@CedarGroveStudios
Copy link
Contributor Author

CedarGroveStudios commented Dec 31, 2021

@FoamyGuy Here's a calibration helper for built-in displays that works graphically or REPL-only. It provides a calibration tuple compatible with the screen rotation parameter. Next version will accommodate add-on displays.
https://github.com/CedarGroveStudios/Touchscreen_Calibrator

adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Dec 31, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI to 3.5.14 from 3.5.13:
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#148 from tekktrik/doc/status-led-connect

Updating https://github.com/adafruit/Adafruit_CircuitPython_Touchscreen to 1.1.8 from 1.1.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_Touchscreen#18 from CedarGroveStudios/main
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_Adafruit to 1.3.2 from 1.3.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE_Adafruit#15 from dhalbert/ulab-numpy
  > update rtd py version
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.

2 participants