feat: keep OSD always visible with pre-map fullscreen states (#3)
This commit is contained in:
+57
-35
@@ -6,60 +6,82 @@ import (
|
||||
"git.piksar.eu/piotr/groundstation/internal/osd"
|
||||
)
|
||||
|
||||
// SnapshotSource serves the latest supervisor-published OSD snapshot while
|
||||
// it is fresh. The file-backed implementation lives in the osd package; the
|
||||
// template only consumes the contract.
|
||||
// SnapshotSource serves the latest supervisor-published OSD snapshot and its
|
||||
// state (none / fresh / stale). The file-backed implementation lives in the
|
||||
// osd package; the template only consumes the contract.
|
||||
type SnapshotSource interface {
|
||||
Latest() (osd.Snapshot, bool)
|
||||
Latest() (osd.Snapshot, osd.SnapshotState)
|
||||
}
|
||||
|
||||
// OSDTemplate is the flight OSD layout of a display target: a transparent,
|
||||
// input-transparent surface above pilot video. While decoded video is
|
||||
// absent the fallback canvas owns the screen and the OSD presents nothing;
|
||||
// while video is present the OSD draws deliberately minimal telemetry from
|
||||
// the latest published snapshot — arm state and requested CH6 WFB power.
|
||||
// The rendering gate is the video presence the display observes on the
|
||||
// display server, never the snapshot's Video field: the supervisor's field
|
||||
// is its launcher knowledge, while the display trusts only the presented
|
||||
// video output itself. The OSD never draws the fallback: it is a telemetry
|
||||
// surface, not a video substitute, and WFB or video decode never move into
|
||||
// the UI process to feed it. The OSD refreshes on its own slower cadence
|
||||
// than the video and the video window keeps rendering priority.
|
||||
// input-transparent surface above everything else on the screen. It renders
|
||||
// from startup — on top of the no-video fallback presentation and above
|
||||
// fullscreen video alike — and never gates on video presence: the video
|
||||
// lifecycle the display observes on the display server is itself displayed
|
||||
// as the VIDEO line, never the snapshot's Video field. ARM and the compact
|
||||
// adaptive-link line come from the latest snapshot; a stale last-known
|
||||
// snapshot stays visible and marked DATA STALE, and before any snapshot has
|
||||
// existed the OSD shows explicit NO DATA / unknown marks. The OSD never
|
||||
// draws the fallback: it is a telemetry surface, not a video substitute,
|
||||
// and WFB or video decode never move into the UI process to feed it. The
|
||||
// OSD refreshes on its own slower cadence than the video and the video
|
||||
// window keeps rendering priority.
|
||||
type OSDTemplate struct {
|
||||
video *VideoPresence
|
||||
source SnapshotSource
|
||||
}
|
||||
|
||||
// NewOSDTemplate builds the OSD surface for a target from the shared video
|
||||
// presence and the supervisor-published snapshot source.
|
||||
// NewOSDTemplate builds the OSD surface for a target from the shared
|
||||
// display-observed video presence and the supervisor-published snapshot
|
||||
// source.
|
||||
func NewOSDTemplate(video *VideoPresence, source SnapshotSource) OSDTemplate {
|
||||
return OSDTemplate{video: video, source: source}
|
||||
}
|
||||
|
||||
func (t OSDTemplate) Draw(canvas Canvas) {
|
||||
canvas.Clear()
|
||||
if t.video.Active() {
|
||||
if snapshot, ok := t.source.Latest(); ok {
|
||||
drawOSD(canvas, snapshot)
|
||||
}
|
||||
}
|
||||
snapshot, state := t.source.Latest()
|
||||
t.draw(canvas, snapshot, state)
|
||||
canvas.Flush()
|
||||
}
|
||||
|
||||
// drawOSD renders the deliberately minimal flight telemetry: the arm state
|
||||
// and one compact adaptive-link line — the operator's target table, the
|
||||
// temporary CH6 maxPower ceiling, the requested runtime level and the
|
||||
// applied VTX state. Values whose producers do not exist yet render at
|
||||
// their explicit pending marks. The full final RC state stays in the
|
||||
// snapshot; the pilot-facing overlay stays terse, and static configuration
|
||||
// is never rendered as applied VTX state.
|
||||
func drawOSD(canvas Canvas, snapshot osd.Snapshot) {
|
||||
arm := "OFF"
|
||||
if snapshot.Armed {
|
||||
arm = "ARMED"
|
||||
// draw renders the deliberately minimal telemetry lines in the top-left
|
||||
// corner: arm state, the adaptive-link contract, an optional staleness or
|
||||
// no-data marker, and the observed video state. The full final RC state
|
||||
// stays in the snapshot; the pilot-facing overlay stays terse.
|
||||
func (t OSDTemplate) draw(canvas Canvas, snapshot osd.Snapshot, state osd.SnapshotState) {
|
||||
y := 32
|
||||
switch state {
|
||||
case osd.SnapshotNone:
|
||||
canvas.Text(32, y, "NO DATA")
|
||||
y += 32
|
||||
canvas.Text(32, y, "VTX tbl:-- ceil:-- req:-- ack:--")
|
||||
y += 32
|
||||
default:
|
||||
canvas.Text(32, y, armLine(snapshot))
|
||||
y += 32
|
||||
canvas.Text(32, y, vtxLine(snapshot))
|
||||
y += 32
|
||||
if state == osd.SnapshotStale {
|
||||
canvas.Text(32, y, "DATA STALE")
|
||||
y += 32
|
||||
}
|
||||
}
|
||||
canvas.Text(32, 32, "ARM "+arm)
|
||||
canvas.Text(32, 64, vtxLine(snapshot))
|
||||
canvas.Text(32, y, "VIDEO "+videoState(t.video.Active()))
|
||||
}
|
||||
|
||||
func armLine(snapshot osd.Snapshot) string {
|
||||
if snapshot.Armed {
|
||||
return "ARM ARMED"
|
||||
}
|
||||
return "ARM OFF"
|
||||
}
|
||||
|
||||
func videoState(active bool) string {
|
||||
if active {
|
||||
return "ON"
|
||||
}
|
||||
return "OFF"
|
||||
}
|
||||
|
||||
// vtxLine is the compact adaptive-link contract line.
|
||||
|
||||
Reference in New Issue
Block a user