parent
18bba4fc86
commit
ee5076f581
@ -266,4 +266,5 @@ inline static std::unordered_map<std::string, uint32_t> keys = {
|
||||
{"NNFFLite", PERSISTENT},
|
||||
{"NNFFModelName", CLEAR_ON_OFFROAD_TRANSITION},
|
||||
|
||||
{"DevicePosition", CLEAR_ON_MANAGER_START},
|
||||
};
|
||||
|
BIN
selfdrive/assets/img_c3x.png
Normal file
BIN
selfdrive/assets/img_c3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
@ -283,6 +283,25 @@ DevicePanel::DevicePanel(SettingsWindow *parent) : ListWidget(parent) {
|
||||
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, [=]() {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user