Panel cleanup: chip padding up a step and a tighter chip line gap, corrected/SNR numbers neutral until amber or red, dB margin casing, compound elapsed units (1m39s) ending the minutes/metres m collision, noise chip shows presence only

This commit is contained in:
flamingcow
2026-08-14 23:47:45 -07:00
parent 9f2b074c4a
commit 6a1a860548
3 changed files with 32 additions and 33 deletions
+21 -23
View File
@@ -60,10 +60,11 @@ const (
chipRadius = spaceTight
chipBorder = 2
gridCols = 2
chipPadY = step * 3
chipGap = spaceTight
statRowGap = spaceRow
gridCols = 2
chipPadY = step * 4
chipLineGap = step * 3
chipGap = spaceTight
statRowGap = spaceRow
)
type rect struct {
@@ -267,10 +268,11 @@ func (d *display) close() {
}
// y is the top of the line as read, not the top of the cell, so text and a
// bordered box placed the same distance apart look it.
// bordered box placed the same distance apart look it. Returns the top of the
// next line, gapless — the caller owns the spacing below.
func (d *display) centerIn(f *textFace, x, w, y int, s string, col rgb) int {
f.draw(d.fb, x+(w-len([]rune(s))*f.cellW)/2, y-f.capTop, s, col)
return y + f.lineH + pairGap
return y + f.lineH
}
type statCell struct {
@@ -306,7 +308,7 @@ func (d *display) stats(vf *textFace, x, w, y int, cells []statCell) int {
}
cx, cw := gridCell(i, len(cells), gridCols, x, w)
cy := y + (i/gridCols)*(d.statPairH(vf)+statRowGap)
ly := d.centerIn(vf, cx, cw, cy, c.value, c.col)
ly := d.centerIn(vf, cx, cw, cy, c.value, c.col) + pairGap
d.centerIn(d.grid, cx, cw, ly, c.label, uiDim)
}
return y + d.statsH(vf, len(cells))
@@ -324,7 +326,7 @@ var errRows = []struct {
func (d *display) chipH() int { return d.grid.lineH + 2*chipPadY }
func (d *display) countChipH() int { return d.chipH() + d.gridB.lineH + pairGap }
func (d *display) countChipH() int { return d.chipH() + d.gridB.lineH + chipLineGap }
// The error chips plus corrected and the noise cable's, which share their
// row grid.
@@ -350,8 +352,8 @@ func (d *display) chipAt(i, n, cols, x, w, y, h int, c rgb) (int, int, int) {
// Whether rather than how many: over a window this short a count changes faster
// than it can be read. The noise chip rides along at the end, presence rather
// than health: red is the cable missing, not the cable failing, and a present
// cable names its cycle phase in green.
// than health: red is the cable missing, not the cable failing. The cycle
// phase stays off the panel (the console column still carries it).
func (d *display) errChips(x, w, y int, e errs, recentCorrected uint64, nv noiseView) int {
n := len(errRows) + 2
for i, r := range errRows {
@@ -366,15 +368,8 @@ func (d *display) errChips(x, w, y int, e errs, recentCorrected uint64, nv noise
cx, cw, cy := d.chipAt(len(errRows), n, gridCols, x, w, y, d.chipH(), c)
d.centerIn(d.grid, cx, cw, cy+chipPadY, "corrected", c)
c = errColor(nv.missing)
label := "noise"
if nv.missing == 0 {
label = "noise off"
if nv.on {
label = "noise on"
}
}
cx, cw, cy = d.chipAt(len(errRows)+1, n, gridCols, x, w, y, d.chipH(), c)
d.centerIn(d.grid, cx, cw, cy+chipPadY, label, c)
d.centerIn(d.grid, cx, cw, cy+chipPadY, "noise", c)
return y + d.chipsH()
}
@@ -383,7 +378,7 @@ func (d *display) errCounts(x, w, y int, e errs) int {
n := r.get(e)
c := errColor(n)
cx, cw, cy := d.chipAt(i, len(errRows), gridCols, x, w, y, d.countChipH(), c)
ty := d.centerIn(d.gridB, cx, cw, cy+chipPadY, scaleCount(n), c)
ty := d.centerIn(d.gridB, cx, cw, cy+chipPadY, scaleCount(n), c) + chipLineGap
d.centerIn(d.grid, cx, cw, ty, r.label, c)
}
return y + d.countsH()
@@ -419,14 +414,17 @@ func errColor(n uint64) rgb {
func snrStat(phy phyDisplay) statCell {
if !phy.haveSNR {
return statCell{"-", "db margin", uiDim}
return statCell{"-", "dB margin", uiDim}
}
return statCell{fmt.Sprintf("%+.1f", phy.worstMargin), "db margin",
classColor(snrClass(phy.worstMargin))}
col := uiFg
if c := snrClass(phy.worstMargin); c != clsGood {
col = classColor(c)
}
return statCell{fmt.Sprintf("%+.1f", phy.worstMargin), "dB margin", col}
}
func correctedStat(v uint64) statCell {
col := uiGreen
col := uiFg
if v > 0 {
col = uiAmber
}