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

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

Closed

Conversation

franz-ms-muc
Copy link
Contributor

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

Copy link

github-actions bot commented Jan 18, 2024

Messages
📖 🎉 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 🚫 dangerJS against 46050bc

…NORMAL event

Added calls for `BUTTON_PRESS_NORMAL` in `iot_button.c` when the button is pressed down or released.
@franz-ms-muc
Copy link
Contributor Author

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.

@github-actions github-actions bot changed the title feat(button): Refactor button press enum values and add BUTTON_PRESS_NORMAL event feat(button): Refactor button press enum values and add BUTTON_PRESS_NORMAL event (AEGHB-527) Jan 18, 2024
@lijunru-hub
Copy link
Contributor

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.

@franz-ms-muc
Copy link
Contributor Author

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.

@lijunru-hub
Copy link
Contributor

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.

@diplfranzhoepfinger
Copy link

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
Copy link

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

@lijunru-hub
Copy link
Contributor

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

@diplfranzhoepfinger
Copy link

Cool I will test it. Good work.

@lijunru-hub
Copy link
Contributor

@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

@diplfranzhoepfinger
Copy link

yes, did work .

@diplfranzhoepfinger
Copy link

BUTTON_PRESS_NORMAL not needed anymore.

@leeebo
Copy link
Collaborator

leeebo commented Jul 9, 2024

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

@leeebo leeebo closed this Jul 9, 2024
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.

4 participants