I am starting my adventure with IoT and got some blinking led experience behind me. But now I wanted to do some more advanced thing so I figured I try to read infrared signals from remotes. Now everything is based on rPi3.
So what I have is:
let private _onPinValueChanged (gpioController: GpioController) =
new PinChangeEventHandler (
fun _ _ ->
Console.WriteLine DateTime.Now
Console.WriteLine (gpioController.Read GpioIrIn)) //pin number is 18
let StartIrRead (gpioController: GpioController) (cancellationToken: CancellationToken) =
let worker =
async {
Console.WriteLine $"Opening PIN {GpioIrIn}"
gpioController.OpenPin (GpioIrIn, PinMode.Input)
match gpioController.IsPinOpen GpioIrIn with
| true -> gpioController.RegisterCallbackForPinValueChangedEvent (GpioIrIn, PinEventTypes.Rising, _onPinValueChanged gpioController)
| false -> raise (Exception($"Problem with opening PIN {GpioIrIn}"))
}
Async.Start (worker, cancellationToken)
And well it works to some matter. Event is firing up when I point a remote on it and press any button, but what I understand I need pulse or some values, but what I am getting is just PinStatus (eg. High). So how can I register that signal and convert it so I can send it back?