fix display binary format
This commit is contained in:
parent
043022186f
commit
2d17ff0de3
|
@ -15,6 +15,7 @@ internal sealed class DisplayConnection(IOptions<DisplayConfiguration> options)
|
||||||
public ValueTask SendClearAsync()
|
public ValueTask SendClearAsync()
|
||||||
{
|
{
|
||||||
var header = new HeaderWindow { Command = DisplayCommand.Clear };
|
var header = new HeaderWindow { Command = DisplayCommand.Clear };
|
||||||
|
|
||||||
return SendAsync(header, Memory<byte>.Empty);
|
return SendAsync(header, Memory<byte>.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +29,7 @@ internal sealed class DisplayConnection(IOptions<DisplayConfiguration> options)
|
||||||
PosX = x,
|
PosX = x,
|
||||||
PosY = y
|
PosY = y
|
||||||
};
|
};
|
||||||
|
|
||||||
return SendAsync(header, grid.Data);
|
return SendAsync(header, grid.Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +83,7 @@ internal sealed class DisplayConnection(IOptions<DisplayConfiguration> options)
|
||||||
{
|
{
|
||||||
Command = DisplayCommand.BitmapLinearWin,
|
Command = DisplayCommand.BitmapLinearWin,
|
||||||
PosX = x, PosY = y,
|
PosX = x, PosY = y,
|
||||||
Width = pixels.Width,
|
Width = (ushort)(pixels.Width / 8),
|
||||||
Height = pixels.Height
|
Height = pixels.Height
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -111,6 +113,7 @@ internal sealed class DisplayConnection(IOptions<DisplayConfiguration> options)
|
||||||
var buffer = _arrayPool.Rent(messageSize);
|
var buffer = _arrayPool.Rent(messageSize);
|
||||||
var message = buffer.AsMemory(0, messageSize);
|
var message = buffer.AsMemory(0, messageSize);
|
||||||
|
|
||||||
|
header.ChangeToNetworkOrder();
|
||||||
MemoryMarshal.Write(message.Span, header);
|
MemoryMarshal.Write(message.Span, header);
|
||||||
payload.CopyTo(message[headerSize..]);
|
payload.CopyTo(message[headerSize..]);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System.Buffers.Binary;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace DisplayCommands.Internals;
|
namespace DisplayCommands.Internals;
|
||||||
|
@ -14,4 +15,15 @@ internal struct HeaderWindow
|
||||||
public ushort Width;
|
public ushort Width;
|
||||||
|
|
||||||
public ushort Height;
|
public ushort Height;
|
||||||
}
|
|
||||||
|
public void ChangeToNetworkOrder()
|
||||||
|
{
|
||||||
|
if (!BitConverter.IsLittleEndian)
|
||||||
|
return;
|
||||||
|
Command = (DisplayCommand)BinaryPrimitives.ReverseEndianness((ushort)Command);
|
||||||
|
PosX = BinaryPrimitives.ReverseEndianness(PosX);
|
||||||
|
PosY = BinaryPrimitives.ReverseEndianness(PosY);
|
||||||
|
Width = BinaryPrimitives.ReverseEndianness(Width);
|
||||||
|
Height = BinaryPrimitives.ReverseEndianness(Height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue