Custom steering wheel icons

Added toggle for custom steering wheel icons in the onroad UI.

Want to add your own steering wheel? Request one under "feature-requests" on the FrogPilot Discord!
This commit is contained in:
FrogAi
2024-01-12 22:39:30 -07:00
parent 62e60535e6
commit 142e5e0975
12 changed files with 38 additions and 2 deletions

View File

@@ -265,6 +265,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"UpdateSchedule", PERSISTENT}, {"UpdateSchedule", PERSISTENT},
{"UpdateTime", PERSISTENT}, {"UpdateTime", PERSISTENT},
{"UseSI", PERSISTENT}, {"UseSI", PERSISTENT},
{"WheelIcon", PERSISTENT},
{"WideCamera", PERSISTENT}, {"WideCamera", PERSISTENT},
}; };

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

View File

@@ -20,6 +20,7 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot
{"UnlimitedLength", "'Unlimited' Road UI Length", "Extend the display of the path, lane lines, and road edges as far as the system can detect, providing a more expansive view of the road ahead.", ""}, {"UnlimitedLength", "'Unlimited' Road UI Length", "Extend the display of the path, lane lines, and road edges as far as the system can detect, providing a more expansive view of the road ahead.", ""},
{"ScreenBrightness", "Screen Brightness", "Customize your screen brightness.", "../frogpilot/assets/toggle_icons/icon_light.png"}, {"ScreenBrightness", "Screen Brightness", "Customize your screen brightness.", "../frogpilot/assets/toggle_icons/icon_light.png"},
{"WheelIcon", "Steering Wheel Icon", "Replace the default steering wheel icon with a custom design, adding a unique touch to your interface.", "../assets/offroad/icon_openpilot.png"},
}; };
for (const auto &[param, title, desc, icon] : visualToggles) { for (const auto &[param, title, desc, icon] : visualToggles) {
@@ -67,6 +68,12 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot
} }
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 101, brightnessLabels, this, false); toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 101, brightnessLabels, this, false);
} else if (param == "WheelIcon") {
std::vector<QString> wheelToggles{};
std::vector<QString> wheelToggleNames{};
std::map<int, QString> steeringWheelLabels = {{0, "Stock"}, {1, "Lexus"}, {2, "Toyota"}, {3, "Frog"}, {4, "Rocket"}, {5, "Hyundai"}, {6, "Stalin"}};
toggle = new FrogPilotParamValueToggleControl(param, title, desc, icon, 0, 6, steeringWheelLabels, this, true, "", 1, wheelToggles, wheelToggleNames);
} else { } else {
toggle = new ParamControl(param, title, desc, icon, this); toggle = new ParamControl(param, title, desc, icon, this);
} }

View File

@@ -286,6 +286,17 @@ ExperimentalButton::ExperimentalButton(QWidget *parent) : experimental_mode(fals
engage_img = loadPixmap("../assets/img_chffr_wheel.png", {img_size, img_size}); engage_img = loadPixmap("../assets/img_chffr_wheel.png", {img_size, img_size});
experimental_img = loadPixmap("../assets/img_experimental.svg", {img_size, img_size}); experimental_img = loadPixmap("../assets/img_experimental.svg", {img_size, img_size});
QObject::connect(this, &QPushButton::clicked, this, &ExperimentalButton::changeMode); QObject::connect(this, &QPushButton::clicked, this, &ExperimentalButton::changeMode);
// Custom steering wheel images
wheelImages = {
{0, loadPixmap("../assets/img_chffr_wheel.png", {img_size, img_size})},
{1, loadPixmap("../frogpilot/assets/wheel_images/lexus.png", {img_size, img_size})},
{2, loadPixmap("../frogpilot/assets/wheel_images/toyota.png", {img_size, img_size})},
{3, loadPixmap("../frogpilot/assets/wheel_images/frog.png", {img_size, img_size})},
{4, loadPixmap("../frogpilot/assets/wheel_images/rocket.png", {img_size, img_size})},
{5, loadPixmap("../frogpilot/assets/wheel_images/hyundai.png", {img_size, img_size})},
{6, loadPixmap("../frogpilot/assets/wheel_images/stalin.png", {img_size, img_size})}
};
} }
void ExperimentalButton::changeMode() { void ExperimentalButton::changeMode() {
@@ -308,13 +319,25 @@ void ExperimentalButton::updateState(const UIState &s, bool leadInfo) {
} }
// FrogPilot variables // FrogPilot variables
wheelIcon = scene.wheel_icon;
y_offset = leadInfo ? 10 : 0; y_offset = leadInfo ? 10 : 0;
} }
void ExperimentalButton::paintEvent(QPaintEvent *event) { void ExperimentalButton::paintEvent(QPaintEvent *event) {
QPainter p(this); QPainter p(this);
QPixmap img = experimental_mode ? experimental_img : engage_img; // Custom steering wheel icon
drawIcon(p, QPoint(btn_size / 2, btn_size / 2 + y_offset), img, QColor(0, 0, 0, 166), (isDown() || (!engageable && !scene.always_on_lateral_active)) ? 0.6 : 1.0); engage_img = wheelImages[wheelIcon];
QPixmap img = wheelIcon ? engage_img : (experimental_mode ? experimental_img : engage_img);
QColor background_color = wheelIcon && !isDown() && engageable ?
(scene.conditional_status == 1 ? QColor(255, 246, 0, 255) :
(experimental_mode ? QColor(218, 111, 37, 241) :
(scene.navigate_on_openpilot ? QColor(49, 161, 238, 255) : QColor(0, 0, 0, 166)))) :
(scene.always_on_lateral_active ? QColor(10, 186, 181, 255) :
QColor(0, 0, 0, 166));
drawIcon(p, QPoint(btn_size / 2, btn_size / 2 + y_offset), img, background_color, (isDown() || (!engageable && !scene.always_on_lateral_active)) ? 0.6 : 1.0);
} }

View File

@@ -57,6 +57,9 @@ private:
// FrogPilot variables // FrogPilot variables
UIScene &scene; UIScene &scene;
std::map<int, QPixmap> wheelImages;
int wheelIcon;
int y_offset; int y_offset;
}; };

View File

@@ -294,6 +294,7 @@ void ui_update_params(UIState *s) {
scene.unlimited_road_ui_length = scene.model_ui && params.getBool("UnlimitedLength"); scene.unlimited_road_ui_length = scene.model_ui && params.getBool("UnlimitedLength");
scene.screen_brightness = params.getInt("ScreenBrightness"); scene.screen_brightness = params.getInt("ScreenBrightness");
scene.wheel_icon = params.getInt("WheelIcon");
} }
void UIState::updateStatus() { void UIState::updateStatus() {

View File

@@ -200,6 +200,7 @@ typedef struct UIScene {
int obstacle_distance_stock; int obstacle_distance_stock;
int screen_brightness; int screen_brightness;
int stopped_equivalence; int stopped_equivalence;
int wheel_icon;
QPolygonF track_adjacent_vertices[6]; QPolygonF track_adjacent_vertices[6];
QPolygonF track_edge_vertices; QPolygonF track_edge_vertices;