more cached params

This commit is contained in:
royjr
2025-09-23 06:49:41 -04:00
parent fbd1f6bad1
commit cbc34dd1f6
2 changed files with 20 additions and 5 deletions
+16 -5
View File
@@ -8,6 +8,11 @@
#include "common/swaglog.h"
#include "selfdrive/ui/qt/util.h"
void AnnotatedCameraWidget::updateParams() {
visual_style_ = QString::fromStdString(Params().get("VisualStyle")).toInt();
visual_wide_cam_ = QString::fromStdString(Params().get("VisualWideCam")).toInt();
}
// Window that shows camera view and variety of info drawn on top
AnnotatedCameraWidget::AnnotatedCameraWidget(VisionStreamType type, QWidget *parent)
: fps_filter(UI_FREQ, 3, 1. / UI_FREQ), CameraWidget("camerad", type, parent) {
@@ -26,9 +31,7 @@ void AnnotatedCameraWidget::updateState(const UIState &s) {
experimental_btn->updateState(s);
dmon.updateState(s);
// dynamically adjust background
int style = QString::fromStdString(Params().get("VisualStyle")).toInt();
if (style == 0) {
if (visual_style_ == 0) {
setBackgroundColor(bg_colors[STATUS_DISENGAGED]);
} else {
setBackgroundColor(QColor(0, 0, 0));
@@ -43,7 +46,7 @@ void AnnotatedCameraWidget::initializeGL() {
qInfo() << "OpenGL language version:" << QString((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION));
prev_draw_t = millis_since_boot();
if (QString::fromStdString(Params().get("VisualStyle")).toInt() == 0) {
if (visual_style_ == 0) {
setBackgroundColor(bg_colors[STATUS_DISENGAGED]);
} else {
setBackgroundColor(QColor(0, 0, 0));
@@ -100,6 +103,14 @@ mat4 AnnotatedCameraWidget::calcFrameMatrix() {
}
void AnnotatedCameraWidget::paintGL() {
// refresh VisualWideCam param ~once per second
static double last_params_t = 0.0;
double params_now = millis_since_boot();
if (params_now - last_params_t > 1000.0) {
updateParams();
last_params_t = params_now;
}
UIState *s = uiState();
SubMaster &sm = *(s->sm);
const double start_draw_t = millis_since_boot();
@@ -131,7 +142,7 @@ void AnnotatedCameraWidget::paintGL() {
wide_cam_requested = false;
}
wide_cam_requested = wide_cam_requested && sm["selfdriveState"].getSelfdriveState().getExperimentalMode();
wide_cam_requested = wide_cam_requested || QString::fromStdString(Params().get("VisualWideCam")).toInt();
wide_cam_requested = wide_cam_requested || (visual_wide_cam_ != 0);
}
CameraWidget::setStreamType(wide_cam_requested ? VISION_STREAM_WIDE_ROAD : VISION_STREAM_ROAD);
CameraWidget::setFrameId(sm["modelV2"].getModelV2().getFrameId());
@@ -45,4 +45,8 @@ protected:
double prev_draw_t = 0;
FirstOrderFilter fps_filter;
void updateParams();
int visual_style_ = 0;
int visual_wide_cam_ = 0;
};