From 1b13eaf1ebd0949d2cfed436a568aeef118e1611 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 2 May 2024 20:16:33 -0500 Subject: [PATCH] wip --- clearpilot_testme.txt | 3 +- .../ui/qt/offroad/visual_settings.cc | 7 +- selfdrive/ui/qt/onroad.cc | 83 ++++++------------- selfdrive/ui/ui.h | 7 +- 4 files changed, 35 insertions(+), 65 deletions(-) diff --git a/clearpilot_testme.txt b/clearpilot_testme.txt index ea8d898..83328ed 100644 --- a/clearpilot_testme.txt +++ b/clearpilot_testme.txt @@ -1,7 +1,8 @@ Dev: - New behavior for lane change assist - when starting lane change, disable lateral until .5 seconds after blinkers stop -- +- // Clearpilot allow leadInfo (test me) + Test: - New colors for driving diff --git a/selfdrive/frogpilot/ui/qt/offroad/visual_settings.cc b/selfdrive/frogpilot/ui/qt/offroad/visual_settings.cc index 6e02745..7012c10 100644 --- a/selfdrive/frogpilot/ui/qt/offroad/visual_settings.cc +++ b/selfdrive/frogpilot/ui/qt/offroad/visual_settings.cc @@ -138,9 +138,10 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot modifiedCustomOnroadUIKeys.erase("DeveloperUI"); } - if (!hasOpenpilotLongitudinal || !isRelease) { - modifiedCustomOnroadUIKeys.erase("LeadInfo"); - } + // Clearpilot allow leadInfo (test me) + // if (!hasOpenpilotLongitudinal || !isRelease) { + // modifiedCustomOnroadUIKeys.erase("LeadInfo"); + // } toggle->setVisible(modifiedCustomOnroadUIKeys.find(key.c_str()) != modifiedCustomOnroadUIKeys.end()); } diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index e0b6370..5734387 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -823,6 +823,14 @@ void AnnotatedCameraWidget::updateFrameMat() { void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) { painter.save(); + // CLEARPILOT: color channel code rewriten to allow custom colors + // Define base RGB color and alpha + int base_red = 255; // Example red color + int base_green = 200; // Example green color + int base_blue = 150; // Example blue color + float base_alpha = 0.75; // Example base alpha + QColor baseColor(base_red, base_green, base_blue); + SubMaster &sm = *(s->sm); // lanelines @@ -864,59 +872,32 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) { } for (int i = 0; i < max_len; ++i) { - // Some points are out of frame if (scene.track_vertices[i].y() < 0 || scene.track_vertices[i].y() > height()) continue; - // Flip so 0 is bottom of frame float lin_grad_point = (height() - scene.track_vertices[i].y()) / height(); - // CLEARPILOT disabling custom theme colors - // // If acceleration is between -0.25 and 0.25, resort to the theme color - // if (std::abs(acceleration[i]) < 0.25 && (currentHolidayTheme != 0)) { - // const auto &colorMap = std::get<2>(holidayThemeConfiguration[currentHolidayTheme]); - // for (const auto &[position, brush] : colorMap) { - // bg.setColorAt(position, brush.color()); - // } + float path_hue = std::max(std::min(60 + acceleration[i] * 35, 120.f), 0.f); + path_hue = static_cast(path_hue * 100 + 0.5) / 100; // Ensuring hue is rounded to reduce processing - // } else if (std::abs(acceleration[i]) < 0.25 && (customColors != 0)) { - // const auto &colorMap = std::get<2>(themeConfiguration[customColors]); - // for (const auto &[position, brush] : colorMap) { - // bg.setColorAt(position, brush.color()); - // } + float saturation = std::min(std::abs(acceleration[i] * 1.5f), 1.f); + float lightness = util::map_val(saturation, 0.5f, 0.0f, 0.95f, 0.62f); // lighter when grey - // } else { - // speed up: 120, slow down: 0 - float path_hue = fmax(fmin(60 + acceleration[i] * 35, 120), 0); - // FIXME: painter.drawPolygon can be slow if hue is not rounded - path_hue = int(path_hue * 100 + 0.5) / 100; + float dynamic_alpha = util::map_val(lin_grad_point, 0.75f / 2.f, 0.75f, base_alpha, 0.0f); - float saturation = fmin(fabs(acceleration[i] * 1.5), 1); - float lightness = util::map_val(saturation, 0.0f, 1.0f, 0.95f, 0.62f); // lighter when grey - float alpha = util::map_val(lin_grad_point, 0.75f / 2.f, 0.75f, 0.4f, 0.0f); // matches previous alpha fade - bg.setColorAt(lin_grad_point, QColor::fromHslF(path_hue / 360., saturation, lightness, alpha)); + QColor base_color = QColor::fromRgb(base_red, base_green, base_blue); + float h, s, l; + base_color.getHslF(&h, &s, &l); + QColor final_color = QColor::fromHslF(path_hue / 360., saturation, lightness, dynamic_alpha); - // Skip a point, unless next is last - i += (i + 2) < max_len ? 1 : 0; - // } + bg.setColorAt(lin_grad_point, final_color); + + i += (i + 2) < max_len ? 1 : 0; // skipping a point to optimize rendering } - // CLEARPILOT disabling custom theme colors - // } else if (currentHolidayTheme != 0) { - // const auto &colorMap = std::get<2>(holidayThemeConfiguration[currentHolidayTheme]); - // for (const auto &[position, brush] : colorMap) { - // bg.setColorAt(position, brush.color()); - // } - - // } else if (customColors != 0) { - // const auto &colorMap = std::get<2>(themeConfiguration[customColors]); - // for (const auto &[position, brush] : colorMap) { - // bg.setColorAt(position, brush.color()); - // } - } else { - bg.setColorAt(0.0, QColor::fromHslF(148 / 360., 0.94, 0.51, 0.4)); - bg.setColorAt(0.5, QColor::fromHslF(112 / 360., 1.0, 0.68, 0.35)); - bg.setColorAt(1.0, QColor::fromHslF(112 / 360., 1.0, 0.68, 0.0)); + bg.setColorAt(0.0, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast(base_alpha * 255 * 0.4))); + bg.setColorAt(0.5, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast(base_alpha * 255 * 0.35))); + bg.setColorAt(1.0, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast(base_alpha * 255 * 0.0))); } painter.setBrush(bg); @@ -944,22 +925,10 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) { pe.setColorAt(0.0, QColor::fromHslF(205 / 360., 0.85, 0.56, 1.0)); pe.setColorAt(0.5, QColor::fromHslF(205 / 360., 0.85, 0.56, 0.5)); pe.setColorAt(1.0, QColor::fromHslF(205 / 360., 0.85, 0.56, 0.1)); - // } else if (currentHolidayTheme != 0) { - // const auto &colorMap = std::get<2>(holidayThemeConfiguration[currentHolidayTheme]); - // for (const auto &[position, brush] : colorMap) { - // QColor darkerColor = brush.color().darker(120); - // pe.setColorAt(position, darkerColor); - // } - // } else if (customColors != 0) { - // const auto &colorMap = std::get<2>(themeConfiguration[customColors]); - // for (const auto &[position, brush] : colorMap) { - // QColor darkerColor = brush.color().darker(120); - // pe.setColorAt(position, darkerColor); - // } } else { - pe.setColorAt(0.0, QColor::fromHslF(148 / 360., 0.94, 0.51, 1.0)); - pe.setColorAt(0.5, QColor::fromHslF(112 / 360., 1.00, 0.68, 0.5)); - pe.setColorAt(1.0, QColor::fromHslF(112 / 360., 1.00, 0.68, 0.1)); +pe.setColorAt(0.0, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast(base_alpha * 255))); +pe.setColorAt(0.5, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast(base_alpha * 255 * 0.5))); +pe.setColorAt(1.0, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast(base_alpha * 255 * 0.1))); } QPainterPath path; diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index ef46949..d6a7434 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -130,12 +130,11 @@ enum PrimeType { const QColor bg_colors [] = { [STATUS_DISENGAGED] = QColor(0x17, 0x33, 0x49, 0xc8), - [STATUS_OVERRIDE] = QColor(0x91, 0x9b, 0x95, 0xf1), - // [STATUS_ENGAGED] = QColor(0x17, 0x86, 0x44, 0xf1), - [STATUS_ENGAGED] = QColor(47, 158, 238, 0xf1), // CLEARPILOT changed to light blue + [STATUS_OVERRIDE] = QColor(0x91, 0x7b, 0x7b, 0xf1)), + [STATUS_ENGAGED] = QColor(0x91, 0x7b, 0x7b, 0xf1), // CLEARPILOT changed to redish gray // FrogPilot colors - [STATUS_ALWAYS_ON_LATERAL_ACTIVE] = QColor(4, 64, 11, 0xf1), // CLEARPILOT changed to dark blue + [STATUS_ALWAYS_ON_LATERAL_ACTIVE] = QColor(0x91, 0x7b, 0x7b, 0xf1), // CLEARPILOT changed to dark blue [STATUS_TRAFFIC_MODE_ACTIVE] = QColor(0xc9, 0x22, 0x31, 0xf1), };