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

Add MultiTouchBlink examples #11

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

aliphys
Copy link
Contributor

@aliphys aliphys commented Jun 13, 2024

This PR adds two examples, that blinks the LED on the GIGA R1 WiFi based on the number of touches registered on the screen.

  • ⁉️ MultiTouchBlink_IRQ.ino shows how to attach and detach an interrupt (be calling touchDetector.begin();
  • 🚥 The LED onboard the GIGA R1 WiFi is used to display the feedback from the touch events. Using the RGB LED on the GIGA Display Shield itself would create a cyclical dependency since the GIGADisplayRGB class is part of arduino-libraries/Arduino_GigaDisplay
  • 🌐 Both interrupt MultiTouchBlink_IRQ.ino and polling approaches MultiTouchBlink_Polling.ino are covered.

✨ Thanks for initial testing and feedback by @Hannes7eicher and @pedromsousalima
Closes #10

Copy link
Contributor

@leonardocavagnis leonardocavagnis left a comment

Choose a reason for hiding this comment

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

Instead of calling begin/end, it might make more sense to use the detach function.


void gigaTouchHandler(uint8_t contacts, GDTpoint_t* points) {
contactPoints = contacts;
touchDetector.end(); // close the touch controller
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
touchDetector.end(); // close the touch controller
touchDetector.detach();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not see a member function for .detach() in the Arduino_GigaDisplayTouch.h header. When making the change recommended the following error is given.

C:\GitHub\Arduino\Arduino_GigaDisplayTouch\examples\MultiTouchBlink_IRQ\MultiTouchBlink_IRQ.ino:30:17: error: 'class Arduino_GigaDisplayTouch' has no member named 'detach'
   touchDetector.detach();  // close the touch controller
                 ^~~~~~

Using library Arduino_GigaDisplayTouch at version 1.0.1 in folder: C:\Users\Ali Jahangiri\Documents\Arduino\libraries\Arduino_GigaDisplayTouch 
Using library Wire in folder: C:\Users\Ali Jahangiri\AppData\Local\Arduino15\packages\arduino\hardware\mbed_giga\4.1.3\libraries\Wire (legacy)
exit status 1

Compilation error: 'class Arduino_GigaDisplayTouch' has no member named 'detach'

I agree, having a detach() method would be greatly appreciated 😄 ! See #8

delay(250);
}
contactPoints = 0;
touchDetector.begin();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
touchDetector.begin();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree it is not a pretty solution, but it works. One should not use begin() in the middle of a sketch to restart the GT911 module. See: #11 (comment)

@aliphys
Copy link
Contributor Author

aliphys commented Jun 13, 2024

The MultiTouchBlink_Polling.ino example has an issue where sends the same message to the Serial twice, for a single touch event. It seems as if the values provided by touchDetector.getTouchPoints(points); are not flushed even with a one second delay.

contactPoints = touchDetector.getTouchPoints(points);

MultiTouchBlink_IRQ.ino

✅ Each touch event, is represented by a single message in the Serial Monitor (as well as a single Blink of the GIGA R1 WiFi LED)

VID_20240613_113431.mp4

MultiTouchBlink_Polling.ino

❌ Each touch event, is represented by a two messages in the Serial Monitor, separated by the delay value (as well as a duplicate Blink of the GIGA R1 WiFi LED)

VID_20240613_114511.mp4

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.

Examples not enough to convey power of this library 💪
2 participants