You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
856 B
34 lines
856 B
#include "selfdrive/ui/qt/body.h"
|
|
|
|
#include <cmath>
|
|
|
|
BodyWindow::BodyWindow(QWidget *parent) : QLabel(parent) {
|
|
awake = new QMovie("../assets/body/awake.gif");
|
|
awake->setCacheMode(QMovie::CacheAll);
|
|
sleep = new QMovie("../assets/body/sleep.gif");
|
|
sleep->setCacheMode(QMovie::CacheAll);
|
|
|
|
QPalette p(Qt::black);
|
|
setPalette(p);
|
|
setAutoFillBackground(true);
|
|
|
|
setAlignment(Qt::AlignCenter);
|
|
|
|
QObject::connect(uiState(), &UIState::uiUpdate, this, &BodyWindow::updateState);
|
|
}
|
|
|
|
void BodyWindow::updateState(const UIState &s) {
|
|
if (!isVisible()) {
|
|
return;
|
|
}
|
|
|
|
const SubMaster &sm = *(s.sm);
|
|
|
|
// TODO: use carState.standstill when that's fixed
|
|
const bool standstill = std::abs(sm["carState"].getCarState().getVEgo()) < 0.01;
|
|
QMovie *m = standstill ? sleep : awake;
|
|
if (m != movie()) {
|
|
setMovie(m);
|
|
movie()->start();
|
|
}
|
|
}
|
|
|