-
-
Notifications
You must be signed in to change notification settings - Fork 968
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
New touch handler #492
New touch handler #492
Conversation
auto returnGesture = gesture; | ||
gesture = Drivers::Cst816S::Gestures::None; | ||
return returnGesture; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be simplified as return std::exchange(gesture, Drivers::Cst816S::Gestures::None);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be argued whether this is simpler or not. Anyone can read the current code, but I must not be the only one who's never heard of std::exchange()
before. I can change it though if this is important to comply with the "Modern C++" requirement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up to you ultimately, just a suggestion. I just like to mention things like these because as you said yourself there's lots of useful things in the standard library that many people aren't familiar with. I personally think that std::exchange
is nicer/simpler than the equivalent code to do it manually but YMMV.
For some reason the watch freezes if we swipe the screen multiple times while the watch is sleeping. |
Removing every |
I haven't look at the code, but it looks like you are improving the touch driver a lot! Regarding your last comment
Originally, the goal was to handle sleep/wakeup at one place. It was easy when all devices were put to sleep when the watch is going to sleep. Which calls to |
No. That's the only one i left. I just removed the three other ones in SystemTask.cpp. I don't know if just one of them was causing the problem. I was thinking maybe twiMaster could just be woken up in the Read() and Write() functions, so there wouldn't be any need to keep track of the state. After my first experiment, I got a bootloop, so I don't really wan't to mess with it any more right now since I don't have a devkit. But does this sound like a good idea? |
This seems to queue the last gesture given. |
I've been testing this today and it's certainly a lot faster than the old setup, but I've had a number of false inputs, taps interpreted as swipes and the inverse, also the watch locked up and rebooted after a game of 2048. I wonder if it needs some sort of debouncing or filtering, IE if something is interpreted as a swipe but moved only 10px, it's probably meant to be a tap... |
I remember it working quite well for me when I was testing it. I guess I'll have to test it some more. |
|
I'm testing it again with the ui/settings update and it seems to be behaving fine. It might have been that my screen was dirty! |
Further testing makes me think double tap to wake is not working correctly still, I have this PR plus UI/settings updates applied and double tap to wake is very unreliable. I'm going to test with just this PR, and with a stock build, but could you see if double tap to wake works correctly for you? It seems like it works fine at first but after a few hours it will not wake by double tap. |
I was testing the double tap to wake yesterday, and even after leaving the watch on a table overnight, the double tap worked first try in the morning. Maybe you're experiencing something related to the freezing issue, or the queueing issue I haven't fixed yet. I did find one issue though, which is probably what you were experiencing as well. This is what I wrote in #471:
If we do a very short and quick swipe in the app menu for example, LVGL doesn't care that we moved our finger, it sends a click event anyway where the screen was last touched. CancelTap() is used to combat this, but the swipe gesture arrives too late, and LVGL has already sent the event. I wish there was a way to disable this behaviour in LVGL, but we must work around it for now. EDIT: This is hard to test, so I'm not sure if this is actually an issue, or if it's technically working correctly. Still this wouldn't happen if this quirk in LVGL didn't exist. |
I tested overnight with a stock build and double tap worked reliably. I've just flashed a build with only this PR applied, I should know if it's reliable by the end of the day. I can't see how the UI updates PRs could have caused this behaviour, but we will see. |
Double tap wake is still being unreliable for me with this PR I'm afraid. I think we need someone else to test it. |
Great :+1 Thanks! So, in the end, if we merge #497, this PR is not WIP anymore, right? |
I just tested it with both PRs and it seems to work correctly as far as I can tell. |
LGTM! 👍 |
Hi, I tried to merge this to my P8 and watches react just to the first click/gesture. I'm sure there is different touch controller cst716 in the P8. I'm in the beginings of debugging it. If you have any idea what to check and touch datasheet with registers, that would help me a lot. it seems like a new configuration is sent to the driver, if I set 0x00 to this register it behaved the same way - only first touch gesture is detected after boot.
Then the Thank you. |
https://smarterwat.ch/soc-list/nordic-semiconductor/p8.html
Because of the difference in behaviour, info.touching will be false and the gesture won't be registered. The code would need to be tweaked slightly for the different controller.
This value could be used to detect the controller and adjust the touch handler accordingly. I've added reading this value in #489. |
Thanks for tips. And I'm not sure what this variable exactly does yet. I also did this hack and it seems that I could swipe many times now. However I still have issues with touch because isCancelled is false, |
CancelTap() is also related to this swipe behaviour in Cst816. If we swipe, the screen will switch while we're still touching the screen, and when we finally release, it may activate a button on the new screen. CancelTap() and isCancelled set the touch point to somewhere outside the screen, so when we release, it won't activate anything. So in practice, the touch has been cancelled and won't activate anything in LVGL. Releasing a touch generates an interrupt because of "EnChange" in irqCtl register, so UpdateLvglTouchPoints() gets run with info.touching being false, which should set isCancelled to false. This is also required for LVGL to detect release.
|
Do you have a proper datasheet with registers and bits explained? Thanks
|
The PineTime wiki has datasheets for the components This one has the registers. |
It's a pity P8 users got stuck with 0.13 because of this pull.
This value could be used to detect the controller and adjust the touch handler accordingly. I've added reading this value in #489.
Tried that but it doesn't help much only displaying a nice error message.
|
The touch driver now automatically detects whether a CST816s (pinetime) or CST716 (some p8 watches) chip is used, and adjusts the decoding logic accordingly. For more information, see the discussion on InfiniTimeOrg#492
I added support for the CST716 back in my fork, see StarGate01@6ecb9a1 . For more info, see #62 (comment) . It rarely detects a swipe as a touch, apart from that it works great. |
The touch driver now automatically detects whether a CST816s (pinetime) or CST716 (some p8 watches) chip is used, and adjusts the decoding logic accordingly. For more information, see the discussion on InfiniTimeOrg#492
The touch driver now automatically detects whether a CST816s (pinetime) or CST716 (some p8 watches) chip is used, and adjusts the decoding logic accordingly. For more information, see the discussion on InfiniTimeOrg#492
The touch driver now automatically detects whether a CST816s (pinetime) or CST716 (some p8 watches) chip is used, and adjusts the decoding logic accordingly. For more information, see the discussion on InfiniTimeOrg#492
The touch driver now automatically detects whether a CST816s (pinetime) or CST716 (some p8 watches) chip is used, and adjusts the decoding logic accordingly. For more information, see the discussion on InfiniTimeOrg#492
This code probably requires further stress testing to make sure it always works correctly.
Implements #471 and fixes #491.