{"id":18768650,"url":"https://github.com/slimenull/stc89c52rc_keyclick","last_synced_at":"2026-06-19T21:31:50.318Z","repository":{"id":104253779,"uuid":"504846868","full_name":"SlimeNull/STC89C52RC_KeyClick","owner":"SlimeNull","description":"在STC89C52RC(普中51实验板)中检查按钮是否按下的简单库","archived":false,"fork":false,"pushed_at":"2022-06-21T01:30:20.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-25T00:40:14.364Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SlimeNull.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-06-18T13:09:08.000Z","updated_at":"2023-03-30T13:19:07.000Z","dependencies_parsed_at":"2023-07-22T11:33:51.616Z","dependency_job_id":null,"html_url":"https://github.com/SlimeNull/STC89C52RC_KeyClick","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SlimeNull/STC89C52RC_KeyClick","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SlimeNull%2FSTC89C52RC_KeyClick","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SlimeNull%2FSTC89C52RC_KeyClick/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SlimeNull%2FSTC89C52RC_KeyClick/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SlimeNull%2FSTC89C52RC_KeyClick/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SlimeNull","download_url":"https://codeload.github.com/SlimeNull/STC89C52RC_KeyClick/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SlimeNull%2FSTC89C52RC_KeyClick/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34549340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-19T02:00:06.005Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-07T19:13:28.363Z","updated_at":"2026-06-19T21:31:50.313Z","avatar_url":"https://github.com/SlimeNull.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KeyClick\n\n独立按键点击检测封装. 通过简单的方式来控制按键单击的处理逻辑.\n\n## 使用:\n\n1. 将仓库中 btnclick.h 和 btnclick.c 文件添加到你的项目中\n2. 引用头文件\n   ```cpp\n   #include \"btnclick.h\"\n   ```\n3. 在程序中添加主循环逻辑:\n\n    ```cpp\n    void main()\n    {\n        // 其他代码\n\n        while (1)  // 程序主循环\n        {\n            // 其他代码\n            btnclick_loop();     // 按钮检查\n        }\n    }\n    ```\n\n4. 定义按键按下处理函数:\n\n    ```cpp\n    void key1click()\n    {\n        P2 = ~P2;    // 切换 LED 灯显示状态\n    }\n    ```\n\n5. 订阅按键按下事件\n\n    ```cpp\n    void main()\n    {\n        on_k1_click(key1click);   // 订阅按键按下事件\n\n        while (1)\n        {\n            btnclick_loop();        // 主循环\n        }\n    }\n    ```\n\n## 函数\n\n在 loops.c 文件中, 定义了以下函数:\n\n```cpp\nvoid button_loop();                         // 按钮主循环\nvoid on_k1_click(void (*handler)());        // 订阅按钮1按下事件\nvoid on_k2_click(void (*handler)());        // 订阅按钮2按下事件\nvoid on_k3_click(void (*handler)());        // 订阅按钮3按下事件\nvoid on_k4_click(void (*handler)());        // 订阅按钮4按下事件\nvoid on_anyk_click(void (*handler)(int));   // 订阅任意按钮按下事件, 参数为按钮索引\n```\n\n## 代码示例\n\n```cpp\n#include \u003cREGX52.H\u003e\n#include \"btnclick.h\"\n\nvoid switch_led(int index) {\n\tP2 ^= ((1 \u003c\u003c (index * 2)) + (1 \u003c\u003c (index * 2 + 1)));\n}\n\nvoid main()\n{\n\ton_anyk_click(switch_led);\n\t\n\twhile(1)\n\t{\n\t\tbtnclick_loop();\n\t}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslimenull%2Fstc89c52rc_keyclick","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslimenull%2Fstc89c52rc_keyclick","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslimenull%2Fstc89c52rc_keyclick/lists"}