more commands, change display communication to new lib
This commit is contained in:
parent
38463ac109
commit
7213318838
31 changed files with 240 additions and 417 deletions
|
@ -1,5 +1,6 @@
|
|||
using System.Buffers;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
@ -74,6 +75,27 @@ internal sealed class DisplayConnection(IOptions<DisplayConfiguration> options)
|
|||
_arrayPool.Return(payloadBuffer);
|
||||
}
|
||||
|
||||
public ValueTask SendBitmapLinearWindowAsync(ushort x, ushort y, PixelGrid pixels)
|
||||
{
|
||||
var header = new HeaderWindow
|
||||
{
|
||||
Command = DisplayCommand.BitmapLinearWin,
|
||||
PosX = x, PosY = y,
|
||||
Width = pixels.Width,
|
||||
Height = pixels.Height
|
||||
};
|
||||
|
||||
return SendAsync(header, pixels.Data);
|
||||
}
|
||||
|
||||
public string GetLocalIPv4()
|
||||
{
|
||||
using var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, 0);
|
||||
socket.Connect(options.Value.Hostname, options.Value.Port);
|
||||
var endPoint = socket.LocalEndPoint as IPEndPoint ?? throw new NotSupportedException();
|
||||
return endPoint.Address.ToString();
|
||||
}
|
||||
|
||||
private async ValueTask SendAsync(HeaderWindow header, Memory<byte> payload)
|
||||
{
|
||||
int headerSize;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
namespace DisplayCommands.Internals;
|
||||
|
||||
internal enum DisplaySubCommand
|
||||
internal enum DisplaySubCommand : ushort
|
||||
{
|
||||
BitmapNormal = 0x0,
|
||||
BitmapCompressZ = 0x677a,
|
||||
|
|
17
DisplayCommands/Internals/HeaderBitmap.cs
Normal file
17
DisplayCommands/Internals/HeaderBitmap.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DisplayCommands.Internals;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 16, Size = 10)]
|
||||
internal struct HeaderBitmap
|
||||
{
|
||||
public DisplayCommand Command;
|
||||
|
||||
public ushort Offset;
|
||||
|
||||
public ushort Length;
|
||||
|
||||
public DisplaySubCommand SubCommand;
|
||||
|
||||
public ushort Reserved;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue