Prepares RioJoy.Core for the net40 (Windows XP) target, which has no System.Memory, ValueTask, or System.Text.Json: - IRioTransport and the whole protocol/framing layer now use byte[] + Task (RioPacket.Payload, PacketParser/Builder, RioChecksum, replies, AnalogReport, RioHidReport). At 9600 baud Span bought nothing; the SerialPortTransport bridge copies disappear entirely. - ConfigStore/OverlayTemplateStore switch to Newtonsoft 13 with the same conventions (indented, PascalCase, string enums, null-skipping); verified against the real STJ-written config.json and regions.json (load + round-trip). System.Memory and System.Text.Json packages dropped. 275 tests green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
53 lines
2.0 KiB
C#
53 lines
2.0 KiB
C#
using RioJoy.Core.Serial;
|
|
|
|
namespace RioJoy.Core.Plasma;
|
|
|
|
/// <summary>
|
|
/// Drives the plasma / VFD text display over its (secondary) serial transport,
|
|
/// writing the ESC sequences built by <see cref="PlasmaCommands"/>. Thin async
|
|
/// wrapper around an <see cref="IRioTransport"/>; the display is write-only. The
|
|
/// content shown is per-profile (Phase 5+).
|
|
/// </summary>
|
|
public sealed class PlasmaDisplay
|
|
{
|
|
private readonly IRioTransport _transport;
|
|
|
|
public PlasmaDisplay(IRioTransport transport)
|
|
{
|
|
_transport = transport ?? throw new ArgumentNullException(nameof(transport));
|
|
}
|
|
|
|
public Task ClearAsync(CancellationToken ct = default) =>
|
|
WriteAsync(PlasmaCommands.Clear(), ct);
|
|
|
|
public Task CursorHomeAsync(CancellationToken ct = default) =>
|
|
WriteAsync(PlasmaCommands.CursorHome(), ct);
|
|
|
|
public Task TextAsync(string text, CancellationToken ct = default) =>
|
|
WriteAsync(PlasmaCommands.Text(text), ct);
|
|
|
|
/// <summary>
|
|
/// Position the cursor, set attribute + font, and write text — the
|
|
/// <c>PlasmaPosText</c> sequence (auto-fit via
|
|
/// <see cref="PlasmaCommands.ResolvePosText"/>). Pass (0,0) to auto-center.
|
|
/// </summary>
|
|
public async Task PosTextAsync(
|
|
string text, byte x = 0, byte y = 0, byte attr = 0, byte font = 0,
|
|
CancellationToken ct = default)
|
|
{
|
|
if (string.IsNullOrEmpty(text))
|
|
return;
|
|
|
|
(byte rx, byte ry, byte rfont, int len) = PlasmaCommands.ResolvePosText(text, x, y, font);
|
|
|
|
await WriteAsync(PlasmaCommands.CursorX(rx), ct).ConfigureAwait(false);
|
|
await WriteAsync(PlasmaCommands.CursorY(ry), ct).ConfigureAwait(false);
|
|
await WriteAsync(PlasmaCommands.FontAttr(attr), ct).ConfigureAwait(false);
|
|
await WriteAsync(PlasmaCommands.Font(rfont), ct).ConfigureAwait(false);
|
|
await WriteAsync(PlasmaCommands.Text(text[..len]), ct).ConfigureAwait(false);
|
|
}
|
|
|
|
private Task WriteAsync(byte[] data, CancellationToken ct) =>
|
|
_transport.WriteAsync(data, ct);
|
|
}
|