do not send frames when nothing changes

This commit is contained in:
Vinzenz Schroeter 2024-04-12 19:54:16 +02:00
parent 89494ef495
commit de3d298475
5 changed files with 54 additions and 13 deletions

View file

@ -13,6 +13,7 @@ internal sealed class SendToServicePointDisplay : ITickStep
private readonly PlayerServer _players;
private readonly ILogger<SendToServicePointDisplay> _logger;
private readonly IDisplayConnection _displayConnection;
private PixelGrid? _lastSentFrame;
private DateTime _nextFailLog = DateTime.Now;
@ -50,7 +51,12 @@ internal sealed class SendToServicePointDisplay : ITickStep
try
{
await _displayConnection.SendCp437DataAsync(MapService.TilesPerRow, 0, _scoresBuffer);
await _displayConnection.SendBitmapLinearWindowAsync(0, 0, _lastFinishedFrameProvider.LastFrame);
var currentFrame = _lastFinishedFrameProvider.LastFrame;
if (_lastSentFrame == currentFrame)
return;
_lastSentFrame = currentFrame;
await _displayConnection.SendBitmapLinearWindowAsync(0, 0, _lastSentFrame);
}
catch (SocketException ex)
{