{"id":24640995,"url":"https://github.com/cnadler86/micropython_joystick","last_synced_at":"2025-03-20T11:48:48.280Z","repository":{"id":274135690,"uuid":"922019985","full_name":"cnadler86/Micropython_Joystick","owner":"cnadler86","description":"A simple and fast library for joysticks over ADC","archived":false,"fork":false,"pushed_at":"2025-01-25T06:45:06.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T11:48:43.124Z","etag":null,"topics":["joystick","micropython"],"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/cnadler86.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":"2025-01-25T05:20:59.000Z","updated_at":"2025-01-25T06:45:09.000Z","dependencies_parsed_at":"2025-01-25T06:34:32.706Z","dependency_job_id":null,"html_url":"https://github.com/cnadler86/Micropython_Joystick","commit_stats":null,"previous_names":["cnadler86/micropython_joystick"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnadler86%2FMicropython_Joystick","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnadler86%2FMicropython_Joystick/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnadler86%2FMicropython_Joystick/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnadler86%2FMicropython_Joystick/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cnadler86","download_url":"https://codeload.github.com/cnadler86/Micropython_Joystick/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244609431,"owners_count":20480782,"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":["joystick","micropython"],"created_at":"2025-01-25T12:11:58.061Z","updated_at":"2025-03-20T11:48:48.249Z","avatar_url":"https://github.com/cnadler86.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Joystick Library for MicroPython\n\nThis repository contains a simple and efficient MicroPython library for interfacing with a joystick module. The library provides calibration, scaling, and real-time value retrieval for both axes (X and Y) and an optional button.\n\n## Features\n- **X and Y Axis Support**: Reads analog joystick values and scales them to a range of -100 to 100.\n- **Button Support**: Handles an optional button for input.\n- **Calibration**: Automatically calibrates the joystick's center position.\n- **High Performance**: Optimized for speed with native decorators and efficient sampling.\n\n## Usage\n\n### Initialization\n```python\nfrom joystick import Joystick\n\n# Initialize the joystick on pin 1 for X-axes, pin 2 for Y-axes and pin 3 for the button (optional).\njoystick = Joystick(1, 2, 3)\n```\n\n### Accessing Joystick Values\n```python\n# Get the scaled X and Y values (-100 to 100)\nx_value = joystick.x\ny_value = joystick.y\n\n# Get button state (True if pressed, False otherwise)\nbutton_state = joystick.b\n```\n\n### Example\n```python\nimport time\nfrom joystick import Joystick\n\njoystick = Joystick(1, 2, 3, CalValues=20)\n\nwhile True:\n    print(f\"X: {joystick.x}, Y: {joystick.y}, Button: {joystick.b}\")\n    time.sleep(0.25)\n```\n\n## Performance Benchmark\nOn a ESP32S3 the library can get all values together at aprox. 7.7 kHz.\n\n## Notes\n- Adjust the `CalValues` parameter for better calibration accuracy. Higher values result in more samples being averaged.\n- Ensure the joystick is in the center position during calibration.\n- If the button is not used, set `PinButton=None` or don't pass the argument at all.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnadler86%2Fmicropython_joystick","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcnadler86%2Fmicropython_joystick","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnadler86%2Fmicropython_joystick/lists"}