Pamoja.Gpio
0.1.18
dotnet add package Pamoja.Gpio --version 0.1.18
NuGet\Install-Package Pamoja.Gpio -Version 0.1.18
<PackageReference Include="Pamoja.Gpio" Version="0.1.18" />
<PackageVersion Include="Pamoja.Gpio" Version="0.1.18" />
<PackageReference Include="Pamoja.Gpio" />
paket add Pamoja.Gpio --version 0.1.18
#r "nuget: Pamoja.Gpio, 0.1.18"
#:package Pamoja.Gpio@0.1.18
#addin nuget:?package=Pamoja.Gpio&version=0.1.18
#tool nuget:?package=Pamoja.Gpio&version=0.1.18
Pamoja.Gpio
I2C address frames with reserved-range checks, the four SPI clock modes, and active-high or active-low pins. One capability of pamoja, one memory-safe Rust core with bindings for TypeScript, Python, and C#.
Install
dotnet add package Pamoja.Gpio
using Pamoja.Gpio;
This pulls in Pamoja.Native, the compiled engine. dotnet add package Pamoja is the whole framework in one package.
Example
The guide project's example, spliced here as it ran in CI.
From bindings/dotnet/samples/Pamoja.Guides/GpioGuide.cs:
// Most relay boards energize when their input is pulled low, and a float switch
// wired to ground closes the same way. Saying "active low" once, here, is what
// keeps the inversion out of every line below it.
const PinPolarity Relay = PinPolarity.ActiveLow;
const PinPolarity Float = PinPolarity.ActiveLow;
var pump = new Line();
var floatSwitch = new Line(PinLevel.High, PinLevel.Low);
Console.WriteLine(
$"a pump on an active-low relay runs when its line is {Pin.LevelFor(Relay, true)}");
// The pump runs while the tank fills. The stand-in line answers open and then
// closed, so this is the real loop with nothing plugged in.
pump.Drive(Pin.LevelFor(Relay, true));
bool whileFilling = Pin.IsAsserted(Float, floatSwitch.Read());
bool onceFilled = Pin.IsAsserted(Float, floatSwitch.Read());
Console.WriteLine($"the float reads full: {whileFilling}, then {onceFilled}");
// The moment the float closes is that line going low, which is a falling edge. A
// watch armed for the rising one would sleep through the tank filling.
bool closing = Pin.Triggers(PinEdge.Falling, PinLevel.High, PinLevel.Low);
Console.WriteLine($"the float closing is a falling edge on that line: {closing}");
// Full, so the pump stops, and the levels the line was driven to are the whole
// conversation the board saw.
pump.Drive(Pin.LevelFor(Relay, false));
(PinLevel ran, PinLevel stopped) = (pump.Driven[0], pump.Driven[1]);
Console.WriteLine($"running drove the line {ran} and stopping drove it {stopped}");
// A part on a shared bus answers to an address, and the byte on the wire is not
// the address the datasheet prints: it shifts up one and the low bit says read or
// write.
byte toWrite = I2c.AddressFrame(0x76)[0];
byte toRead = I2c.AddressFrame(0x76, read: true)[0];
Console.WriteLine(
$"a part at 0x76 is written to as 0x{toWrite:X2} and read from as 0x{toRead:X2}");
// Two ranges belong to the specification itself, so a part answering in either is
// a wiring mistake rather than a device.
bool reserved = I2c.IsReserved(I2c.ReservedFrom);
Console.WriteLine(
$"0x{I2c.ReservedFrom:X2} is reserved by the specification: {reserved}");
// And a datasheet quotes SPI's clock polarity and phase as one mode number.
SpiClock clock = Spi.ClockFor(3);
Console.WriteLine(
$"SPI mode 3 idles high: {clock.Cpol}, samples on the trailing edge: {clock.Cpha}");
The same capability in every language
| Language | Package | Reference |
|---|---|---|
| Rust | pamoja-gpio |
reference, docs.rs, install |
| TypeScript | @pamoja/gpio |
reference, install |
| Python | pamoja-gpio |
reference, install |
| C# | Pamoja.Gpio |
reference, install |
Documentation
Pamoja.Gpioreference, every type in this namespace.- The I2C, SPI, and GPIO guide, with the same example in Rust, TypeScript, and Python.
- Every capability, and the install page.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Pamoja.Native (>= 0.1.18)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Pamoja.Gpio:
| Package | Downloads |
|---|---|
|
Pamoja
The whole pamoja framework in one package: every capability of one memory-safe Rust core, behind an idiomatic C# facade, for IoT, robotics, and drones. |
|
|
Pamoja.FieldIo
Field I/O: The wires a gateway actually has: framed serial packets, an RS485 request and the reply it draws, a CAN frame, the address a chip answers on, and the bus that carries a driver to the part. |
GitHub repositories
This package is not used by any popular GitHub repositories.