esp-iot-solution icon indicating copy to clipboard operation
esp-iot-solution copied to clipboard

feat(button): Refactor button press enum values and add BUTTON_PRESS_NORMAL event (AEGHB-527)

Open franz-ms-muc opened this issue 1 year ago • 9 comments

  • Refactored the enum values for button press in iot_button.h to include a new value BUTTON_PRESS_NORMAL.
  • Added calls to the event callback function for BUTTON_PRESS_NORMAL in iot_button.c when the button is pressed down or released.

These changes improve the clarity and flexibility of handling different button press events.

franz-ms-muc avatar Jan 18 '24 12:01 franz-ms-muc

Messages
:book: 🎉 Good Job! All checks are passing!

👋 Hello franz-ms-muc, we appreciate your contribution to this project!


Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by :no_entry_sign: dangerJS against 46050bc1e9d5b29ccb1ed552af8b5ad42d0cb073

github-actions[bot] avatar Jan 18 '24 12:01 github-actions[bot]

With this Callback to event Type NORMAL, 

one can Register 3 Callbacks:

  • BUTTON_PRESS_NORMAL
  • BUTTON_PRESS_UP
  • BUTTON_PRESS_DOWN

While the UP and DOWN Presses work as before, the "NORMAL" one gets both the Down and Up Events. 

for use in a IEC 61499 Environment see Video: Devcon23 - Turning the ESP32 into a PLC with the Eclipse 4diac™ Framework: The Project logiBUS® this maps then:

  • BUTTON_PRESS_NORMAL maps to a IX
  • BUTTON_PRESS_UP maps to a IE
  • BUTTON_PRESS_DOWN maps to a IE

so this Button Driver then is a VERY Flexible Solution.

franz-ms-muc avatar Jan 18 '24 12:01 franz-ms-muc

Hi franz-ms-muc:

Why introduce the BUTTON_PRESS_NORMAL event? Users can register the same callback for different events and use iot_button_get_event within the callback to determine which event was triggered. This approach offers flexibility in handling multiple events with a single callback.

lijunru-hub avatar Jan 18 '24 12:01 lijunru-hub

Hi,

Why,

it is not about register the same Callback for several Events but register 3 Callbacks:

one only get the UP Events, another only get the DOWN Events, and a third is getting up and Down Events.

franz-ms-muc avatar Jan 28 '24 16:01 franz-ms-muc

The button now supports registering multiple callback functions for a single event. You can register the same function for both the 'up' and 'down' events to handle both, and then separately register functions to specifically handle 'up' and 'down' events if needed.

It seems that we may not need the 'normal' event in this context.

lijunru-hub avatar Jan 29 '24 03:01 lijunru-hub

The button now supports registering multiple callback functions for a single event. You can register the same function for both the 'up' and 'down' events to handle both, and then separately register functions to specifically handle 'up' and 'down' events if needed.

It seems that we may not need the 'normal' event in this context.

you can Register 2 Callbacks for 1 Event ?

diplfranzhoepfinger avatar Jan 31 '24 17:01 diplfranzhoepfinger

The button now supports registering multiple callback functions for a single event. OK, will test. then we do not need this ! cool. !!!!!!

diplfranzhoepfinger avatar Jan 31 '24 17:01 diplfranzhoepfinger

The button now supports registering multiple callback functions for a single event. You can register the same function for both the 'up' and 'down' events to handle both, and then separately register functions to specifically handle 'up' and 'down' events if needed. It seems that we may not need the 'normal' event in this context.

you can Register 2 Callbacks for 1 Event ?

Yes. Please see https://docs.espressif.com/projects/esp-iot-solution/en/latest/input_device/button.html#register-callback-function

lijunru-hub avatar Feb 01 '24 03:02 lijunru-hub

Cool I will test it. Good work.

diplfranzhoepfinger avatar Feb 01 '24 06:02 diplfranzhoepfinger

@franz-ms-muc Hi, can the current button component meet your needs? If there are no other issues, this PR will be closed. Thank you for your contribution

lijunru-hub avatar Jul 08 '24 08:07 lijunru-hub

yes, did work .

diplfranzhoepfinger avatar Jul 08 '24 08:07 diplfranzhoepfinger

BUTTON_PRESS_NORMAL not needed anymore.

diplfranzhoepfinger avatar Jul 08 '24 08:07 diplfranzhoepfinger

@franz-ms-muc @diplfranzhoepfinger @lijunru-hub Thanks, I will close this PR since it is no longer needed

leeebo avatar Jul 09 '24 11:07 leeebo