Ejemplo n.º 1
0
 private void InitializeRelayDevice(RelayDevice device)
 {
     controller.OpenPin(device.GpioId);
     controller.SetPinMode(device.GpioId, PinMode.Output);
     // Relay needs high
     controller.Write(device.GpioId, PinValue.High);
     // Store in map for quick access
     deviceMap.Add(device.Id, device);
 }
Ejemplo n.º 2
0
        public ToggleRelayStateResponse ToggleRelayState(ToggleRelayStateRequest request)
        {
            var response = new ToggleRelayStateResponse
            {
                GpioPin = request.GpioPin,
                State   = request.State
            };

            var pinValue = request.State == RelayState.On ? PinValue.High: PinValue.Low;

            if (pinValue == PinValue.High)
            {
                _gpioController.SetPinMode(request.GpioPin, PinMode.Output);
            }
            else
            {
                _gpioController.SetPinMode(request.GpioPin, PinMode.Input);
            }

            return(response);
        }
Ejemplo n.º 3
0
 public void SetPinMode(int pinNumber, PinMode mode)
 {
     _controller.SetPinMode(pinNumber, mode);
 }