mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-09-29 19:23:41 +08:00
ui: remove Speed Limit Style and fix speed limit display (#227)
* ui: only allow single speed limit type to display * Use unit conversion to set speed limit style if not nav * Remove Speed Limit Style override options * unused * unused
This commit is contained in:
@@ -213,7 +213,7 @@ class LongitudinalPlanner:
|
||||
longitudinalPlan.speedLimit = float(self.speed_limit_controller.speed_limit)
|
||||
longitudinalPlan.speedLimitOffset = float(self.speed_limit_controller.speed_limit_offset)
|
||||
longitudinalPlan.distToSpeedLimit = float(self.speed_limit_controller.distance)
|
||||
longitudinalPlan.isMapSpeedLimit = bool(self.speed_limit_controller.source == SpeedLimitResolver.Source.map_data)
|
||||
longitudinalPlan.isMapSpeedLimit = bool(self.speed_limit_controller.source not in (SpeedLimitResolver.Source.none, SpeedLimitResolver.Source.nav))
|
||||
longitudinalPlan.eventsDEPRECATED = self.events.to_msg()
|
||||
|
||||
longitudinalPlan.turnSpeedControlState = self.turn_speed_controller.state
|
||||
|
||||
@@ -296,8 +296,6 @@ SPControlsPanel::SPControlsPanel(QWidget *parent) : ListWidget(parent) {
|
||||
friction = new TorqueFriction();
|
||||
// Controls: Torque - LAT_ACCEL_FACTOR
|
||||
lat_accel_factor = new TorqueMaxLatAccel();
|
||||
// Controls: MUTCD: US/Canada\nVienna: Europe/Asia/etc.
|
||||
speed_limit_style = new SpeedLimitStyle();
|
||||
|
||||
for (auto &[param, title, desc, icon] : toggle_defs) {
|
||||
auto toggle = new ParamControl(param, title, desc, icon, this);
|
||||
@@ -334,11 +332,6 @@ SPControlsPanel::SPControlsPanel(QWidget *parent) : ListWidget(parent) {
|
||||
addItem(lat_accel_factor);
|
||||
}
|
||||
|
||||
if (param == "SpeedLimitControl") {
|
||||
// Controls: MUTCD: US/Canada\nVienna: Europe/Asia/etc.
|
||||
addItem(speed_limit_style);
|
||||
}
|
||||
|
||||
if (param == "SpeedLimitPercOffset") {
|
||||
// Controls: Speed Limit Offset Type
|
||||
addItem(slo_type);
|
||||
@@ -480,7 +473,6 @@ void SPControlsPanel::updateToggles() {
|
||||
}
|
||||
|
||||
// toggle names to update when SpeedLimitControl is flipped
|
||||
speed_limit_style->setVisible(params.getBool("SpeedLimitControl"));
|
||||
toggles["SpeedLimitPercOffset"]->setVisible(params.getBool("SpeedLimitControl"));
|
||||
|
||||
auto cp_bytes = params.get("CarParamsPersistent");
|
||||
@@ -1460,77 +1452,6 @@ void TorqueMaxLatAccel::refresh() {
|
||||
btnplus.setText("+");
|
||||
}
|
||||
|
||||
SpeedLimitStyle::SpeedLimitStyle() : AbstractControl(
|
||||
tr("Speed Limit Style"),
|
||||
QString("%1<br>"
|
||||
"%2")
|
||||
.arg(tr("MUTCD: US/Canada"))
|
||||
.arg(tr("Vienna: Europe/Asia/etc.")),
|
||||
"../assets/offroad/icon_blank.png")
|
||||
|
||||
{
|
||||
label.setAlignment(Qt::AlignVCenter|Qt::AlignRight);
|
||||
label.setStyleSheet("color: #e0e879");
|
||||
hlayout->addWidget(&label);
|
||||
|
||||
btnminus.setStyleSheet(R"(
|
||||
padding: 0;
|
||||
border-radius: 50px;
|
||||
font-size: 50px;
|
||||
font-weight: 500;
|
||||
color: #E4E4E4;
|
||||
background-color: #393939;
|
||||
)");
|
||||
btnplus.setStyleSheet(R"(
|
||||
padding: 0;
|
||||
border-radius: 50px;
|
||||
font-size: 50px;
|
||||
font-weight: 500;
|
||||
color: #E4E4E4;
|
||||
background-color: #393939;
|
||||
)");
|
||||
btnminus.setFixedSize(150, 100);
|
||||
btnplus.setFixedSize(150, 100);
|
||||
hlayout->addWidget(&btnminus);
|
||||
hlayout->addWidget(&btnplus);
|
||||
|
||||
QObject::connect(&btnminus, &QPushButton::clicked, [=]() {
|
||||
auto str = QString::fromStdString(params.get("SpeedLimitStyle"));
|
||||
int value = str.toInt();
|
||||
value = value - 1;
|
||||
if (value <= 0 ) {
|
||||
value = 0;
|
||||
}
|
||||
QString values = QString::number(value);
|
||||
params.put("SpeedLimitStyle", values.toStdString());
|
||||
refresh();
|
||||
});
|
||||
|
||||
QObject::connect(&btnplus, &QPushButton::clicked, [=]() {
|
||||
auto str = QString::fromStdString(params.get("SpeedLimitStyle"));
|
||||
int value = str.toInt();
|
||||
value = value + 1;
|
||||
if (value >= 1 ) {
|
||||
value = 1;
|
||||
}
|
||||
QString values = QString::number(value);
|
||||
params.put("SpeedLimitStyle", values.toStdString());
|
||||
refresh();
|
||||
});
|
||||
refresh();
|
||||
}
|
||||
|
||||
void SpeedLimitStyle::refresh() {
|
||||
QString option = QString::fromStdString(params.get("SpeedLimitStyle"));
|
||||
if (option == "0") {
|
||||
label.setText(tr("MUTCD"));
|
||||
} else {
|
||||
label.setText(tr("Vienna"));
|
||||
}
|
||||
btnminus.setText("-");
|
||||
btnplus.setText("+");
|
||||
}
|
||||
|
||||
// Speed Limit Control Custom Offset Type
|
||||
SpeedLimitOffsetType::SpeedLimitOffsetType() : AbstractControl(
|
||||
tr("Speed Limit Offset Type"),
|
||||
|
||||
@@ -197,21 +197,6 @@ private:
|
||||
void refresh();
|
||||
};
|
||||
|
||||
class SpeedLimitStyle : public AbstractControl {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SpeedLimitStyle();
|
||||
|
||||
private:
|
||||
QPushButton btnplus;
|
||||
QPushButton btnminus;
|
||||
QLabel label;
|
||||
Params params;
|
||||
|
||||
void refresh();
|
||||
};
|
||||
|
||||
class DevUiInfo : public AbstractControl {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -332,7 +317,6 @@ private:
|
||||
GapAdjustCruiseMode *gac_mode;
|
||||
TorqueFriction *friction;
|
||||
TorqueMaxLatAccel *lat_accel_factor;
|
||||
SpeedLimitStyle *speed_limit_style;
|
||||
};
|
||||
|
||||
class SPVehiclesPanel : public QWidget {
|
||||
|
||||
@@ -569,7 +569,6 @@ void AnnotatedCameraWidget::updateState(const UIState &s) {
|
||||
setProperty("slcActive", !sl_inactive && !sl_temp_inactive);
|
||||
setProperty("overSpeedLimit", (((speed_limit_slc + speed_limit_offset) < cur_speed) && !sl_inactive && !sl_temp_inactive) ||
|
||||
((speed_limit_slc < cur_speed) && (speed_limit_slc > 0.0) && (sl_inactive || sl_temp_inactive)));
|
||||
setProperty("speedLimitStyle", s.scene.speed_limit_style);
|
||||
|
||||
const float tsc_speed = lp.getTurnSpeed() * (s.scene.is_metric ? MS_TO_KPH : MS_TO_MPH);
|
||||
const auto tscState = lp.getTurnSpeedControlState();
|
||||
@@ -672,6 +671,7 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
|
||||
QString speedLimitStrSlc = showSpeedLimit ? QString::number(std::nearbyint(speedLimitSLC)) : "–";
|
||||
QString speedStr = QString::number(std::nearbyint(speed));
|
||||
QString setSpeedStr = is_cruise_set ? QString::number(std::nearbyint(setSpeed)) : "–";
|
||||
const bool isNavSpeedLimit = has_us_speed_limit || has_eu_speed_limit;
|
||||
|
||||
// Draw outer box + border to contain set speed and speed limit
|
||||
const int sign_margin = 12;
|
||||
@@ -681,16 +681,14 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
|
||||
const QSize default_size = {172, 204};
|
||||
QSize set_speed_size = default_size;
|
||||
if (is_metric || has_eu_speed_limit) set_speed_size.rwidth() = 200;
|
||||
if (has_us_speed_limit && speedLimitStr.size() >= 3) set_speed_size.rwidth() = 223;
|
||||
if (((!roadName.isEmpty() || showSpeedLimit) && speedLimitStyle == 1) || is_metric || has_eu_speed_limit) set_speed_size.rwidth() = 200;
|
||||
if (((!roadName.isEmpty() || showSpeedLimit) && speedLimitStyle == 0 && speedLimitStrSlc.size() >= 3) ||
|
||||
(has_us_speed_limit && speedLimitStr.size() >= 3)) set_speed_size.rwidth() = 223;
|
||||
if ((mapSourcedSpeedLimit && !is_metric && speedLimitStrSlc.size() >= 3) ||
|
||||
(has_us_speed_limit && speedLimitStr.size() >= 3)) set_speed_size.rwidth() = 223;
|
||||
|
||||
if (((!roadName.isEmpty() || showSpeedLimit) && speedLimitStyle == 0) || has_us_speed_limit) set_speed_size.rheight() += us_sign_height + sign_margin;
|
||||
else if (((!roadName.isEmpty() || showSpeedLimit) && speedLimitStyle == 1) || has_eu_speed_limit) set_speed_size.rheight() += eu_sign_size + sign_margin;
|
||||
if ((mapSourcedSpeedLimit && !is_metric) || has_us_speed_limit) set_speed_size.rheight() += us_sign_height + sign_margin;
|
||||
else if ((mapSourcedSpeedLimit && is_metric) || has_eu_speed_limit) set_speed_size.rheight() += eu_sign_size + sign_margin;
|
||||
|
||||
int top_radius = 32;
|
||||
int bottom_radius = (((!roadName.isEmpty() || showSpeedLimit) && speedLimitStyle == 1) || has_eu_speed_limit) ? 100 : 32;
|
||||
int bottom_radius = ((mapSourcedSpeedLimit && is_metric) || has_eu_speed_limit) ? 100 : 32;
|
||||
|
||||
QRect set_speed_rect(QPoint(60 + (default_size.width() - set_speed_size.width()) / 2, 45), set_speed_size);
|
||||
p.setPen(QPen(whiteColor(75), 6));
|
||||
@@ -731,7 +729,7 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
|
||||
|
||||
const QRect sign_rect = set_speed_rect.adjusted(sign_margin, default_size.height(), -sign_margin, -sign_margin);
|
||||
// US/Canada (MUTCD style) sign
|
||||
if (((!roadName.isEmpty() || showSpeedLimit) && speedLimitStyle == 0) || has_us_speed_limit) {
|
||||
if ((mapSourcedSpeedLimit && !is_metric && !isNavSpeedLimit) || has_us_speed_limit) {
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(whiteColor());
|
||||
p.drawRoundedRect(sign_rect, 24, 24);
|
||||
@@ -753,7 +751,7 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
|
||||
}
|
||||
|
||||
// EU (Vienna style) sign
|
||||
if (((!roadName.isEmpty() || showSpeedLimit) && speedLimitStyle == 1) || has_eu_speed_limit) {
|
||||
if ((mapSourcedSpeedLimit && is_metric && !isNavSpeedLimit) || has_eu_speed_limit) {
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(whiteColor());
|
||||
p.drawEllipse(sign_rect);
|
||||
|
||||
@@ -110,7 +110,6 @@ class AnnotatedCameraWidget : public CameraWidget {
|
||||
Q_PROPERTY(bool overSpeedLimit MEMBER overSpeedLimit);
|
||||
Q_PROPERTY(bool mapSourcedSpeedLimit MEMBER mapSourcedSpeedLimit);
|
||||
Q_PROPERTY(bool slcActive MEMBER slcActive);
|
||||
Q_PROPERTY(int speedLimitStyle MEMBER speedLimitStyle);
|
||||
|
||||
Q_PROPERTY(bool showTurnSpeedLimit MEMBER showTurnSpeedLimit);
|
||||
Q_PROPERTY(QString turnSpeedLimit MEMBER turnSpeedLimit);
|
||||
@@ -259,7 +258,6 @@ private:
|
||||
QString tscSubText;
|
||||
bool tscActive = false;
|
||||
int curveSign = 0;
|
||||
int speedLimitStyle;
|
||||
|
||||
bool hideVEgoUi;
|
||||
|
||||
|
||||
@@ -243,7 +243,6 @@ void ui_update_params(UIState *s) {
|
||||
s->scene.speed_limit_perc_offset = params.getBool("SpeedLimitPercOffset");
|
||||
s->scene.show_debug_ui = params.getBool("ShowDebugUI");
|
||||
s->scene.debug_snapshot_enabled = params.getBool("EnableDebugSnapshot");
|
||||
s->scene.speed_limit_style = std::atoi(params.get("SpeedLimitStyle").c_str());
|
||||
s->scene.hide_vego_ui = params.getBool("HideVEgoUi");
|
||||
s->scene.true_vego_ui = params.getBool("TrueVEgoUi");
|
||||
s->scene.chevron_data = std::atoi(params.get("ChevronInfo").c_str());
|
||||
|
||||
@@ -143,7 +143,6 @@ typedef struct UIScene {
|
||||
bool speed_limit_control_enabled;
|
||||
bool speed_limit_perc_offset;
|
||||
double last_speed_limit_sign_tap;
|
||||
int speed_limit_style;
|
||||
|
||||
// modelV2
|
||||
float lane_line_probs[4];
|
||||
|
||||
Reference in New Issue
Block a user