mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 08:14:00 +08:00
Conditional Chill
This commit is contained in:
@@ -12,8 +12,13 @@ ExperimentalModeButton::ExperimentalModeButton(QWidget *parent) : QPushButton(pa
|
||||
chill_pixmap = QPixmap("../assets/icons/couch.svg").scaledToWidth(img_width, Qt::SmoothTransformation);
|
||||
experimental_pixmap = QPixmap("../assets/icons/experimental_grey.svg").scaledToWidth(img_width, Qt::SmoothTransformation);
|
||||
|
||||
// go to toggles and expand experimental mode description
|
||||
connect(this, &QPushButton::clicked, [=]() { emit openSettings(2, "ExperimentalMode"); });
|
||||
// go to toggles and expand whichever mode control is actually active
|
||||
connect(this, &QPushButton::clicked, [=]() {
|
||||
const QString toggle = params.getBool("ConditionalExperimental") ? "ConditionalExperimental" :
|
||||
params.getBool("ConditionalChill") ? "ConditionalChill" :
|
||||
"ExperimentalMode";
|
||||
emit openSettings(2, toggle);
|
||||
});
|
||||
|
||||
setFixedHeight(125);
|
||||
QHBoxLayout *main_layout = new QHBoxLayout;
|
||||
@@ -76,6 +81,12 @@ void ExperimentalModeButton::showEvent(QShowEvent *event) {
|
||||
status = params.getInt("PersistedCEStatus");
|
||||
}
|
||||
experimental_mode = !params.getBool("SafeMode") && status == 2;
|
||||
} else if (params.getBool("ConditionalChill")) {
|
||||
int status = params_memory.getInt("CCStatus");
|
||||
if ((status != 1 && status != 2) && params.getBool("PersistChillState")) {
|
||||
status = params.getInt("PersistedCCStatus");
|
||||
}
|
||||
experimental_mode = !params.getBool("SafeMode") && (status == 0 || status == 1);
|
||||
} else {
|
||||
experimental_mode = params.getBool("ExperimentalMode") && !params.getBool("SafeMode");
|
||||
}
|
||||
|
||||
@@ -4,6 +4,16 @@
|
||||
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
|
||||
namespace {
|
||||
bool ccmManualOverride(int status) {
|
||||
return status == 1 || status == 2;
|
||||
}
|
||||
|
||||
bool cemManualOverride(int status) {
|
||||
return status == 1 || status == 2;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void drawIcon(QPainter &p, const QPoint ¢er, const QPixmap &img, const QBrush &bg, float opacity, const int &angle) {
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
p.setOpacity(1.0); // bg dictates opacity of ellipse
|
||||
@@ -38,9 +48,13 @@ void ExperimentalButton::changeMode() {
|
||||
bool can_change = hasLongitudinalControl(cp) && params.getBool("ExperimentalModeConfirmed");
|
||||
if (can_change) {
|
||||
if (starpilot_toggles.value("conditional_experimental_mode").toBool()) {
|
||||
int override_value = (starpilot_scene.conditional_status == 1 || starpilot_scene.conditional_status == 2) ? 0 : experimental_mode ? 1 : 2;
|
||||
int override_value = cemManualOverride(starpilot_scene.conditional_status) ? 0 : experimental_mode ? 1 : 2;
|
||||
params_memory.putInt("CEStatus", override_value);
|
||||
params.putInt("PersistedCEStatus", params.getBool("PersistExperimentalState") ? override_value : 0);
|
||||
} else if (starpilot_toggles.value("conditional_chill_mode").toBool()) {
|
||||
int override_value = ccmManualOverride(starpilot_scene.conditional_status) ? 0 : experimental_mode ? 2 : 1;
|
||||
params_memory.putInt("CCStatus", override_value);
|
||||
params.putInt("PersistedCCStatus", params.getBool("PersistChillState") ? override_value : 0);
|
||||
} else {
|
||||
params.putBool("ExperimentalMode", !experimental_mode);
|
||||
}
|
||||
@@ -97,6 +111,11 @@ void ExperimentalButton::showEvent(QShowEvent *event) {
|
||||
}
|
||||
|
||||
void ExperimentalButton::updateBackgroundColor() {
|
||||
const bool conditional_experimental_mode = starpilot_toggles.value("conditional_experimental_mode").toBool();
|
||||
const bool conditional_chill_mode = starpilot_toggles.value("conditional_chill_mode").toBool();
|
||||
const bool highlight_override =
|
||||
(conditional_experimental_mode && starpilot_scene.conditional_status == 1) ||
|
||||
(conditional_chill_mode && ccmManualOverride(starpilot_scene.conditional_status));
|
||||
if (starpilot_toggles.value("simple_mode").toBool()) {
|
||||
background_color = QColor(0, 0, 0, 166);
|
||||
} else if (isDown() || !engageable) {
|
||||
@@ -105,7 +124,7 @@ void ExperimentalButton::updateBackgroundColor() {
|
||||
background_color = bg_colors[STATUS_SWITCHBACK_MODE_ENABLED];
|
||||
} else if (starpilot_scene.always_on_lateral_active) {
|
||||
background_color = bg_colors[STATUS_ALWAYS_ON_LATERAL_ACTIVE];
|
||||
} else if (starpilot_scene.conditional_status == 1) {
|
||||
} else if (highlight_override) {
|
||||
background_color = bg_colors[STATUS_CEM_DISABLED];
|
||||
} else if (experimental_mode) {
|
||||
background_color = bg_colors[STATUS_EXPERIMENTAL_MODE_ENABLED];
|
||||
|
||||
@@ -59,13 +59,19 @@ void OnroadWindow::updateState(const UIState &s, const StarPilotUIState &fs) {
|
||||
nvg->updateState(s, fs);
|
||||
|
||||
const StarPilotUIScene &starpilot_scene = fs.starpilot_scene;
|
||||
const QJsonObject &starpilot_toggles = starpilot_scene.starpilot_toggles;
|
||||
const auto selfdriveState = (*s.sm)["selfdriveState"].getSelfdriveState();
|
||||
QColor bgColor = bg_colors[s.status];
|
||||
const bool conditional_experimental_mode = starpilot_toggles.value("conditional_experimental_mode").toBool();
|
||||
const bool conditional_chill_mode = starpilot_toggles.value("conditional_chill_mode").toBool();
|
||||
const bool highlight_override =
|
||||
(conditional_experimental_mode && starpilot_scene.conditional_status == 1) ||
|
||||
(conditional_chill_mode && (starpilot_scene.conditional_status == 1 || starpilot_scene.conditional_status == 2));
|
||||
if (starpilot_scene.switchback_mode_enabled && (selfdriveState.getEnabled() || starpilot_scene.always_on_lateral_active)) {
|
||||
bgColor = bg_colors[STATUS_SWITCHBACK_MODE_ENABLED];
|
||||
} else if (starpilot_scene.always_on_lateral_active) {
|
||||
bgColor = bg_colors[STATUS_ALWAYS_ON_LATERAL_ACTIVE];
|
||||
} else if (starpilot_scene.conditional_status == 1) {
|
||||
} else if (highlight_override) {
|
||||
bgColor = bg_colors[STATUS_CEM_DISABLED];
|
||||
} else if (selfdriveState.getExperimentalMode()) {
|
||||
bgColor = bg_colors[STATUS_EXPERIMENTAL_MODE_ENABLED];
|
||||
@@ -78,9 +84,6 @@ void OnroadWindow::updateState(const UIState &s, const StarPilotUIState &fs) {
|
||||
bg = bgColor;
|
||||
update();
|
||||
}
|
||||
|
||||
const QJsonObject &starpilot_toggles = starpilot_scene.starpilot_toggles;
|
||||
|
||||
starpilot_nvg->alertHeight = alerts->alertHeight;
|
||||
|
||||
starpilot_onroad->bg = bg;
|
||||
|
||||
@@ -139,6 +139,11 @@ void ParamControl::toggleClicked(bool state) {
|
||||
if (!confirm || confirmed || !state || do_confirm()) {
|
||||
if (store_confirm && state) params.putBool(key + "Confirmed", true);
|
||||
params.putBool(key, state);
|
||||
if (state && key == "ConditionalExperimental") {
|
||||
params.putBool("ConditionalChill", false);
|
||||
} else if (state && key == "ConditionalChill") {
|
||||
params.putBool("ConditionalExperimental", false);
|
||||
}
|
||||
if (key == "PersistExperimentalState") {
|
||||
static Params params_memory{"", true};
|
||||
int persisted_status = 0;
|
||||
@@ -147,6 +152,14 @@ void ParamControl::toggleClicked(bool state) {
|
||||
persisted_status = (current_status == 1 || current_status == 2) ? current_status : 0;
|
||||
}
|
||||
params.putInt("PersistedCEStatus", persisted_status);
|
||||
} else if (key == "PersistChillState") {
|
||||
static Params params_memory{"", true};
|
||||
int persisted_status = 0;
|
||||
if (state) {
|
||||
int current_status = params_memory.getInt("CCStatus");
|
||||
persisted_status = (current_status == 1 || current_status == 2) ? current_status : 0;
|
||||
}
|
||||
params.putInt("PersistedCCStatus", persisted_status);
|
||||
}
|
||||
setIcon(state);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user