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.
		
		
		
		
		
			
		
			
				
					
					
						
							97 lines
						
					
					
						
							1.8 KiB
						
					
					
				
			
		
		
	
	
							97 lines
						
					
					
						
							1.8 KiB
						
					
					
				| #pragma once
 | |
| 
 | |
| #include <QLabel>
 | |
| #include <QOpenGLFunctions>
 | |
| #include <QOpenGLWidget>
 | |
| #include <QPushButton>
 | |
| #include <QStackedLayout>
 | |
| #include <QStackedWidget>
 | |
| #include <QTimer>
 | |
| #include <QWidget>
 | |
| 
 | |
| #include "sound.hpp"
 | |
| #include "ui/ui.hpp"
 | |
| #include "common/util.h"
 | |
| #include "widgets/offroad_alerts.hpp"
 | |
| 
 | |
| // container window for onroad NVG UI
 | |
| class GLWindow : public QOpenGLWidget, protected QOpenGLFunctions {
 | |
|   Q_OBJECT
 | |
| 
 | |
| public:
 | |
|   using QOpenGLWidget::QOpenGLWidget;
 | |
|   explicit GLWindow(QWidget* parent = 0);
 | |
|   void wake();
 | |
|   ~GLWindow();
 | |
| 
 | |
|   inline static UIState ui_state = {0};
 | |
| 
 | |
| signals:
 | |
|   void offroadTransition(bool offroad);
 | |
|   void screen_shutoff();
 | |
| 
 | |
| protected:
 | |
|   void initializeGL() override;
 | |
|   void resizeGL(int w, int h) override;
 | |
|   void paintGL() override;
 | |
| 
 | |
| private:
 | |
|   QTimer* timer;
 | |
|   QTimer* backlight_timer;
 | |
| 
 | |
|   Sound sound;
 | |
| 
 | |
|   bool onroad = true;
 | |
|   double prev_draw_t = 0;
 | |
| 
 | |
|   // TODO: make a nice abstraction to handle embedded device stuff
 | |
|   float brightness_b = 0;
 | |
|   float brightness_m = 0;
 | |
|   float last_brightness = 0;
 | |
|   FirstOrderFilter brightness_filter;
 | |
| 
 | |
| public slots:
 | |
|   void timerUpdate();
 | |
|   void backlightUpdate();
 | |
| };
 | |
| 
 | |
| // offroad home screen
 | |
| class OffroadHome : public QWidget {
 | |
|   Q_OBJECT
 | |
| 
 | |
| public:
 | |
|   explicit OffroadHome(QWidget* parent = 0);
 | |
| 
 | |
| private:
 | |
|   QTimer* timer;
 | |
| 
 | |
|   QLabel* date;
 | |
|   QStackedLayout* center_layout;
 | |
|   OffroadAlert* alerts_widget;
 | |
|   QPushButton* alert_notification;
 | |
| 
 | |
| public slots:
 | |
|   void closeAlerts();
 | |
|   void openAlerts();
 | |
|   void refresh();
 | |
| };
 | |
| 
 | |
| class HomeWindow : public QWidget {
 | |
|   Q_OBJECT
 | |
| 
 | |
| public:
 | |
|   explicit HomeWindow(QWidget* parent = 0);
 | |
|   GLWindow* glWindow;
 | |
| 
 | |
| signals:
 | |
|   void openSettings();
 | |
|   void closeSettings();
 | |
|   void offroadTransition(bool offroad);
 | |
| 
 | |
| protected:
 | |
|   void mousePressEvent(QMouseEvent* e) override;
 | |
| 
 | |
| private:
 | |
|   OffroadHome* home;
 | |
|   QStackedLayout* layout;
 | |
| };
 | |
| 
 |