mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-05 16:26:14 +08:00
Controls - Experimental Mode Activation - Double Tap the UI
Enable/disable 'Experimental Mode' by double tapping the onroad UI within a 0.5 second time frame.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "selfdrive/ui/qt/onroad/onroad_home.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
#include <QStackedLayout>
|
||||
|
||||
@@ -48,6 +49,13 @@ OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) {
|
||||
QObject::connect(uiState(), &UIState::uiUpdate, this, &OnroadWindow::updateState);
|
||||
QObject::connect(uiState(), &UIState::offroadTransition, this, &OnroadWindow::offroadTransition);
|
||||
QObject::connect(uiState(), &UIState::primeChanged, this, &OnroadWindow::primeChanged);
|
||||
|
||||
// FrogPilot variables
|
||||
QObject::connect(&clickTimer, &QTimer::timeout, this, [this]() {
|
||||
clickTimer.stop();
|
||||
QMouseEvent *event = new QMouseEvent(QEvent::MouseButtonPress, timeoutPoint, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
||||
QApplication::postEvent(this, event);
|
||||
});
|
||||
}
|
||||
|
||||
void OnroadWindow::updateState(const UIState &s) {
|
||||
@@ -89,6 +97,23 @@ void OnroadWindow::mousePressEvent(QMouseEvent* e) {
|
||||
// FrogPilot clickable widgets
|
||||
QPoint pos = e->pos();
|
||||
|
||||
if (scene.experimental_mode_via_screen && pos != timeoutPoint) {
|
||||
if (clickTimer.isActive()) {
|
||||
clickTimer.stop();
|
||||
|
||||
if (scene.conditional_experimental) {
|
||||
int override_value = (scene.conditional_status >= 1 && scene.conditional_status <= 6) ? 0 : (scene.conditional_status >= 7 ? 5 : 6);
|
||||
paramsMemory.putIntNonBlocking("CEStatus", override_value);
|
||||
} else {
|
||||
params.putBoolNonBlocking("ExperimentalMode", !params.getBool("ExperimentalMode"));
|
||||
}
|
||||
|
||||
} else {
|
||||
clickTimer.start(500);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MAPS
|
||||
if (map != nullptr) {
|
||||
// Switch between map and sidebar when using navigate on openpilot
|
||||
|
||||
@@ -25,6 +25,10 @@ private:
|
||||
QHBoxLayout* split;
|
||||
|
||||
// FrogPilot variables
|
||||
QPoint timeoutPoint = QPoint(420, 69);
|
||||
|
||||
QTimer clickTimer;
|
||||
|
||||
Params params;
|
||||
Params paramsMemory{"/dev/shm/params"};
|
||||
|
||||
|
||||
@@ -282,6 +282,8 @@ void ui_update_frogpilot_params(UIState *s, Params ¶ms) {
|
||||
scene.onroad_distance_button = driving_personalities && params.getBool("OnroadDistanceButton");
|
||||
scene.use_kaofui_icons = scene.onroad_distance_button && params.getBool("KaofuiIcons");
|
||||
|
||||
scene.experimental_mode_via_screen = scene.longitudinal_control && params.getBool("ExperimentalModeActivation") && params.getBool("ExperimentalModeViaTap");
|
||||
|
||||
scene.tethering_config = params.getInt("TetheringEnabled");
|
||||
if (scene.tethering_config == 2) {
|
||||
WifiManager(s).setTetheringEnabled(true);
|
||||
|
||||
@@ -124,6 +124,7 @@ typedef struct UIScene {
|
||||
bool conditional_experimental;
|
||||
bool enabled;
|
||||
bool experimental_mode;
|
||||
bool experimental_mode_via_screen;
|
||||
bool map_open;
|
||||
bool online;
|
||||
bool onroad_distance_button;
|
||||
|
||||
Reference in New Issue
Block a user