From a64f3341f2daa9415022f444934fc624996e46cb Mon Sep 17 00:00:00 2001 From: hawkeyexp Date: Wed, 25 Jul 2018 20:39:35 +0200 Subject: [PATCH] Init debug mode via gui --- .../f1x/openauto/autoapp/UI/MainWindow.hpp | 2 + src/autoapp/UI/MainWindow.cpp | 39 +++++++++--- src/autoapp/UI/SettingsWindow.cpp | 18 +++++- src/autoapp/UI/mainwindow.ui | 57 ++++++++++++++++- src/autoapp/UI/settingswindow.ui | 61 +++++++++++++++---- 5 files changed, 155 insertions(+), 22 deletions(-) diff --git a/include/f1x/openauto/autoapp/UI/MainWindow.hpp b/include/f1x/openauto/autoapp/UI/MainWindow.hpp index fc258c7..39f6b9c 100644 --- a/include/f1x/openauto/autoapp/UI/MainWindow.hpp +++ b/include/f1x/openauto/autoapp/UI/MainWindow.hpp @@ -75,6 +75,7 @@ private slots: void toggleExit(); void showRearCamBG(); void hideRearCamBG(); + void createDebuglog(); private: Ui::MainWindow* ui_; @@ -109,6 +110,7 @@ private: bool rearcamState = false; bool dashCamRecording = false; + bool systemDebugmode = false; }; } diff --git a/src/autoapp/UI/MainWindow.cpp b/src/autoapp/UI/MainWindow.cpp index b217271..a2e8a1d 100644 --- a/src/autoapp/UI/MainWindow.cpp +++ b/src/autoapp/UI/MainWindow.cpp @@ -172,6 +172,7 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi connect(ui_->pushButtonRearcamBack, &QPushButton::clicked, this, &MainWindow::hideRearCam); connect(ui_->pushButtonRearcamBack, &QPushButton::clicked, this, &MainWindow::cameraControlHide); connect(ui_->pushButtonSave, &QPushButton::clicked, this, &MainWindow::cameraSave); + connect(ui_->systemDebugging, &QPushButton::clicked, this, &MainWindow::createDebuglog); ui_->pushButtonCameraShow->show(); ui_->pushButtonCameraHide->hide(); } else { @@ -199,8 +200,14 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi ui_->pushButtonSave->hide(); ui_->pushButtonRearcam->hide(); ui_->pushButtonRearcamBack->hide(); - ui_->systemConfigInProgress->hide(); + ui_->systemDebugging->hide(); + + QFileInfo DebugmodeFile("/tmp/usb_debug_mode"); + if (DebugmodeFile.exists()) { + ui_->systemDebugging->show(); + this->systemDebugmode = true; + } if (!this->wifiButtonForce) { ui_->pushButtonWirelessConnection->hide(); @@ -448,8 +455,15 @@ void f1x::openauto::autoapp::ui::MainWindow::hideRearCamBG() ui_->pushButtonRearcamBack->hide(); } +void f1x::openauto::autoapp::ui::MainWindow::createDebuglog() +{ + system("/usr/local/bin/crankshaft debuglog &"); +} + void f1x::openauto::autoapp::ui::MainWindow::showTime() { + using namespace std::this_thread; // sleep_for + using namespace std::chrono; // milliseconds QTime time=QTime::currentTime(); QString time_text=time.toString("hh : mm : ss"); @@ -470,14 +484,28 @@ void f1x::openauto::autoapp::ui::MainWindow::showTime() } QFileInfo configInProgressFile("/tmp/config_in_progress"); - if (configInProgressFile.exists()) { + QFileInfo debugInProgressFile("/tmp/debug_in_progress"); + + if (configInProgressFile.exists() || debugInProgressFile.exists()) { if (ui_->systemConfigInProgress->isVisible() == false) { - ui_->systemConfigInProgress->setText("System config in progress - please wait ..."); - ui_->systemConfigInProgress->show(); + if (configInProgressFile.exists()) { + ui_->systemConfigInProgress->setText("System config in progress - please wait ..."); + ui_->pushButtonSettings->hide(); + ui_->systemConfigInProgress->show(); + } + if (debugInProgressFile.exists()) { + ui_->systemConfigInProgress->setText("Creating debug.zip on /boot - please wait ..."); + ui_->systemDebugging->hide(); + ui_->systemConfigInProgress->show(); + } } } else { if (ui_->systemConfigInProgress->isVisible() == true) { ui_->systemConfigInProgress->hide(); + ui_->pushButtonSettings->show(); + if (this->systemDebugmode) { + ui_->systemDebugging->show(); + } } } @@ -537,9 +565,6 @@ void f1x::openauto::autoapp::ui::MainWindow::showTime() } ui_->Digital_clock->setText(time_text); - - using namespace std::this_thread; // sleep_for - using namespace std::chrono; // milliseconds sleep_for(milliseconds(10)); /**if (configuration_->showClock()) { diff --git a/src/autoapp/UI/SettingsWindow.cpp b/src/autoapp/UI/SettingsWindow.cpp index 8d9bae2..aa9c233 100644 --- a/src/autoapp/UI/SettingsWindow.cpp +++ b/src/autoapp/UI/SettingsWindow.cpp @@ -171,6 +171,12 @@ void SettingsWindow::onSave() params.append("0"); } params.append("#"); + if (ui_->radioButtonDebugmodeEnabled->isChecked()) { + params.append("1"); + } else { + params.append("0"); + } + params.append("#"); system((std::string("/usr/local/bin/autoapp_helper setparams#") + std::string(params) + std::string(" &") ).c_str()); this->close(); } @@ -520,10 +526,18 @@ void SettingsWindow::loadSystemValues() // set custom brightness command if (getparams[26] == "1") { - ui_->checkBoxCustomBrightnessCommand->setChecked(true); + ui_->labelCustomBrightnessCommand->setText("Enabled"); } else { - ui_->checkBoxCustomBrightnessCommand->setChecked(false); + ui_->labelCustomBrightnessCommand->setText("Disabled"); } + + // set debug mode + if (getparams[27] == "1") { + ui_->radioButtonDebugmodeEnabled->setChecked(true); + } else { + ui_->radioButtonDebugmodeDisabled->setChecked(true); + } + } } diff --git a/src/autoapp/UI/mainwindow.ui b/src/autoapp/UI/mainwindow.ui index 4d270d1..057c1e3 100644 --- a/src/autoapp/UI/mainwindow.ui +++ b/src/autoapp/UI/mainwindow.ui @@ -644,9 +644,9 @@ - 200 + 175 368 - 400 + 450 24 @@ -672,6 +672,59 @@ Qt::AlignBottom|Qt::AlignRight|Qt::AlignTrailing + + + + 650 + 368 + 140 + 24 + + + + + 140 + 24 + + + + + Roboto + 14 + 75 + true + PreferAntialias + + + + false + + + QPushButton { background: grey; border: none; } +QPushButton:pressed { background: orange; border: none; } + + + Create Log + + + + 0 + 0 + + + + false + + + false + + + false + + + false + + diff --git a/src/autoapp/UI/settingswindow.ui b/src/autoapp/UI/settingswindow.ui index 2ef7527..859a613 100644 --- a/src/autoapp/UI/settingswindow.ui +++ b/src/autoapp/UI/settingswindow.ui @@ -2726,33 +2726,72 @@ subcontrol-position: center left; 0 320 - 616 - 91 + 300 + 61 Custom Brightness Command - + 10 30 281 + 21 + + + + disabled + + + + + + + 325 + 320 + 291 + 91 + + + + Debugmode + + + + + 120 + 30 + 120 23 - Custom Birghtness Command activated + Enabled - + + + + + 10 + 30 + 80 + 23 + + + + Disabled + + true - + - 30 + 10 56 21 31 @@ -2762,12 +2801,12 @@ subcontrol-position: center left; <html><head/><body><p><img src=":/ico_info.png"/></p></body></html> - + - 60 + 40 60 - 551 + 251 23 @@ -2777,7 +2816,7 @@ subcontrol-position: center left; - Just an information - not checkable! - Can be activated in crankshaft_env.sh! + Debud Mode excludes dev mode! true