{"id":15142080,"url":"https://github.com/funnygeeker/circuitpython-easybutton","last_synced_at":"2026-02-27T01:31:56.154Z","repository":{"id":215278822,"uuid":"738545615","full_name":"funnygeeker/circuitpython-easybutton","owner":"funnygeeker","description":"Multi-button state recognition implemented using loops, suitable for CircuitPython 使用循环实现的多种按钮状态识别，适用于 CircuitPython","archived":false,"fork":false,"pushed_at":"2024-01-03T13:50:29.000Z","size":5,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T15:17:39.945Z","etag":null,"topics":["button","circuitpython","esp32","esp32-c3","esp32-s3","esp8266","loop","rp2040"],"latest_commit_sha":null,"homepage":"","language":"Python","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/funnygeeker.png","metadata":{"files":{"readme":"README.ZH-CN.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":"2024-01-03T13:28:35.000Z","updated_at":"2024-07-22T01:56:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"0fb6f315-59d2-4af6-a173-e3f5fe710e43","html_url":"https://github.com/funnygeeker/circuitpython-easybutton","commit_stats":{"total_commits":2,"total_committers":2,"mean_commits":1.0,"dds":0.5,"last_synced_commit":"ff70dab5d6bc96006a61cf26f2a40c1daad48a62"},"previous_names":["funnygeeker/circuitpython-easybutton"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/funnygeeker/circuitpython-easybutton","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnygeeker%2Fcircuitpython-easybutton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnygeeker%2Fcircuitpython-easybutton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnygeeker%2Fcircuitpython-easybutton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnygeeker%2Fcircuitpython-easybutton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/funnygeeker","download_url":"https://codeload.github.com/funnygeeker/circuitpython-easybutton/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnygeeker%2Fcircuitpython-easybutton/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29880728,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T23:51:21.483Z","status":"ssl_error","status_checked_at":"2026-02-26T23:50:46.793Z","response_time":89,"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":["button","circuitpython","esp32","esp32-c3","esp32-s3","esp8266","loop","rp2040"],"created_at":"2024-09-26T09:22:26.749Z","updated_at":"2026-02-27T01:31:56.136Z","avatar_url":"https://github.com/funnygeeker.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[English (英语)](./README.md)\n# circuitpython-easybutton\n- 使用循环实现的多种按钮状态识别，按钮按下时执行指定函数，适用于 `circuitpython`\n\n### 功能\n- 按钮按下后，每隔一段时间执行一次函数\n- 按钮短按后，松开时执行函数\n- 按钮长按后，松开时执行函数\n- 按钮按下时执行函数\n- 按钮松开时执行函数\n\n### 说明\n`./main.py` 为使用示例文件\n`./lib/easybutton.py` 为按钮库文件\n\n### 示例\n- 在本次示例中，按钮所在的引脚接按钮，按钮接的是 `GND`\n\n```python\nimport board\nimport digitalio\nfrom lib.easybutton import EasyButton, Button\n\n# 配置按钮引脚\npin = digitalio.DigitalInOut(board.GP0)\npin.direction = digitalio.Direction.INPUT\npin.pull = digitalio.Pull.DOWN\n\n\n# Define functions, they can be defined first or later used as anonymous functions\n# 定义函数，可以先定义，也可以后续使用匿名函数\ndef test():\n    print(\"^ UP ^\")\n\n\nb = Button(pin)\n# Set trigger functions for the button\nb.up_func = test  # Executed when the button is released  # 按钮松开时执行函数\nb.down_func = lambda: print(\"v DOWN v\")  # Executed when the button is pressed  # 按钮按下时执行\nb.long_func = lambda: print(\"+ LONG +\")  # Executed when the button is long pressed and released  # 按钮长按后，松开时执行\nb.hold_func = lambda: print(\"| HOLD |\")  # Executed at regular intervals after the button is pressed  # 按钮按下后，每隔一段时间执行一次\nb.short_func = (print, \"- SHORT -\")  # Executed when the button is short pressed and released  # 按钮短按后，松开时执行\neb = EasyButton(interval=100)\neb.add(b)\neb.run()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunnygeeker%2Fcircuitpython-easybutton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunnygeeker%2Fcircuitpython-easybutton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunnygeeker%2Fcircuitpython-easybutton/lists"}