Files
oscarpilot/selfdrive/frogpilot/ui/frogpilot_functions.cc
Your Name 53acbd82d0 wip
2024-02-16 17:45:30 -06:00

181 lines
5.4 KiB
C++

#include <filesystem>
#include "selfdrive/frogpilot/ui/frogpilot_functions.h"
#include "selfdrive/ui/ui.h"
bool FrogPilotConfirmationDialog::toggle(const QString &prompt_text, const QString &confirm_text, QWidget *parent) {
ConfirmationDialog d = ConfirmationDialog(prompt_text, confirm_text, tr("Reboot Later"), false, parent);
return d.exec();
}
bool FrogPilotConfirmationDialog::toggleAlert(const QString &prompt_text, const QString &button_text, QWidget *parent) {
ConfirmationDialog d = ConfirmationDialog(prompt_text, button_text, "", false, parent);
return d.exec();
}
bool FrogPilotConfirmationDialog::yesorno(const QString &prompt_text, QWidget *parent) {
ConfirmationDialog d = ConfirmationDialog(prompt_text, tr("Yes"), tr("No"), false, parent);
return d.exec();
}
FrogPilotButtonIconControl::FrogPilotButtonIconControl(const QString &title, const QString &text, const QString &desc, const QString &icon, QWidget *parent) : AbstractControl(title, desc, icon, parent) {
btn.setText(text);
btn.setStyleSheet(R"(
QPushButton {
padding: 0;
border-radius: 50px;
font-size: 35px;
font-weight: 500;
color: #E4E4E4;
background-color: #393939;
}
QPushButton:pressed {
background-color: #4a4a4a;
}
QPushButton:disabled {
color: #33E4E4E4;
}
)");
btn.setFixedSize(250, 100);
QObject::connect(&btn, &QPushButton::clicked, this, &FrogPilotButtonIconControl::clicked);
hlayout->addWidget(&btn);
}
void setDefaultParams() {
Params params = Params();
bool FrogsGoMoo = false;
// bool elite_mode = params.get("DongleId").substr(0, 6) == "90bb71";
std::map<std::string, std::string> defaultValues {
{"AccelerationPath", "0"}, // NOTE: Should be one if using OPLong
{"AccelerationProfile", "2"},
{"AdjacentPath", "0"}, // Test?
{"AdjustablePersonalities", "0"},
{"AggressiveAcceleration", "1"},
{"AggressiveFollow", "12"},
{"AggressiveJerk", "5"},
{"AlwaysOnLateral", "1"},
{"AlwaysOnLateralMain", "1"},
{"AverageCurvature", "1"},
{"BlindSpotPath", "1"},
{"CameraView", "0"},
{"CECurves", "1"},
{"CECurvesLead", "1"},
{"CENavigation", "1"},
{"CESignal", "0"},
{"CESlowerLead", "0"},
{"CESpeed", "0"},
{"CESpeedLead", "0"},
{"CEStopLights", "0"},
{"CEStopLightsLead", "0"},
{"Compass", "0"},
{"ConditionalExperimental", "1"},
{"CurveSensitivity", "125"}, // was 100
{"CustomColors", "1"},
{"CustomIcons", "1"},
{"CustomPersonalities", "0"},
{"CustomSignals", "0"},
{"CustomSounds", "1"},
{"CustomTheme", "1"},
{"CustomUI", "0"},
{"DeviceShutdown", "1"},
{"DisableOnroadUploads", "1"},
{"DriverCamera", "0"},
{"DriveStats", "1"},
{"EVTable", FrogsGoMoo ? "0" : "1"},
{"ExperimentalModeActivation", "0"},
{"ExperimentalModeViaLKAS", "0"},
{"ExperimentalModeViaScreen", "0"},
{"Fahrenheit", "1"},
{"FireTheBabysitter", FrogsGoMoo ? "1" : "0"},
{"FullMap", "0"},
{"GasRegenCmd", "0"},
{"GoatScream", "0"},
{"GreenLightAlert", "0"},
{"HideSpeed", "0"},
{"HigherBitrate", "0"},
{"LaneChangeTime", "0"},
{"LaneDetection", "1"},
{"LaneLinesWidth", "4"},
{"LateralTune", "1"},
{"LeadInfo", FrogsGoMoo ? "1" : "0"},
{"LockDoors", "0"},
{"LongitudinalTune", "1"},
{"LongPitch", FrogsGoMoo ? "0" : "1"},
{"LowerVolt", FrogsGoMoo ? "0" : "1"},
{"Model", "3"},
{"ModelUI", "1"},
{"MTSCEnabled", "1"},
{"MuteDM", "1"},
{"MuteDoor", "1"},
{"MuteOverheated", "0"},
{"MuteSeatbelt", "1"},
{"NNFF", "1"},
{"NoLogging", "1"},
{"NudgelessLaneChange", "0"},
{"NumericalTemp", FrogsGoMoo ? "1" : "0"},
{"Offset1", "3"},
{"Offset2", FrogsGoMoo ? "7" : "5"},
{"Offset3", "7"},
{"Offset4", FrogsGoMoo ? "20" : "7"},
{"OneLaneChange", "1"},
{"PathEdgeWidth", "20"},
{"PathWidth", "61"},
{"PauseLateralOnSignal", "20"},
{"PreferredSchedule", "0"},
{"QOLControls", "1"},
{"QOLVisuals", "1"},
{"RandomEvents", "0"},
{"RelaxedFollow", "30"},
{"RelaxedJerk", "50"},
{"ReverseCruise", "0"},
{"RoadEdgesWidth", "2"},
{"RoadNameUI", "1"},
{"RotatingWheel", "1"},
{"ScreenBrightness", "101"},
{"SearchInput", "0"},
{"ShowCPU", "0"},
{"ShowFPS", "0"},
{"ShowGPU", "0"},
{"ShowMemoryUsage", "0"},
{"Sidebar", "0"},
{"SilentMode", "0"},
{"SLCFallback", "2"},
{"SLCOverride", FrogsGoMoo ? "2" : "1"},
{"SLCPriority", "1"},
{"SmoothBraking", "1"},
{"SNGHack", FrogsGoMoo ? "0" : "1"},
{"SpeedLimitController", "1"},
{"StandardFollow", "15"},
{"StandardJerk", "10"},
{"StoppingDistance", FrogsGoMoo ? "6" : "0"},
{"TSS2Tune", "1"},
{"TurnAggressiveness", FrogsGoMoo ? "150" : "100"}, // Test 90?
{"TurnDesires", "0"},
{"UnlimitedLength", "1"},
{"UseSI", FrogsGoMoo ? "1" : "0"},
{"UseVienna", "0"},
{"VisionTurnControl", "1"},
{"WheelIcon", "0"},
{"IsLdwEnabled", "1"},
{"RecordFront", "0"}
};
bool rebootRequired = false;
for (const auto &[key, value] : defaultValues) {
if (params.get(key).empty()) {
params.put(key, value);
rebootRequired = true;
}
}
if (rebootRequired) {
while (!std::filesystem::exists("/data/openpilot/prebuilt")) {
std::this_thread::sleep_for(std::chrono::seconds(1));
}
Hardware::reboot();
}
}