Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/razshare/zigberrypi
Zig library for interacting with raspberrypi's gpio
https://github.com/razshare/zigberrypi
gpio-pins raspberry-pi zig
Last synced: about 1 month ago
JSON representation
Zig library for interacting with raspberrypi's gpio
- Host: GitHub
- URL: https://github.com/razshare/zigberrypi
- Owner: razshare
- License: mit
- Created: 2023-05-31T16:58:13.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-06-02T14:08:59.000Z (over 1 year ago)
- Last Synced: 2024-05-28T13:28:37.093Z (7 months ago)
- Topics: gpio-pins, raspberry-pi, zig
- Language: Zig
- Homepage: https://aquila.red/1/tncrazvan/zigberrypi
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# zigberrypi
Zig library for interacting with raspberrypi's gpio## How to install
- add dependency
```sh
zigmod aq install 1/tncrazvan/zigberrypi
```
- add a reference for the dependency in `build.zig`
```zig
const deps = @import("deps.zig");
// ...
pub fn build(b: *std.Build) void {
// ...
deps.addAllTo(exe);
// ...
}
```
- import `zigberrypi` in your project with
```zig
const gpio = @import("zigberrypi");
```## Example
Blinking led example
```zig
const std = @import("std");
const gpio = @import("zigberrypi");fn sleepForTwoSeconds() void {
std.time.sleep(std.time.ns_per_s * 2);
}pub fn main() !void {
var active = false;
const pin11 = try gpio.openWritable(gpio.Pin.PIN11);
defer pin11.close();
while (true) {
try pin11.write(if (active) "1" else "0");
active = !active;
sleepForTwoSeconds();
}
}
```