Add support for esp

This commit is contained in:
2025-07-19 18:59:53 +02:00
parent 732d7c8295
commit 5c26b8f8dd
12 changed files with 255 additions and 230 deletions

View File

@@ -0,0 +1,31 @@
using HomeApi.Models;
using HomeApi.Models.Configuration;
using MediatR;
using Microsoft.Extensions.Options;
namespace HomeApi.Handlers;
public static class Configuration
{
public record Command : IRequest<MicroProcessorConfiguration>;
public class Handler(IOptions<ApiConfiguration> configuration)
: IRequestHandler<Command, MicroProcessorConfiguration>
{
private readonly ApiConfiguration _apiConfiguration = configuration.Value;
public Task<MicroProcessorConfiguration> Handle(Command request, CancellationToken cancellationToken)
{
return Task.FromResult(new MicroProcessorConfiguration
{
InformationBoardImageUrl = _apiConfiguration.EspConfiguration.InformationBoardImageUrl,
UpdateIntervalMinutes = _apiConfiguration.EspConfiguration.UpdateIntervalMinutes,
BlackTextThreshold = _apiConfiguration.EspConfiguration.BlackTextThreshold,
ContrastStrength = _apiConfiguration.EspConfiguration.ContrastStrength,
DitheringStrength = _apiConfiguration.EspConfiguration.DitheringStrength,
EnableDithering = _apiConfiguration.EspConfiguration.EnableDithering,
EnhanceContrast = _apiConfiguration.EspConfiguration.EnhanceContrast
});
}
}
}