mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-06 19:45:43 +08:00
Merge branch 'master-priv-sunnylink-sidebar-status' into master-dev-c3-new
# Conflicts: # CHANGELOGS.md
This commit is contained in:
@@ -54,6 +54,7 @@ sunnypilot - 0.9.7.0 (2024-05-xx)
|
||||
* Display Metrics Below Chevron
|
||||
* NEW❗: Metrics is now being displayed below the chevron instead of above
|
||||
* NEW❗: Display both Distance and Speed simultaneously
|
||||
* NEW❗: View sunnylink connectivity status on the left sidebar!
|
||||
* Ford F-150 2022-23 support
|
||||
* Ford F-150 Lightning 2021-23 support
|
||||
* Ford Mustang Mach-E 2021-23 support
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
#include "common/params.h"
|
||||
|
||||
void Sidebar::drawMetric(QPainter &p, const QPair<QString, QString> &label, QColor c, int y) {
|
||||
const QRect rect = {30, y, 240, 126};
|
||||
@@ -152,6 +153,21 @@ void Sidebar::updateState(const UIState &s) {
|
||||
pandaStatus = {{tr("GPS"), tr("SEARCH")}, warning_color};
|
||||
}
|
||||
setProperty("pandaStatus", QVariant::fromValue(pandaStatus));
|
||||
|
||||
ItemStatus sunnylinkStatus;
|
||||
auto last_sunnylink_ping = std::strtol(params.get("LastSunnylinkPingTime").c_str(), nullptr, 10);
|
||||
auto sunnylink_enabled = params.getBool("SunnylinkEnabled");
|
||||
if (!sunnylink_enabled) {
|
||||
sunnylinkStatus = ItemStatus{{tr("SUNNYLINK"), tr("DISABLED")}, disabled_color};
|
||||
} else if (last_ping == 0) {
|
||||
sunnylinkStatus = ItemStatus{{tr("SUNNYLINK"), tr("OFFLINE")}, warning_color};
|
||||
} else {
|
||||
if (nanos_since_boot() - last_sunnylink_ping < 80e9)
|
||||
sunnylinkStatus = ItemStatus{{tr("SUNNYLINK"), tr("ONLINE")}, good_color};
|
||||
else
|
||||
sunnylinkStatus = ItemStatus{{tr("SUNNYLINK"), tr("ERROR")}, danger_color};
|
||||
}
|
||||
setProperty("sunnylinkStatus", QVariant::fromValue(sunnylinkStatus));
|
||||
}
|
||||
|
||||
void Sidebar::paintEvent(QPaintEvent *event) {
|
||||
@@ -183,7 +199,8 @@ void Sidebar::paintEvent(QPaintEvent *event) {
|
||||
p.drawText(r, Qt::AlignCenter, net_type);
|
||||
|
||||
// metrics
|
||||
drawMetric(p, temp_status.first, temp_status.second, 338);
|
||||
drawMetric(p, panda_status.first, panda_status.second, 496);
|
||||
drawMetric(p, connect_status.first, connect_status.second, 654);
|
||||
drawMetric(p, temp_status.first, temp_status.second, 310);
|
||||
drawMetric(p, panda_status.first, panda_status.second, 440);
|
||||
drawMetric(p, connect_status.first, connect_status.second, 570);
|
||||
drawMetric(p, sunnylink_status.first, sunnylink_status.second, 700);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ Q_DECLARE_METATYPE(ItemStatus);
|
||||
class Sidebar : public QFrame {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(ItemStatus connectStatus MEMBER connect_status NOTIFY valueChanged);
|
||||
Q_PROPERTY(ItemStatus sunnylinkStatus MEMBER sunnylink_status NOTIFY valueChanged);
|
||||
Q_PROPERTY(ItemStatus pandaStatus MEMBER panda_status NOTIFY valueChanged);
|
||||
Q_PROPERTY(ItemStatus tempStatus MEMBER temp_status NOTIFY valueChanged);
|
||||
Q_PROPERTY(QString netType MEMBER net_type NOTIFY valueChanged);
|
||||
@@ -53,12 +54,14 @@ protected:
|
||||
const QColor good_color = QColor(255, 255, 255);
|
||||
const QColor warning_color = QColor(218, 202, 37);
|
||||
const QColor danger_color = QColor(201, 34, 49);
|
||||
const QColor disabled_color = QColor(128, 128, 128);
|
||||
|
||||
ItemStatus connect_status, panda_status, temp_status;
|
||||
ItemStatus connect_status, panda_status, temp_status, sunnylink_status;
|
||||
QString net_type;
|
||||
int net_strength = 0;
|
||||
|
||||
private:
|
||||
Params params;
|
||||
std::unique_ptr<PubMaster> pm;
|
||||
|
||||
QString sidebar_temp = "0";
|
||||
|
||||
Reference in New Issue
Block a user