{"id":25613224,"url":"https://github.com/myfreax/esp32-adc-button","last_synced_at":"2026-02-15T22:32:29.077Z","repository":{"id":163930877,"uuid":"639227525","full_name":"myfreax/esp32-adc-button","owner":"myfreax","description":"Button component driven by ADC voltage sampling","archived":false,"fork":false,"pushed_at":"2024-07-25T07:39:32.000Z","size":69,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-19T03:04:07.189Z","etag":null,"topics":["adc","button","driver","esp32"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/myfreax.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":"2023-05-11T03:13:19.000Z","updated_at":"2024-07-25T07:39:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"97081b27-a4dc-4e95-b450-b06a5a09fd54","html_url":"https://github.com/myfreax/esp32-adc-button","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/myfreax/esp32-adc-button","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myfreax%2Fesp32-adc-button","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myfreax%2Fesp32-adc-button/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myfreax%2Fesp32-adc-button/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myfreax%2Fesp32-adc-button/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/myfreax","download_url":"https://codeload.github.com/myfreax/esp32-adc-button/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myfreax%2Fesp32-adc-button/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29490889,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T19:29:10.908Z","status":"ssl_error","status_checked_at":"2026-02-15T19:29:10.419Z","response_time":118,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["adc","button","driver","esp32"],"created_at":"2025-02-22T01:29:29.187Z","updated_at":"2026-02-15T22:32:29.047Z","avatar_url":"https://github.com/myfreax.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ESP32 ADC Button\n\nCan be used not only for buttons driven via ADC, but also for other driving methods, depending on the sampling function you pass\n\n## Feature\n\n- Detect button press, long press and release event and triger event callback\n- Allow Pass custom parameter to event callback function\n- Pass button open and close state to callback function\n- Allow you grouping button by set grouping id\n- Automatically reset the state of other buttons in the current group\n- Combine button support. You can press one of button then press other button\n- Define multiple long buttons to use for a specified time\n## Dependences\n- [ESP32 Time Component](https://github.com/myfreax/esp32-time)\n\n## Steup\n```shell\ngit submodule add git@github.com:myfreax/esp32-time.git components/datetime\ngit submodule add git@github.com:myfreax/esp32-adc-button.git components/button_driver\n```\n\n## Usage\n```c\n#include \"button_driver.h\"\n#include \"esp_log.h\"\n#include \"freertos/FreeRTOS.h\"\n#include \"freertos/task.h\"\nstatic uint32_t button_sampling_voltage(void* arg) {\n  // your code ...\n  return 1234;\n}\nstatic void light_long_press(void* arg, int64_t time_us, bool state, button_config_t* button) {}\nstatic void light_release(void* arg, int64_t time_us, bool state, button_config_t* button) {}\n// more ...\n\nvoid app_main(void) {\n  static const char* TAG = \"BUTTON-DRIVER\";\n\n  // custom params pass button event callback  \n  button_params_t button_params = {\n      .screen = screen,\n  };\n  // configure ESP32 ADC\n  adc_chan_t* button_adc =\n      adc_chan_config(ADC_CHANNEL_0, ADC_BITWIDTH_DEFAULT, ADC_ATTEN_DB_12);\n\n  // power button\n  long_press_t* power_presses[] = {\n      button_create_press(power_long_press, 1.5),\n  };\n  button_config_t* power_button = button_create(\n      \"power\", 0, 100, 798, false, power_release, power_press_once,\n      power_presses, sizeof(power_presses) / sizeof(long_press_t*), \u0026ctx);\n  // light button\n  long_press_t* light_presses[] = {\n      button_create_press(light_long_press, 1.5),\n      button_create_press(light_falsh_mode, 5),\n  };\n  button_config_t* light_button = button_create(\n      \"light\", 1, 799, 1349, false, light_release, light_press_once,\n      light_presses, sizeof(light_presses) / sizeof(long_press_t*), \u0026ctx);\n  // AC button\n  long_press_t* ac_presses[] = {\n      button_create_press(ac_long_press, 1.5),\n  };\n  button_config_t* ac_button = button_create(\n      \"AC\", 2, 1350, 1869, false, ac_release, ac_press_once, ac_presses,\n      sizeof(ac_presses) / sizeof(long_press_t*), \u0026ctx);\n  // Standby button\n  long_press_t* standby_presses[] = {\n      button_create_press(standby_long_press, 1.5),\n  };\n  button_config_t* standby_button = button_create(\n      \"standby\", 3, 1870, 2139, false, standby_release, standby_press_once,\n      standby_presses, sizeof(standby_presses) / sizeof(long_press_t*), \u0026ctx);\n\n  // DC button\n  long_press_t* dc_presses[] = {\n      button_create_press(dc_long_press, 1.5),\n  };\n  button_config_t* dc_button = button_create(\n      \"DC\", 4, 2140, 2250, false, dc_release, dc_press_once, dc_presses,\n      sizeof(dc_presses) / sizeof(long_press_t*), \u0026ctx);\n\n  button_config_t* buttons[] = {light_button, dc_button, power_button,\n                                ac_button, standby_button};\n  // create driver configuration params and pass buttons and sampling rate,\n  // debounce time, sampling function and params of sampling function\n  button_driver_config_t* button_driver_config = button_driver_config_create(\n      buttons, sizeof(buttons) / sizeof(button_config_t*), 15, 30000,\n      button_adc, button_sampling_voltage);\n  button_driver_install(button_driver_config, 8192, 25);\n\n  while (1) {\n    ESP_LOGI(TAG, \"Main Thread Task\");\n    vTaskDelay(1000 / portTICK_PERIOD_MS);\n  }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyfreax%2Fesp32-adc-button","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmyfreax%2Fesp32-adc-button","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyfreax%2Fesp32-adc-button/lists"}