示例#1
0
        /// <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()}");
            }
        }
示例#2
0
 /// <inheritdoc />
 public void OpenPins(HardwareConfiguration configuration)
 {
 }
示例#3
0
 /// <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;
 }