public Task StopAsync(CancellationToken cancellationToken) { Console.WriteLine("Stopping Vending Service..."); if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { // Close the pins for the buttons Hardware.Gpio.ClosePin(HardwareAccess.INPUT_1); Hardware.Gpio.ClosePin(HardwareAccess.INPUT_2); Hardware.Gpio.ClosePin(HardwareAccess.INPUT_3); // Unregister Event Listeners Hardware.Gpio.UnregisterCallbackForPinValueChangedEvent(HardwareAccess.INPUT_1, Button_Released); Hardware.Gpio.UnregisterCallbackForPinValueChangedEvent(HardwareAccess.INPUT_2, Button_Released); Hardware.Gpio.UnregisterCallbackForPinValueChangedEvent(HardwareAccess.INPUT_3, Button_Released); Hardware.Gpio.UnregisterCallbackForPinValueChangedEvent(HardwareAccess.INPUT_1, Button_Pressed); Hardware.Gpio.UnregisterCallbackForPinValueChangedEvent(HardwareAccess.INPUT_2, Button_Pressed); Hardware.Gpio.UnregisterCallbackForPinValueChangedEvent(HardwareAccess.INPUT_3, Button_Pressed); // Turn off the lights Hardware.LightsOff(); } return(Task.CompletedTask); }
public IActionResult Lights([FromBody] bool value) { if (value) { _hardware.LightsOn(); } else { _hardware.LightsOff(); } return(Ok(value)); }