feat: add IlluminatorService intencity changed events

This commit is contained in:
2026-02-19 08:15:42 +03:00
parent 1c315a6994
commit f1ce8ea572
+19 -3
View File
@@ -75,6 +75,10 @@ public class IlluminatorService : IDisposable
private readonly GpioPin _uv365Relay; private readonly GpioPin _uv365Relay;
private readonly GpioPin _fanRelay; private readonly GpioPin _fanRelay;
public event EventHandler<double>? WhiteIntencityChanged;
public event EventHandler<double>? Uv254IntencityChanged;
public event EventHandler<double>? Uv365IntencityChanged;
public IlluminatorService(ILogger<IlluminatorService> logger, IlluminatorServiceConfiguration? configuration = null) public IlluminatorService(ILogger<IlluminatorService> logger, IlluminatorServiceConfiguration? configuration = null)
{ {
_logger = logger; _logger = logger;
@@ -118,9 +122,21 @@ public class IlluminatorService : IDisposable
{ {
try try
{ {
if (white is not null) _whitePwm.DutyCycle = CalculateDuty(white.Value, _configuration.MaxWhitePwmDuty); if (white is not null)
if (uv365 is not null) _uv365Pwm.DutyCycle = CalculateDuty(uv365.Value, _configuration.MaxUv365PwmDuty); {
if (uv254 is not null) _uv254Pwm.DutyCycle = CalculateDuty(uv254.Value, _configuration.MaxUv254PwmDuty); _whitePwm.DutyCycle = CalculateDuty(white.Value, _configuration.MaxWhitePwmDuty);
WhiteIntencityChanged?.Invoke(this, white.Value);
}
if (uv365 is not null)
{
_uv365Pwm.DutyCycle = CalculateDuty(uv365.Value, _configuration.MaxUv365PwmDuty);
Uv365IntencityChanged?.Invoke(this, uv365.Value);
}
if (uv254 is not null)
{
_uv254Pwm.DutyCycle = CalculateDuty(uv254.Value, _configuration.MaxUv254PwmDuty);
Uv254IntencityChanged?.Invoke(this, uv254.Value);
}
} }
catch (Exception e) catch (Exception e)
{ {