Compare commits

..

No commits in common. "83bba359cb1be28ef1c561a2d9e80332ec31116b" and "82d7ab5e6f9eb7cc648a975d26fe03774b61d568" have entirely different histories.

3 changed files with 2 additions and 32 deletions

View file

@ -19,13 +19,7 @@ namespace Proculite.GpioRest.Controllers
if (!ModelState.IsValid) if (!ModelState.IsValid)
return BadRequest(); return BadRequest();
return Ok(_gpioService.PinValueModelOfPin(pinNumber)); return Ok(_gpioService.CurrentPinValue(pinNumber).ToString());
}
[HttpGet("pin-value")]
public IActionResult AllPinValues()
{
return Ok(_gpioService.StateOfAllPins());
} }
} }
} }

View file

@ -1,14 +0,0 @@
using System.Device.Gpio;
using System.Text.Json.Serialization;
namespace Proculite.GpioRest.Models
{
public class PinValueModel(int pinNumber, PinValue pinValue)
{
public int PinNumber { get; set; } = pinNumber;
[JsonIgnore]
public PinValue PinValue { get; set; } = pinValue;
public int Value => PinValue == PinValue.High ? 1 : 0;
}
}

View file

@ -1,5 +1,4 @@
using System.Device.Gpio; using System.Device.Gpio;
using Proculite.GpioRest.Models;
namespace Proculite.GpioRest.Services namespace Proculite.GpioRest.Services
{ {
@ -41,6 +40,7 @@ namespace Proculite.GpioRest.Services
} }
_gpioController.OpenPin(pin, pinMode, PinValue.Low); _gpioController.OpenPin(pin, pinMode, PinValue.Low);
Thread.Sleep(200);
} }
} }
@ -48,15 +48,5 @@ namespace Proculite.GpioRest.Services
{ {
return _gpioController.Read(pinNumber); return _gpioController.Read(pinNumber);
} }
public PinValueModel PinValueModelOfPin(int pinNumber)
{
return new PinValueModel(pinNumber, _gpioController.Read(pinNumber));
}
public PinValueModel[] StateOfAllPins()
{
return _pins.Select(PinValueModelOfPin).ToArray();
}
} }
} }