From f9e209bf2ae3525010e5c18b67d984b6691606c3 Mon Sep 17 00:00:00 2001 From: pgdalmeida Date: Thu, 17 Sep 2026 18:14:54 +0200 Subject: [PATCH] Show the calibration actually in use, not just a fit from this session --- src/ui/TuiUi.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/ui/TuiUi.cpp b/src/ui/TuiUi.cpp index a0a2687..23808df 100644 --- a/src/ui/TuiUi.cpp +++ b/src/ui/TuiUi.cpp @@ -909,7 +909,7 @@ Element axisDumpDetail(const DumpAxis& ax) { // (incl. RAMP_STAT, the last one) is visible without scrolling. Element axisColumn(const std::string& title, const AxisView& live, const DumpData& d, char letter, bool calib_has, const CalibAxisView& cal, - const DiagAxisView* diag, ScrollState& st) { + const AxisMapView& live_map, const DiagAxisView* diag, ScrollState& st) { auto fmt = [](const char* f, double v) { char b[32]; std::snprintf(b, sizeof(b), f, v); @@ -957,13 +957,21 @@ Element axisColumn(const std::string& title, const AxisView& live, const DumpDat // Last calibration result for this axis. col.push_back(separator()); col.push_back(text("CALIBRATION") | bold | color(Color::Magenta)); + // The values actually in use, always. They are what every bearing is computed + // from, so showing nothing here because no fit happened today told the + // operator the axis was uncalibrated when it was not. + col.push_back(kvRow("cnt/deg", fmt("%.3f", live_map.counts_per_deg))); + col.push_back(kvRow("deg@ctr", fmt("%.3f", live_map.deg_at_center))); if (calib_has && cal.ok) { - col.push_back(kvRow("cnt/deg", fmt("%.3f", cal.counts_per_deg))); - col.push_back(kvRow("deg@ctr", fmt("%.3f", cal.deg_at_center))); + // A fit ran this session: add its quality, and flag if the live map has + // since moved away from it (a homing derivation, or a manual offset). col.push_back(kvRow("R2", fmt("%.4f", cal.r2), cal.r2 >= 0.99 ? Color::Green : Color::Yellow)); col.push_back(kvRow("points", std::to_string(cal.n))); + col.push_back(text("from a fit this session") | dim); + } else if (calib_has) { + col.push_back(text("last fit this session FAILED") | color(Color::Yellow)); } else { - col.push_back(text(calib_has ? "fit failed" : "uncalibrated this session") | dim); + col.push_back(text("from config, no fit this session") | dim); } // Each axis keeps its own frame so the YAW/PITCH titles stay put; framing the @@ -985,7 +993,7 @@ Element gimbalDetailPanel(const GimbalView& g, const DumpView& dump, const Calib std::string reset; for (size_t i = 0; i < d.reset_flags.size(); ++i) reset += (i ? " " : "") + d.reset_flags[i]; - std::string calib_note = "uncalibrated this session"; + std::string calib_note = "calibration from config"; if (calib.has) { long long now = std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch()).count(); @@ -1002,10 +1010,11 @@ Element gimbalDetailPanel(const GimbalView& g, const DumpView& dump, const Calib }); std::vector cols; - cols.push_back(axisColumn("YAW", g.yaw, d, 'Y', calib.has, calib.yaw, diagFor('Y'), st[0])); + cols.push_back(axisColumn("YAW", g.yaw, d, 'Y', calib.has, calib.yaw, calib.live_yaw, + diagFor('Y'), st[0])); if (g.pitch_present) - cols.push_back( - axisColumn("PITCH", g.pitch, d, 'P', calib.has, calib.pitch, diagFor('P'), st[1])); + cols.push_back(axisColumn("PITCH", g.pitch, d, 'P', calib.has, calib.pitch, + calib.live_pitch, diagFor('P'), st[1])); return window(overlayTitle("GIMBAL", "g/Esc:close d:refresh dump", st[0]), vbox({header, separator(), hbox(std::move(cols)) | flex}));