/// <summary>
 /// Initializes a new instance of the <see cref="RemotePiDevice" /> class.
 /// </summary>
 /// <param name="gpioController">The gpio controller.</param>
 /// <param name="shutdownButtonDevice">The shutdown button device.</param>
 /// <param name="shutdownOutPin">The shutdown out pin.</param>
 /// <param name="operatingSystemShutdown">The operation system shutdown.</param>
 /// <param name="activate">if set to <c>true</c> [activate].</param>
 /// <param name="shutdownTimeSpan">The shutdown time span.</param>
 /// <param name="dateTime">The date time.</param>
 public RemotePiDevice(
     GpioController gpioController,
     IButtonDevice shutdownButtonDevice,
     int shutdownOutPin,
     IOperatingSystemShutdown operatingSystemShutdown,
     bool activate,
     TimeSpan shutdownTimeSpan,
     IDateTime?dateTime = null)
 {
     this.gpioController          = gpioController;
     this.shutdownButtonDevice    = shutdownButtonDevice;
     this.shutdownOutPin          = shutdownOutPin;
     this.operatingSystemShutdown = operatingSystemShutdown;
     this.shutdownTimeSpan        = shutdownTimeSpan > MaxShutdownTimeSpan ? MaxShutdownTimeSpan : shutdownTimeSpan;
     this.dateTime = dateTime ?? new DateTimeProvider();
     this.thread   = new CurrentThread();
     this.shutdownButtonDevice.Pressed += this.OnShutdown;
     this.activation = new Activation(
         () => this.shutdownButtonDevice.IsActivated,
         () =>
     {
         this.shutdownButtonDevice.SetActivation(true);
         this.gpioController.OpenPin(this.shutdownOutPin, PinMode.Output);
     },
         () =>
     {
         this.shutdownButtonDevice.SetActivation(false);
         this.gpioController.ClosePin(this.shutdownOutPin);
     },
         activate);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RemotePiDevice" /> class.
 /// </summary>
 /// <param name="gpioController">The gpio controller.</param>
 /// <param name="shutdownButtonDevice">The shutdown button device.</param>
 /// <param name="shutdownOutPin">The shutdown out pin.</param>
 /// <param name="operatingSystemShutdown">The operation system shutdown.</param>
 /// <param name="activate">if set to <c>true</c> [activate].</param>
 /// <param name="shutdownTimeSpan">The shutdown time span.</param>
 public RemotePiDevice(
     GpioController gpioController,
     IButtonDevice shutdownButtonDevice,
     int shutdownOutPin,
     IOperatingSystemShutdown operatingSystemShutdown,
     bool activate,
     TimeSpan shutdownTimeSpan = default)
     : this(
         gpioController,
         shutdownButtonDevice,
         shutdownOutPin,
         operatingSystemShutdown,
         activate,
         shutdownTimeSpan,
         null)
 {
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InputControls" /> class.
 /// </summary>
 /// <param name="playPauseButton">The play pause button.</param>
 /// <param name="nextButton">The next button.</param>
 /// <param name="previousButton">The previous button.</param>
 /// <param name="menuButton">The menu button.</param>
 /// <param name="rfidTransceiver">The rfid transceiver.</param>
 /// <param name="remoteControl">The lirc connection.</param>
 /// <param name="rotaryEncoder">The ky040 connection.</param>
 /// <param name="buttonsGpioConnection">The buttons gpio connection.</param>
 public InputControls(
     IButtonDevice playPauseButton,
     IButtonDevice nextButton,
     IButtonDevice previousButton,
     IButtonDevice menuButton,
     IRfidConnection rfidTransceiver,
     ILircDevice remoteControl,
     IRotaryEncoderWithButtonDevice rotaryEncoder,
     IDisposable buttonsGpioConnection)
 {
     this.PlayPauseButton       = playPauseButton;
     this.NextButton            = nextButton;
     this.PreviousButton        = previousButton;
     this.MenuButton            = menuButton;
     this.RfidTransceiver       = rfidTransceiver;
     this.RemoteControl         = remoteControl;
     this.RotaryEncoder         = rotaryEncoder;
     this.ButtonsGpioConnection = buttonsGpioConnection;
 }