diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2021-08-18 07:49:16 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2021-08-18 08:33:40 +0200 |
commit | 78519a6a50271dbaaf7d04d84665777a637354d7 (patch) | |
tree | 9a836bc225bd42a6443dd0cf570f21b17a65330b /video-ps3eye | |
parent | 106feabe8b47be19e82f1141999fa861ca3be10b (diff) |
video/ps3eye: throttle sensor reset
Diffstat (limited to 'video-ps3eye')
-rw-r--r-- | video-ps3eye/module.cpp | 6 | ||||
-rw-r--r-- | video-ps3eye/module.hpp | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/video-ps3eye/module.cpp b/video-ps3eye/module.cpp index 28deedc8..a4afacb5 100644 --- a/video-ps3eye/module.cpp +++ b/video-ps3eye/module.cpp @@ -254,16 +254,18 @@ OTR_REGISTER_CAMERA(ps3eye_camera_) dialog::dialog(QWidget* parent) : QWidget(parent) { ui.setupUi(this); + t.setInterval(500); t.setSingleShot(true); tie_setting(s.exposure, ui.exposure_slider); tie_setting(s.gain, ui.gain_slider); ui.exposure_label->setValue((int)*s.exposure); ui.gain_label->setValue((int)*s.gain); - connect(&s.exposure, value_::value_changed<slider_value>(), this, [this](const slider_value&) { s.set_exposure(); }); - connect(&s.gain, value_::value_changed<slider_value>(), this, [this](const slider_value&) { s.set_gain(); }); + connect(&s.exposure, value_::value_changed<slider_value>(), this, [this](const slider_value&) { t.stop(); t.start(); }); + connect(&s.gain, value_::value_changed<slider_value>(), this, [this](const slider_value&) { t.stop(); t.start(); }); connect(ui.exposure_slider, &QSlider::valueChanged, ui.exposure_label, &QSpinBox::setValue); connect(ui.gain_slider, &QSlider::valueChanged, ui.gain_label, &QSpinBox::setValue); connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &dialog::do_ok); connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &dialog::do_cancel); + connect(&t, &QTimer::timeout, this, [this] { s.set_exposure(); s.set_gain(); }); } // XXX copypasta -sh 20200329 diff --git a/video-ps3eye/module.hpp b/video-ps3eye/module.hpp index 56ffe5df..6dcec66a 100644 --- a/video-ps3eye/module.hpp +++ b/video-ps3eye/module.hpp @@ -10,6 +10,7 @@ #include <QDialog> #include <QProcess> +#include <QTimer> using namespace options; @@ -34,6 +35,7 @@ class dialog final : public QWidget Q_OBJECT Ui_Dialog ui; settings s; + QTimer t{this}; shm_wrapper shm { "ps3eye-driver-shm", nullptr, sizeof(ps3eye::shm) }; @@ -41,7 +43,7 @@ class dialog final : public QWidget void do_cancel() { s.b->reload(); close(); deleteLater(); } protected: - void closeEvent(QCloseEvent*) override { do_cancel(); } + void closeEvent(QCloseEvent*) override { do_cancel(); if (t.isActive()) { s.set_exposure(); s.set_gain(); } } public: explicit dialog(QWidget* parent = nullptr); |