Files
groundstation/cmd/groundstation-display/main.go
T
piotr b169a64ad5
Build Ground Station / build (push) Successful in 44s
feat: show no-WFB kiosk fallback only while video absent (#2)
2026-10-01 14:40:24 +02:00

53 lines
1.6 KiB
Go

// Command groundstation-display renders the Ground Station kiosk canvas. It
// owns its display lifecycle independently of WFB, the transmitter and the
// video launcher: it waits for its target to appear, redraws as needed, and
// stops only when it receives SIGINT or SIGTERM.
package main
import (
"context"
"flag"
"fmt"
"log"
"os"
"os/signal"
"syscall"
"git.piksar.eu/piotr/groundstation/internal/display"
)
// buildTarget selects the target-specific opener and template. Each target
// owns its own backend and layouts; there is no shared global template.
// buildTarget wires one shared video presence signal into both the opener
// (which observes the video output lifecycle) and the fallback template
// (which shows or hides itself from it).
func buildTarget(name string) (display.Opener, display.Template, error) {
switch name {
case "x11":
video := display.NewVideoPresence()
return display.X11Opener{Video: video},
display.NewFallbackTemplate(video, "Brak połączenia WFB"), nil
default:
return nil, nil, fmt.Errorf("unknown display target %q (supported: x11)", name)
}
}
func main() {
target := flag.String("target", "x11", "display target: x11 (Viture) today; mipi planned")
flag.Parse()
opener, template, err := buildTarget(*target)
if err != nil {
log.Fatal(err)
}
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
// Temporary X11 unavailability never exits this process; display.Run
// keeps retrying internally until the context is cancelled.
if err := display.Run(ctx, opener, template, display.Options{}); err != nil {
log.Fatalf("display: %v", err)
}
}