Remove underscores from examples
This commit is contained in:
19
examples/blinky.zig
Normal file
19
examples/blinky.zig
Normal 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
27
examples/multi.zig
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user