Remove underscores from examples

This commit is contained in:
2023-12-13 17:28:19 -08:00
parent ecbe272c1b
commit 3adc525084
3 changed files with 2 additions and 2 deletions

19
examples/blinky.zig Normal file
View File

@@ -0,0 +1,19 @@
const std = @import("std");
const gpio = @import("gpio");
pub fn main() !void {
var chip = try gpio.getChip("/dev/gpiochip2");
defer chip.close();
try chip.setConsumer("blinky");
std.debug.print("Chip Name: {s}\n", .{chip.name});
var line = try chip.requestLine(22, .{ .output = true });
defer line.close();
while (true) {
try line.setHigh();
std.time.sleep(std.time.ns_per_s);
try line.setLow();
std.time.sleep(std.time.ns_per_s);
}
}

27
examples/multi.zig Normal file
View File

@@ -0,0 +1,27 @@
const std = @import("std");
const gpio = @import("gpio");
pub fn main() !void {
var chip = try gpio.getChip("/dev/gpiochip0");
defer chip.close();
try chip.setConsumer("multi");
std.debug.print("Chip Name: {s}\n", .{chip.name});
// Request the lines with offsets 26, 27, 28, and 29 as outputs.
var lines = try chip.requestLines(&.{ 26, 27, 28, 29 }, .{ .output = true });
defer lines.close();
// Alternate between lines 27/29 and 26/28 being high
while (true) {
// Set lines 27 and 29 as low (off)
try lines.setLow(&.{ 1, 3 });
// Set lines 26 and 28 as high (on)
try lines.setHigh(&.{ 0, 2 });
std.time.sleep(std.time.ns_per_s);
// Set lines 26 and 28 as low (off)
try lines.setLow(&.{ 0, 2 });
// Set lines 27 and 28 as high (on)
try lines.setHigh(&.{ 1, 3 });
std.time.sleep(std.time.ns_per_s);
}
}