{"id":17713739,"url":"https://github.com/duart38/deno_gpio","last_synced_at":"2025-06-18T09:41:13.791Z","repository":{"id":43756543,"uuid":"460576105","full_name":"duart38/deno_gpio","owner":"duart38","description":"TS Deno Interface to help communicate with the raspberry pi's GPIO pins","archived":false,"fork":false,"pushed_at":"2022-03-20T13:54:49.000Z","size":53,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-09-16T15:08:28.974Z","etag":null,"topics":["deno","gpio","raspberry-pi","sysfs","sysfs-gpio"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/duart38.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}},"created_at":"2022-02-17T19:22:17.000Z","updated_at":"2024-05-17T02:45:59.000Z","dependencies_parsed_at":"2022-08-21T20:00:31.048Z","dependency_job_id":null,"html_url":"https://github.com/duart38/deno_gpio","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duart38%2Fdeno_gpio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duart38%2Fdeno_gpio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duart38%2Fdeno_gpio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duart38%2Fdeno_gpio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/duart38","download_url":"https://codeload.github.com/duart38/deno_gpio/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223849432,"owners_count":17213640,"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":["deno","gpio","raspberry-pi","sysfs","sysfs-gpio"],"created_at":"2024-10-25T10:22:23.014Z","updated_at":"2024-11-09T16:03:32.747Z","avatar_url":"https://github.com/duart38.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Raspberry pi GPIO helpers made for Deno\n\nAn interface for interacting and reading from the raspberry pi GPIO pins using\n_sysfs_.\n\n## Why?\n\n\u003e Just for shits and giggles. Also why not? LOL!\n\n# Examples\n\n### Turning on an LED:\n\n```TypeScript\n/*\n- set pin direction to out. will queue up an instruction to auto-export the pin\n- also sets the pin value to high. RPis do not have analogue: 1 for HIGH 0 for LOW\n*/\nimport { executeInstructions, Pin, PinDirection, sleep } from \"./mod.ts\";\n\n// full bash-level execution.\nconst led = new Pin(24, PinDirection.OUT, 1);\nsleep(5);\nled.setValue(0);\nled.unexport();\nexecuteInstructions(); // executes the above instructions.\n```\n\nit is **highly recommended** you unexport the pin after you are done using it.\n\nIt is also possible to take a more hybrid approach in which you come back to\njavascript:\n\n```TypeScript\n// alternative hybrid (transfer from bash to JS and vice-versa)\n// note that this approach is a bit slower and can cause timing issues with some 'dumb' sensors that require precise instruction sequences.\nconst led = new Pin(24, PinDirection.OUT, 1);\n// the Pin constructor queues up some export instructions.. we are executing these here\nexecuteInstructions(); // calls sysfs. returns a promise.\n\n// standard JS timeout..\nsetTimeout(() =\u003e {\n  led.setValue(0);\n  led.unexport();\n  executeInstructions();\n}, 4000);\n```\n\n### Listening for button press\n\n```TypeScript\nimport { executeInstructions, Pin, PinDirection } from \"./mod.ts\";\n\nconst button = new Pin(24, PinDirection.IN);\n// the Pin constructor queues up some export instructions.. execute here.\nawait executeInstructions();\nconsole.log(\"Waiting for button press\");\n\nwhile (true) {\n  if (button.readValue() == 1) {\n    console.log(\"button pressed\");\n    button.unexport();\n    executeInstructions();\n    break;\n  }\n}\n```\n\n### Waiting for a pin to be a specific value\nThe following will issue an instruction to wait until the provided pin is set to HIGH (1) before continuing executing other commands:\n```TypeScript\nconst button = new Pin(24, PinDirection.IN);\nbutton.waitForValue(); // wait (and thus blocking) occurs here\nbutton.unexport();\nawait executeInstructions(); // this is where the main loop gets blocked in JavaScript.\n```\n\u003e Note that this blocking will happen in the sub-process created by Deno and will not block the JavaScript loop unless we use async await. it is also important to note that the blocking happens at the point of execution (i.e., when 'await executeInstructions();' is called)\n\n# Limitations\n\n1. JavaScript it not very 'precise'. i.e. no microsecond delay support for\n   interacting with hardware that requires this (e.g. DHT11). To circumvent\n   this, a method named _pipeValue_ can be used to add read instructions in the\n   instruction queue which will be executed along other instructions (including\n   sleep instructions) in a shell.\n\n# Deno on the pi?\n\n\u003e YES!!!!\n\u003e [This will explain it all](https://github.com/LukeChannings/deno-arm64)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduart38%2Fdeno_gpio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fduart38%2Fdeno_gpio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduart38%2Fdeno_gpio/lists"}