Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn pin on/off #107

Open
bodovix opened this issue Jan 21, 2019 · 3 comments
Open

Turn pin on/off #107

bodovix opened this issue Jan 21, 2019 · 3 comments

Comments

@bodovix
Copy link

bodovix commented Jan 21, 2019

I've been experimenting with this library but haven't been able to find a direct turn pin on or off? we can toggle or blink. but these require being me to be aware of the pins current state before toggling.
To achieve this I ended up using the extension methods below.
Is there a better way to do this currently? or is this something that we would maybe need?
(couldn't get the 'code text 'thing formatting properly...)

public static class GwydsGreatExtensionMethods
{
public static void TurnOn(this GpioConnection gpioConn, ProcessorPin pin)
{
GpioConnectionDriver driver = new GpioConnectionDriver();
if (driver.Read(pin) == false)
{
gpioConn[pin] = !gpioConn[pin];
Console.WriteLine("Light Turned on");
}
else
{
//already on. no need to toggle
Console.WriteLine("already on.");
}
}
public static void TurnOff(this GpioConnection gpioConn, ProcessorPin pin)
{
GpioConnectionDriver driver = new GpioConnectionDriver();
if (driver.Read(pin) == true)
{
gpioConn[pin] = !gpioConn[pin];
Console.WriteLine("Light Turned off");
}
else
{
Console.WriteLine("already off.");
}
}
}

@rgelb
Copy link

rgelb commented Jan 26, 2019

I think this project is dead. Last commit happened over 2 years ago.

@bfsmithATL
Copy link

bfsmithATL commented Jan 26, 2019

No, not dead, just sleepy. It’s just not receiving new feature activity, although it’s a bummer to see those outstanding pull requests that are so stale. Core functionality is stable, I use it regularly on about 10 different RasPi’s.

@bodovix bodovix changed the title Button, OnStatusChangeAction not working. Turn pin on/off Jan 26, 2019
@bfsmithATL
Copy link

@bodovix You might try checking out JTrotta's fork of raspberry-sharp, it has been kept up to date nicely:

https://github.com/JTrotta/RaspberrySharp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants