{"id":14963289,"url":"https://github.com/mauriciobarroso/button","last_synced_at":"2025-10-25T00:32:03.133Z","repository":{"id":45829297,"uuid":"472028402","full_name":"mauriciobarroso/button","owner":"mauriciobarroso","description":"ESP-IDF component to drive multiple instances of tactile switches buttons","archived":false,"fork":false,"pushed_at":"2025-01-24T16:44:50.000Z","size":44,"stargazers_count":16,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-24T17:32:29.350Z","etag":null,"topics":["button","debounce","double-click","esp-idf","esp-idf-component","esp32","esp32c3","esp32s2","esp32s3","multifunction","oop","switch","tactile-switches"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mauriciobarroso.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-20T15:56:47.000Z","updated_at":"2025-01-24T16:44:54.000Z","dependencies_parsed_at":"2024-04-20T22:37:55.517Z","dependency_job_id":"d70df55b-7f28-4b70-963a-2a6b3e76b8c2","html_url":"https://github.com/mauriciobarroso/button","commit_stats":{"total_commits":22,"total_committers":2,"mean_commits":11.0,"dds":0.5,"last_synced_commit":"feb476992ec0aa93e0e15e5645c933df928a5553"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauriciobarroso%2Fbutton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauriciobarroso%2Fbutton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauriciobarroso%2Fbutton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauriciobarroso%2Fbutton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mauriciobarroso","download_url":"https://codeload.github.com/mauriciobarroso/button/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238053514,"owners_count":19408699,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["button","debounce","double-click","esp-idf","esp-idf-component","esp32","esp32c3","esp32s2","esp32s3","multifunction","oop","switch","tactile-switches"],"created_at":"2024-09-24T13:31:18.600Z","updated_at":"2025-10-25T00:32:03.128Z","avatar_url":"https://github.com/mauriciobarroso.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Button Driver for Tactile Switches Buttons Compatible with ESP-IDF and STM32CubeIDE\n\nA lightweight, FreeRTOS-based button driver for ESP32 and STM32 platforms. Provides robust debouncing, event detection, and deferred callback dispatch with minimal RTOS overhead.\n\n## Features\n\n* **Event detection**: single-click, double-click, press, hold, and long-press\n* **Adjustable timings**: debounce interval, double-click window, hold and long-press durations\n* **Efficient RTOS usage**: only one software timer, one queue, and one dispatcher task required\n* **Configurable dispatcher**: set task priority, stack size, and dispatch interval to suit your application\n* **Compile-time scaling**: define the maximum number of button instances for optimized resource allocation\n* **Ready for ESP-IDF**: made to be integrated as component in ESP-IDF projects\n\n## Examples\n\n* [Print press type](examples/print_press_type)\n\n## How to use\n\nA quick guide to use a single button and define its associated actions.\n\n1. **Define a button instance**\n\n   ```c\n   button_t button;\n   ```\n\n2. **Initialize the button**\n\n   ```c\n   /* Replace GPIO_NUM and GPIO_PORT with your hardware definitions */\n   button_init(\u0026button, GPIO_NUM, GPIO_PORT);\n   ```\n\n3. **Register callbacks for each event**\n\n   ```c\n   void on_single(void *arg)  { /* handle single click */ }\n   void on_double(void *arg)  { /* handle double click */ }\n\n   button_register_action(\u0026button, BUTTON_TYPE_SINGLE, on_single,  NULL);\n   button_register_action(\u0026button, BUTTON_TYPE_DOUBLE, on_double,  NULL);\n   ```\n\n4. **Unregister unwanted callbacks**\n\n   ```c\n   button_unregister_action(\u0026button, BUTTON_TYPE_DOUBLE);\n   ```\n\n5. **Deinitialize when done**\n\n   ```c\n   button_deinit(\u0026button);\n   ```\n\n## Dependencies\n\n* [FSM Library for Embedded C Projects](https://github.com/mauriciobarroso/fsm)\n\n## Roadmap\n\n* Implement button priority levels and conflict resolution\n* Add support for bare-metal (no-RTOS) environments\n* Provide keypad matrix and ADC-based button drivers\n\n## License\n\nMIT License\n\nCopyright (c) 2025 Mauricio Barroso Benavides\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauriciobarroso%2Fbutton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmauriciobarroso%2Fbutton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauriciobarroso%2Fbutton/lists"}