feat: add bounded display_diag journal diagnostics for the OSD (#3)
This commit is contained in:
@@ -41,6 +41,11 @@ func NewOSDTemplate(video *VideoPresence, source SnapshotSource) OSDTemplate {
|
||||
func (t OSDTemplate) Draw(canvas Canvas) {
|
||||
canvas.Clear()
|
||||
snapshot, state := t.source.Latest()
|
||||
// Report the snapshot state into the layer's diagnostic stream when
|
||||
// the canvas supports it; transitions are deduplicated there.
|
||||
if reporter, ok := canvas.(interface{ SetDiagSnapshot(string) }); ok {
|
||||
reporter.SetDiagSnapshot(snapshotStateName(state))
|
||||
}
|
||||
t.draw(canvas, snapshot, state)
|
||||
canvas.Flush()
|
||||
}
|
||||
@@ -77,6 +82,17 @@ func armLine(snapshot osd.Snapshot) string {
|
||||
return "ARM OFF"
|
||||
}
|
||||
|
||||
// snapshotStateName names a snapshot state in diagnostics.
|
||||
func snapshotStateName(state osd.SnapshotState) string {
|
||||
switch state {
|
||||
case osd.SnapshotFresh:
|
||||
return "fresh"
|
||||
case osd.SnapshotStale:
|
||||
return "stale"
|
||||
}
|
||||
return "none"
|
||||
}
|
||||
|
||||
func videoState(active bool) string {
|
||||
if active {
|
||||
return "ON"
|
||||
|
||||
Reference in New Issue
Block a user