Comments (4)
Use 2 instances of the UISwitch objects to detect 2 keys at the same time.
Your use case is interesting and not really well handled by UISwitch - I'll think about what can be done to support this better in a future release.
from md_uiswitch.
Hello,
Use 2 instances of the UISwitch objects to detect 2 keys at the same time.
With 2 instances you run into the problem that keyResult_t enumeration is not sufficiant.
KEY_RELEASED, KEY_CLICKED and KEY_DBLCLICKED would be helpful.
Assume:
- pressing 2 keys cannot be done simultaneously by a user. There is always a time difference.
- normal user operation is startet with: KEY_PRESS
Problem:
With 2 instances, you need 2 subsequent .read() methods which are delayed at least for the debounce time. With getting the first KEY_PRESS (after debounce time), you cannot know whether the second key comes soon or not. So a normal user action starts with KEY_PRESS (after debounce time).
Solution:
a) A possible solution is to check for actions on an alternative port during debounce time
b) to introduce new members to keyResult_t enumeration.
User Action starts alternatively on a KEY_CLICKED.
When using KEY_PRESSED there can be several checks on other KEY_PRESSED instances with KEY_RELEASED.
regards
Wolfgang
from md_uiswitch.
The library needs a KEY_DOWN and a KEY_UP notification for what you want to do. This means the way debouncing is done in the library needs to change as well, but the current structure does not support this easily. Switch debounce needs to happen before the FSM is invoked. This would also simplify the FSM.
As mentioned in the first response, I'll probably add this in a future release as I have already thought about this restructure, but I have no plan for this yet. I would also not expect that the 'two key' solution will be implemented in the library as this is too specific, but the additional notifications will support the user code to do what it needs.
from md_uiswitch.
Version 2.0.0 implements KEY_DOWN and KEY_UP events notification.
from md_uiswitch.
Related Issues (12)
- multiple push button HOT 1
- Issue in 2.0.0 with multiple MD_UISwitch_Digital instances HOT 2
- Tolerance to "too long" long press HOT 3
- Unable to get a long press response from MD_UISwitch_Digital HOT 1
- Thinking about also using PCF8574 HOT 4
- Detect multiple concurrent button presses or long presses. HOT 4
- False positive for KEY_SINGLE HOT 3
- Debouncing Algorithm sensitive to short presses HOT 1
- Example MD_UISwitch compilation error HOT 2
- Navigation problem with ADKeyboard Module v2 DFRobot HOT 1
- Version 2.0 is not backward compatible with 1.2.x HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from md_uiswitch.