PowerShell / PowerShell-IoT

Interact with I2C, SPI & GPIO devices using PowerShell Core!
https://www.powershellgallery.com/packages/Microsoft.PowerShell.IoT
MIT License
129 stars 28 forks source link

Allow the registering of change events #31

Open TylerLeonhardt opened 6 years ago

TylerLeonhardt commented 6 years ago

It would look something like this:

Register-GpioPinChangeEvent -Type LowToHigh -ScriptBlock {
    Write-Host "do the thing"
}

# and

Register-GpioPinChangeEvent -Type HighToLow -ScriptPath foo.ps1

Under the hood it could use Register-ObjectEvent to allow the script execution to be in the same runspace.

Unosquare docs here: https://github.com/unosquare/raspberryio#interrupts-and-callbacks

jnury commented 6 years ago

Really useful to handle I2C devices that use interrupts pins !

TylerLeonhardt commented 6 years ago

Changed the title so it doesn't only apply to GPIO :)

matswi commented 4 years ago

@TylerLeonhardt Would this make it possible to detect button being pressed?

TylerLeonhardt commented 4 years ago

That's the idea, yes

matswi commented 4 years ago

That's the idea, yes

That would be really nice! :) I'm afraid I don't have the skills to make it but would be happy to help with testing it. Is there any plan on moving forward with it?

DanielSSilva commented 4 years ago

@matswi we are currently migrating to .NET IoT library. The closest that we will have so far (I think) "out of the box" will be the possibility to register an event for changes https://github.com/dotnet/iot/blob/master/src/System.Device.Gpio/System/Device/Gpio/GpioController.cs#L281-L296 There's no ETA I'm afraid