Wish the web server handles route "/setup" with nav "" handler {
html [subst {
Folk setup
Folk setup
Displays
[HtmlWhen $::thisNode has display /display/ with /...opts/ {
HtmlWhen the collected results for \
[list /someone/ wishes $::thisNode uses display $display with /...usingOpts/] \
are /results/ {
set isUsingDisplay $([llength $results] >= 1)
if {$isUsingDisplay} {
set usingOpts [dict get [lindex $results 0] usingOpts]
}
set info [dict get $opts info]
set displayName [dict get $info name]
set modesByRegion [dict create]
foreach mode [dict getdef $info modes [list]] {
dict lappend modesByRegion $mode(visibleRegion) $mode
}
set regions [lsort -decreasing -integer -index 0 \
[dict keys $modesByRegion]]
set displayId [string map {/ _} $display]
subst {
[if {[llength $regions] > 0} { subst {
} }]
}
}}]
Cameras
[HtmlWhen $::thisNode has camera /camera/ with /...opts/ {
HtmlWhen the collected results for \
[list /someone/ wishes $::thisNode uses camera $camera with /...usingOpts/] \
are /results/ {
set isUsingCamera $([llength $results] >= 1)
if {$isUsingCamera} {
set usingOpts [dict get [lindex $results 0] usingOpts]
}
set resolutions [list]
foreach format [dict get $opts formats] {
# For now, we only support MJPG. The more raw formats are
# rarely used by cameras at even medium resolutions and
# framerates, anyway, so it's only worth supporting MJPG.
if {$format(fourcc) eq "MJPG"} {
lappend resolutions {*}$format(resolutions)
}
}
set resolutions [lsort -command {apply {{a b} {
expr {[dict get $b width] - [dict get $a width]}
}}} $resolutions]
if {[llength $resolutions] == 0} {
# Cameras often have extra camera devices with no formats (or no
# MJPG, at least) for some reason. Not very useful for us.
subst {
$camera ([dict getdef $opts card ""])
(no supported formats)