/// <inheritdoc /> public void OpenPins(HardwareConfiguration configuration) { this.controller = new GpioController(PinNumberingScheme.Logical); foreach (var pin in configuration.Pins) { if (pin.Mode == HardwarePinConfigurationMode.Input) { this.controller.OpenPin(pin.LogicalPin); this.controller.RegisterCallbackForPinValueChangedEvent( pin.LogicalPin, PinEventTypes.Falling | PinEventTypes.Rising | PinEventTypes.None, this.OnPinValueChanged); } else { this.controller.OpenPin(pin.LogicalPin, PinMode.Output); this.controller.Write(pin.LogicalPin, PinValue.High); } } this.pins = configuration.Pins.ToList(); this.devices = OneWireThermometerDevice.EnumerateDevices().ToList(); foreach (var device in this.devices) { this.logger.LogDebug($"Found device bus={device.BusId}, id={device.DeviceId}, type={device.Family.ToString()}"); } }
/// <inheritdoc /> public void OpenPins(HardwareConfiguration configuration) { }
/// <summary> /// Initializes a new instance of the <see cref="HardwareManager"/> class. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="driver">The driver used to access the hardware.</param> public HardwareManager(IOptions <HardwareConfiguration> configuration, ILogger <HardwareManager> logger, IHardwareDriver driver) { this.driver = driver; this.logger = logger; this.configuration = configuration.Value; }