add c3x position on sidebar
This commit is contained in:
Lee Jong Mun 2025-04-26 13:27:59 +09:00 committed by GitHub
parent 18bba4fc86
commit ee5076f581
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 40 additions and 9 deletions

View File

@ -119,11 +119,11 @@ inline static std::unordered_map<std::string, uint32_t> keys = {
{"UpdaterTargetBranch", CLEAR_ON_MANAGER_START},
{"UpdaterLastFetchTime", PERSISTENT},
{"Version", PERSISTENT},
// carrot
{"LongitudinalPersonalityMax", PERSISTENT},
{"NetworkAddress", CLEAR_ON_MANAGER_START},
{"ApiCache_NavDestinations", PERSISTENT},
{"NavDestination", CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION},
{"NavDestinationWaypoints", CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION},
@ -261,9 +261,10 @@ inline static std::unordered_map<std::string, uint32_t> keys = {
{"CustomSR", PERSISTENT},
{"SteerRatioRate", PERSISTENT},
{"SoftRestartTriggered", CLEAR_ON_MANAGER_START},
{"NNFF", PERSISTENT},
{"NNFFLite", PERSISTENT},
{"NNFFModelName", CLEAR_ON_OFFROAD_TRANSITION},
{"DevicePosition", CLEAR_ON_MANAGER_START},
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View File

@ -282,7 +282,26 @@ DevicePanel::DevicePanel(SettingsWindow *parent) : ListWidget(parent) {
auto statusCalibBtn = new ButtonControl(tr("Calibration Status"), tr("SHOW"), "");
connect(statusCalibBtn, &ButtonControl::showDescriptionEvent, this, &DevicePanel::updateCalibDescription);
addItem(statusCalibBtn);
std::string calib_bytes = params.get("CalibrationParams");
if (!calib_bytes.empty()) {
try {
AlignedBuffer aligned_buf;
capnp::FlatArrayMessageReader cmsg(aligned_buf.align(calib_bytes.data(), calib_bytes.size()));
auto calib = cmsg.getRoot<cereal::Event>().getLiveCalibration();
if (calib.getCalStatus() != cereal::LiveCalibrationData::Status::UNCALIBRATED) {
double pitch = calib.getRpyCalib()[1] * (180 / M_PI);
double yaw = calib.getRpyCalib()[2] * (180 / M_PI);
QString position = QString("%2 %1° %4 %3°")
.arg(QString::number(std::abs(pitch), 'g', 1), pitch > 0 ? "" : "",
QString::number(std::abs(yaw), 'g', 1), yaw > 0 ? "" : "");
params.put("DevicePosition", position.toStdString());
}
} catch (kj::Exception) {
qInfo() << "invalid CalibrationParams";
}
}
if (Hardware::TICI()) {
auto regulatoryBtn = new ButtonControl(tr("Regulatory"), tr("VIEW"), "");
connect(regulatoryBtn, &ButtonControl::clicked, [=]() {
@ -399,7 +418,7 @@ void SettingsWindow::setCurrentPanel(int index, const QString &param) {
if (param.endsWith("Panel")) {
QString panelName = param;
panelName.chop(5); // Remove "Panel" suffix
// Find the panel by name
for (int i = 0; i < nav_btns->buttons().size(); i++) {
if (nav_btns->buttons()[i]->text() == tr(panelName.toStdString().c_str())) {
@ -411,7 +430,7 @@ void SettingsWindow::setCurrentPanel(int index, const QString &param) {
emit expandToggleDescription(param);
}
}
panel_widget->setCurrentIndex(index);
nav_btns->buttons()[index]->setChecked(true);
}

View File

@ -28,6 +28,7 @@ Sidebar::Sidebar(QWidget *parent) : QFrame(parent), onroad(false), flag_pressed(
home_img = loadPixmap("../assets/images/button_home.png", home_btn.size());
flag_img = loadPixmap("../assets/images/button_flag.png", home_btn.size());
settings_img = loadPixmap("../assets/images/button_settings.png", settings_btn.size(), Qt::IgnoreAspectRatio);
c3x_img = loadPixmap("../assets/img_c3x.png", home_btn.size());
connect(this, &Sidebar::valueChanged, [=] { update(); });
@ -115,11 +116,20 @@ void Sidebar::paintEvent(QPaintEvent *event) {
p.fillRect(rect(), QColor(57, 57, 57));
QString c3x_position = QString("%1").arg(QString::fromStdString(params.get("DevicePosition")));
// buttons
p.setOpacity(settings_pressed ? 0.65 : 1.0);
p.drawPixmap(settings_btn.x(), settings_btn.y(), settings_img);
p.setOpacity(onroad && flag_pressed ? 0.65 : 1.0);
p.drawPixmap(home_btn.x(), home_btn.y(), onroad ? flag_img : home_img);
//p.drawPixmap(home_btn.x(), home_btn.y(), onroad ? flag_img : home_img);
p.drawPixmap(home_btn.x(), home_btn.y(), c3x_img);
const QRect r3 = QRect(0, 967, event->rect().width(), 50);
p.setFont(InterFont(30));
p.setPen(QColor(0xff, 0xff, 0xff));
p.drawText(r3, Qt::AlignCenter, c3x_position);
p.setOpacity(1.0);
// network

View File

@ -36,7 +36,7 @@ protected:
void mouseReleaseEvent(QMouseEvent *event) override;
void drawMetric(QPainter &p, const QPair<QString, QString> &label, QColor c, int y);
QPixmap home_img, flag_img, settings_img;
QPixmap home_img, flag_img, settings_img, c3x_img;
bool onroad, flag_pressed, settings_pressed;
const QMap<cereal::DeviceState::NetworkType, QString> network_type = {
{cereal::DeviceState::NetworkType::NONE, tr("--")},
@ -61,4 +61,5 @@ protected:
private:
std::unique_ptr<PubMaster> pm;
Networking *networking = nullptr;
Params params;
};