diff --git a/GSS2.Core/Hardware/IlluminatorService.cs b/GSS2.Core/Hardware/IlluminatorService.cs index 05b3302..0f79c97 100644 --- a/GSS2.Core/Hardware/IlluminatorService.cs +++ b/GSS2.Core/Hardware/IlluminatorService.cs @@ -75,6 +75,10 @@ public class IlluminatorService : IDisposable private readonly GpioPin _uv365Relay; private readonly GpioPin _fanRelay; + public event EventHandler? WhiteIntencityChanged; + public event EventHandler? Uv254IntencityChanged; + public event EventHandler? Uv365IntencityChanged; + public IlluminatorService(ILogger logger, IlluminatorServiceConfiguration? configuration = null) { _logger = logger; @@ -118,9 +122,21 @@ public class IlluminatorService : IDisposable { try { - if (white is not null) _whitePwm.DutyCycle = CalculateDuty(white.Value, _configuration.MaxWhitePwmDuty); - if (uv365 is not null) _uv365Pwm.DutyCycle = CalculateDuty(uv365.Value, _configuration.MaxUv365PwmDuty); - if (uv254 is not null) _uv254Pwm.DutyCycle = CalculateDuty(uv254.Value, _configuration.MaxUv254PwmDuty); + if (white is not null) + { + _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) {