{"id":13481045,"url":"https://github.com/Nilhcem/keypad-androidthings","last_synced_at":"2025-03-27T11:31:38.127Z","repository":{"id":141783910,"uuid":"96333454","full_name":"Nilhcem/keypad-androidthings","owner":"Nilhcem","description":"Matrix Keypad driver for Android Things","archived":false,"fork":false,"pushed_at":"2018-05-10T16:48:17.000Z","size":383,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-08-01T17:24:35.684Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/Nilhcem.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2017-07-05T15:20:22.000Z","updated_at":"2018-05-12T17:45:02.000Z","dependencies_parsed_at":"2023-03-17T05:15:40.162Z","dependency_job_id":null,"html_url":"https://github.com/Nilhcem/keypad-androidthings","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nilhcem%2Fkeypad-androidthings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nilhcem%2Fkeypad-androidthings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nilhcem%2Fkeypad-androidthings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nilhcem%2Fkeypad-androidthings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nilhcem","download_url":"https://codeload.github.com/Nilhcem/keypad-androidthings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222239502,"owners_count":16953961,"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":[],"created_at":"2024-07-31T17:00:48.068Z","updated_at":"2024-10-30T14:31:15.195Z","avatar_url":"https://github.com/Nilhcem.png","language":"Java","funding_links":[],"categories":["Useful links"],"sub_categories":["Drivers"],"readme":"# Matrix Keypad driver for Android Things\n\n## Download\n\n```groovy\ndependencies {\n    compile 'com.nilhcem.androidthings:driver-keypad:0.0.3'\n}\n```\n\n## Usage\n\n```java\nString[] rowPins = new String[]{\"BCM12\", \"BCM16\", \"BCM20\", \"BCM21\"};\nString[] colPins = new String[]{\"BCM25\", \"BCM24\", \"BCM23\", \"BCM27\"};\n \nKeypad keypad = new Keypad(rowPins, colPins, Keypad.KEYS_4x4);\n// For a 3x4 matrix, you can use the \"Keypad.KEYS_3x4\" constant. You can also set your own custom keys.\n \nkeypad.register(new Keypad.OnKeyEventListener() {\n    @Override\n    public void onKeyEvent(KeyEvent keyEvent) {\n        String action = keyEvent.getAction() == KeyEvent.ACTION_DOWN ? \"ACTION_DOWN\" : \"ACTION_UP\";\n        Log.i(TAG, \"onKeyEvent: (\" + action + \"): \" + keyEvent.getDisplayLabel());\n    }\n});\n \n// Don't forget to:\nkeypad.unregister();\nkeypad.close();\n```\n\nAlternatively, you can register a `KeypadInputDriver` with the system and receive `KeyEvents` through the standard Android APIs:\n\n```java\nKeypadInputDriver mInputDriver;\n\ntry {\n    mInputDriver = new KeypadInputDriver(rowPins, colPins, Keypad.KEYS_4x4);\n    mInputDriver.register();\n} catch (IOException e) {\n    // error configuring keypad...\n}\n\n// Override key event callbacks in your Activity:\n\n@Override\npublic boolean onKeyDown(int keyCode, KeyEvent event) {\n    Log.i(TAG, \"onKeyDown: \" + event.getDisplayLabel());\n    return true;\n}\n\n@Override\npublic boolean onKeyUp(int keyCode, KeyEvent event) {\n    Log.i(TAG, \"onKeyUp: \" + event.getDisplayLabel());\n    return true;\n}\n\n// Unregister and close the input driver when finished:\n\nmInputDriver.unregister();\ntry {\n    mInputDriver.close();\n} catch (IOException e) {\n    // error closing input driver\n}\n```\n\nAlso, don't forget to add the required permission to your app's manifest file:\n\n```xml\n\u003cuses-permission android:name=\"com.google.android.things.permission.MANAGE_INPUT_DRIVERS\" /\u003e\n```\n\n### Schematic\n\nThe sample is for a 4x4 Membrane Matrix Keypad, but the library should work for any keypad formats (e.g. 3x4).  \nWe use 1k pull-up resistors for the rows\n\n![schematic][]\n\n![rowscols][]\n\n* Row 1 -\u003e BCM12\n* Row 2 -\u003e BCM16\n* Row 3 -\u003e BCM20\n* Row 4 -\u003e BCM21\n* Col 1 -\u003e BCM25\n* Col 2 -\u003e BCM24\n* Col 3 -\u003e BCM23\n* Col 4 -\u003e BCM27\n\n## Kudos to\n\n* [Polidea][polidea] for the Polithings numpad12 driver.\n* [ciromattia][ciromattia] for the Fritzing 4x4 membrane matrix keypad.\n\n[rowscols]: https://raw.githubusercontent.com/Nilhcem/keypad-androidthings/master/assets/rowscols.png\n[schematic]: https://raw.githubusercontent.com/Nilhcem/keypad-androidthings/master/assets/schematic.png\n\n[polidea]: https://github.com/Polidea/Polithings/tree/master/numpad\n[ciromattia]: https://github.com/ciromattia/Fritzing-Library\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNilhcem%2Fkeypad-androidthings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNilhcem%2Fkeypad-androidthings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNilhcem%2Fkeypad-androidthings/lists"}