UI: body support (#24079)
	
		
	
				
					
				
			* body ui template
* faces
* abs
* not raw
* auto switch
* check that
* no smoosh
* cmath
old-commit-hash: b51deb97d1
			
			
				vw-mqb-aeb
			
			
		
							parent
							
								
									abdcce3ad5
								
							
						
					
					
						commit
						1ce647b0a6
					
				
				 8 changed files with 80 additions and 2 deletions
			
			
		| @ -0,0 +1,3 @@ | ||||
| version https://git-lfs.github.com/spec/v1 | ||||
| oid sha256:a4b3f7e9bc5cf058c3daaca23f99c0aafe4324eb4b2e0f8ccb3759b252a8101d | ||||
| size 69319 | ||||
| @ -0,0 +1,3 @@ | ||||
| version https://git-lfs.github.com/spec/v1 | ||||
| oid sha256:3481857356714833aa196a89c47de3246dd395a51fbfd9e0dff53058c109ced8 | ||||
| size 400908 | ||||
| @ -0,0 +1,34 @@ | ||||
| #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(); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,19 @@ | ||||
| #pragma once | ||||
| 
 | ||||
| #include <QMovie> | ||||
| #include <QLabel> | ||||
| 
 | ||||
| #include "selfdrive/ui/ui.h" | ||||
| 
 | ||||
| class BodyWindow : public QLabel { | ||||
|   Q_OBJECT | ||||
| 
 | ||||
| public: | ||||
|   BodyWindow(QWidget* parent = 0); | ||||
| 
 | ||||
| private: | ||||
|   QMovie *awake, *sleep; | ||||
| 
 | ||||
| private slots: | ||||
|   void updateState(const UIState &s); | ||||
| }; | ||||
					Loading…
					
					
				
		Reference in new issue