Compare commits
No commits in common. "83bba359cb1be28ef1c561a2d9e80332ec31116b" and "82d7ab5e6f9eb7cc648a975d26fe03774b61d568" have entirely different histories.
83bba359cb
...
82d7ab5e6f
|
|
@ -19,13 +19,7 @@ namespace Proculite.GpioRest.Controllers
|
|||
if (!ModelState.IsValid)
|
||||
return BadRequest();
|
||||
|
||||
return Ok(_gpioService.PinValueModelOfPin(pinNumber));
|
||||
}
|
||||
|
||||
[HttpGet("pin-value")]
|
||||
public IActionResult AllPinValues()
|
||||
{
|
||||
return Ok(_gpioService.StateOfAllPins());
|
||||
return Ok(_gpioService.CurrentPinValue(pinNumber).ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
using System.Device.Gpio;
|
||||
using Proculite.GpioRest.Models;
|
||||
|
||||
namespace Proculite.GpioRest.Services
|
||||
{
|
||||
|
|
@ -41,6 +40,7 @@ namespace Proculite.GpioRest.Services
|
|||
}
|
||||
|
||||
_gpioController.OpenPin(pin, pinMode, PinValue.Low);
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -48,15 +48,5 @@ namespace Proculite.GpioRest.Services
|
|||
{
|
||||
return _gpioController.Read(pinNumber);
|
||||
}
|
||||
|
||||
public PinValueModel PinValueModelOfPin(int pinNumber)
|
||||
{
|
||||
return new PinValueModel(pinNumber, _gpioController.Read(pinNumber));
|
||||
}
|
||||
|
||||
public PinValueModel[] StateOfAllPins()
|
||||
{
|
||||
return _pins.Select(PinValueModelOfPin).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue