forked from commaai/openpilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into PA-master
- Loading branch information
Showing
17 changed files
with
434 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule panda
updated
14 files
+2 −2 | Dockerfile | |
+2 −2 | Jenkinsfile | |
+2 −2 | __init__.py | |
+3 −2 | board/README.md | |
+1 −1 | board/drivers/spi.h | |
+14 −20 | board/safety/safety_subaru.h | |
+0 −1 | python/__init__.py | |
+1 −2 | python/base.py | |
+2 −0 | python/constants.py | |
+74 −71 | python/spi.py | |
+1 −1 | python/uds.py | |
+1 −2 | python/usb.py | |
+0 −2 | tests/hitl/8_spi.py | |
+3 −1 | tests/reflash_internal_panda.py |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include "selfdrive/ui/qt/maps/map_eta.h" | ||
|
||
#include <QDateTime> | ||
#include <QPainter> | ||
|
||
#include "selfdrive/ui/ui.h" | ||
|
||
const float MANEUVER_TRANSITION_THRESHOLD = 10; | ||
|
||
MapETA::MapETA(QWidget *parent) : QWidget(parent) { | ||
setVisible(false); | ||
setAttribute(Qt::WA_TranslucentBackground); | ||
eta_doc.setUndoRedoEnabled(false); | ||
eta_doc.setDefaultStyleSheet("body {font-family:Inter;font-size:60px;color:white;} b{font-size:70px;font-weight:600}"); | ||
} | ||
|
||
void MapETA::paintEvent(QPaintEvent *event) { | ||
if (!eta_doc.isEmpty()) { | ||
QPainter p(this); | ||
p.setRenderHint(QPainter::Antialiasing); | ||
p.setPen(Qt::NoPen); | ||
p.setBrush(QColor(0, 0, 0, 150)); | ||
QSizeF txt_size = eta_doc.size(); | ||
p.drawRoundedRect((width() - txt_size.width()) / 2 - UI_BORDER_SIZE, 0, txt_size.width() + UI_BORDER_SIZE * 2, height() + 25, 25, 25); | ||
p.translate((width() - txt_size.width()) / 2, (height() - txt_size.height()) / 2); | ||
eta_doc.drawContents(&p); | ||
} | ||
} | ||
|
||
void MapETA::updateETA(float s, float s_typical, float d) { | ||
// ETA | ||
auto eta_t = QDateTime::currentDateTime().addSecs(s).time(); | ||
auto eta = format_24h ? std::array{eta_t.toString("HH:mm"), tr("eta")} | ||
: std::array{eta_t.toString("h:mm a").split(' ')[0], eta_t.toString("a")}; | ||
|
||
// Remaining time | ||
auto remaining = s < 3600 ? std::array{QString::number(int(s / 60)), tr("min")} | ||
: std::array{QString("%1:%2").arg((int)s / 3600).arg(((int)s % 3600) / 60, 2, 10, QLatin1Char('0')), tr("hr")}; | ||
QString color = "#25DA6E"; | ||
if (s / s_typical > 1.5) | ||
color = "#DA3025"; | ||
else if (s / s_typical > 1.2) | ||
color = "#DAA725"; | ||
|
||
// Distance | ||
float num = uiState()->scene.is_metric ? (d / 1000.0) : (d * METER_TO_MILE); | ||
auto distance = std::array{QString::number(num, 'f', num < 100 ? 1 : 0), | ||
uiState()->scene.is_metric ? tr("km") : tr("mi")}; | ||
|
||
eta_doc.setHtml(QString(R"(<body><b>%1</b>%2 <span style="color:%3"><b>%4</b>%5</span> <b>%6</b>%7</body>)") | ||
.arg(eta[0], eta[1], color, remaining[0], remaining[1], distance[0], distance[1])); | ||
|
||
setVisible(d >= MANEUVER_TRANSITION_THRESHOLD); | ||
update(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#include <QPaintEvent> | ||
#include <QTextDocument> | ||
#include <QWidget> | ||
|
||
#include "common/params.h" | ||
|
||
class MapETA : public QWidget { | ||
Q_OBJECT | ||
|
||
public: | ||
MapETA(QWidget * parent=nullptr); | ||
void updateETA(float seconds, float seconds_typical, float distance); | ||
|
||
private: | ||
void paintEvent(QPaintEvent *event) override; | ||
void showEvent(QShowEvent *event) override { format_24h = param.getBool("NavSettingTime24h"); } | ||
|
||
bool format_24h = false; | ||
QTextDocument eta_doc; | ||
Params param; | ||
}; |
Oops, something went wrong.