Git Product home page Git Product logo

Comments (4)

MajicDesigns avatar MajicDesigns commented on July 17, 2024

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.

wolfgamM avatar wolfgamM commented on July 17, 2024

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:

  1. pressing 2 keys cannot be done simultaneously by a user. There is always a time difference.
  2. 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.

MajicDesigns avatar MajicDesigns commented on July 17, 2024

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.

MajicDesigns avatar MajicDesigns commented on July 17, 2024

Version 2.0.0 implements KEY_DOWN and KEY_UP events notification.

from md_uiswitch.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.