diff --git a/firmware/src/src/basetrackersettings.h b/firmware/src/src/basetrackersettings.h index f950b553..223a4297 100644 --- a/firmware/src/src/basetrackersettings.h +++ b/firmware/src/src/basetrackersettings.h @@ -773,6 +773,16 @@ class BaseTrackerSettings { inline const bool& getRstOnTlt() {return rstontlt;} void setRstOnTlt(bool val=false) { rstontlt = val; } + // Delay to Reset in Seconds + inline const float& getRstDelay() {return rstdelay;} + bool setRstDelay(float val=0) { + if(val >= 0 && val <= 1) { + rstdelay = val; + return true; + } + return false; + } + // Reset on a double tap inline const bool& getRstOnDbltTap() {return rstondblttap;} void setRstOnDbltTap(bool val=false) { rstondblttap = val; } @@ -1056,6 +1066,7 @@ class BaseTrackerSettings { json["rstonwave"] = rstonwave; json["butlngps"] = butlngps; json["rstontlt"] = rstontlt; + json["rstdelay"] = rstdelay; json["rstondblttap"] = rstondblttap; json["rstondbltapthres"] = rstondbltapthres; json["rstondbltapmin"] = rstondbltapmin; @@ -1144,6 +1155,7 @@ class BaseTrackerSettings { v = json["rstonwave"]; if(!v.isNull()) {setRstOnWave(v);} v = json["butlngps"]; if(!v.isNull()) {setButLngPs(v);} v = json["rstontlt"]; if(!v.isNull()) {setRstOnTlt(v);} + v = json["rstdelay"]; if(!v.isNull()) {setRstDelay(v);} v = json["rstondblttap"]; if(!v.isNull()) {setRstOnDbltTap(v);} v = json["rstondbltapthres"]; if(!v.isNull()) {setRstOnDblTapThres(v);} v = json["rstondbltapmin"]; if(!v.isNull()) {setRstOnDblTapMin(v);} @@ -1556,6 +1568,7 @@ class BaseTrackerSettings { bool rstonwave = false; // Reset on Proximity Sense bool butlngps = false; // Long Press on the Button to Enable/Disable Tilt Roll and Pan bool rstontlt = false; // Reset Center on a Head Tilt + float rstdelay = 0; // Delay to Reset in Seconds bool rstondblttap = false; // Reset on a double tap float rstondbltapthres = 80; // Double Tap Threshold float rstondbltapmin = 100; // Double Tap Min Time diff --git a/firmware/src/src/io.cpp b/firmware/src/src/io.cpp index 12ccc52c..51b521c6 100644 --- a/firmware/src/src/io.cpp +++ b/firmware/src/src/io.cpp @@ -18,6 +18,8 @@ #include "soc_flash.h" #include "trackersettings.h" +void rstTimerFunc(struct k_timer *timer_id); +K_TIMER_DEFINE(rstCenterTimer, rstTimerFunc, NULL); #if defined(CONFIG_SOC_SERIES_NRF52X) // TODO: Find how to do this in new version of Zephyr @@ -181,8 +183,16 @@ bool wasButtonLongPressed() return true; } -// Reset Center -void pressButton() { k_sem_give(&button_sem); } +// Called after the reset center delay. +void rstTimerFunc(struct k_timer *timer_id) { + k_sem_give(&button_sem); +} + +// Call reset center after delay +void pressButton() { + /* start a periodic timer that expires once every second */ + k_timer_start(&rstCenterTimer, K_MSEC(static_cast(trkset.getRstDelay()*1000.0f)), K_NO_WAIT); +} void longPressButton() { k_sem_give(&lngbutton_sem); } diff --git a/gui/src/basetrackersettings.h b/gui/src/basetrackersettings.h index d5d128f0..44617a21 100644 --- a/gui/src/basetrackersettings.h +++ b/gui/src/basetrackersettings.h @@ -148,6 +148,7 @@ class BaseTrackerSettings : public QObject _setting["rstonwave"] = false; _setting["butlngps"] = false; _setting["rstontlt"] = false; + _setting["rstdelay"] = 0; _setting["rstondblttap"] = false; _setting["rstondbltapthres"] = 80; _setting["rstondbltapmin"] = 100; @@ -262,6 +263,7 @@ class BaseTrackerSettings : public QObject descriptions["rstonwave"] = tr("Reset on Proximity Sense"); descriptions["butlngps"] = tr("Long Press on the Button to Enable/Disable Tilt Roll and Pan"); descriptions["rstontlt"] = tr("Reset Center on a Head Tilt"); + descriptions["rstdelay"] = tr("Delay to Reset in Seconds"); descriptions["rstondblttap"] = tr("Reset on a double tap"); descriptions["rstondbltapthres"] = tr("Double Tap Threshold"); descriptions["rstondbltapmin"] = tr("Double Tap Min Time"); @@ -1164,6 +1166,19 @@ class BaseTrackerSettings : public QObject bool getRstOnTlt() {return _setting["rstontlt"].toBool();} void setRstOnTlt(bool val=false) { _setting["rstontlt"] = val; } + // Delay to Reset in Seconds + float getRstDelay() { + return _setting["rstdelay"].toFloat(); + } + bool setRstDelay(float val=0) { + if(val >= 0 && val <= 1) { + _setting["rstdelay"] = QString::number(val,'g',4); + return true; + } + return false; + } + + // Reset on a double tap bool getRstOnDbltTap() {return _setting["rstondblttap"].toBool();} void setRstOnDbltTap(bool val=false) { _setting["rstondblttap"] = val; } diff --git a/gui/src/mainwindow.cpp b/gui/src/mainwindow.cpp index 85bb24a4..2c6aee49 100644 --- a/gui/src/mainwindow.cpp +++ b/gui/src/mainwindow.cpp @@ -137,6 +137,7 @@ MainWindow::MainWindow(QWidget *parent) connect(ui->spnRstDblTapMax, &QSpinBox::valueChanged, this, &MainWindow::updateFromUI); connect(ui->spnRstDblTapMin, &QSpinBox::valueChanged, this, &MainWindow::updateFromUI); connect(ui->spnRstDblTapThres, &QSpinBox::valueChanged, this, &MainWindow::updateFromUI); + connect(ui->spnResetDelay, &QDoubleSpinBox::valueChanged, this, &MainWindow::updateFromUI); // Gain Sliders connect(ui->til_gain, &GainSlider::valueChanged, this, &MainWindow::updateFromUI); @@ -574,6 +575,9 @@ void MainWindow::updateToUI() ui->spnA3Gain->setValue(trkset.getAn3Gain()); ui->spnA3Off->setValue(trkset.getAn3Off()); + // Reset Delay + ui->spnResetDelay->setValue(trkset.getRstDelay()); + ui->spnSBUSRate->setValue(trkset.getSbusTxRate()); ui->spnCRSFRate->setValue(trkset.getCrsfTxRate()); @@ -792,6 +796,9 @@ void MainWindow::updateFromUI() ui->spnRstDblTapThres->setEnabled(false); } + // Reset Delay + trkset.setRstDelay(ui->spnResetDelay->value()); + trkset.setSbOutInv(ui->chkSbusOutInv->isChecked()); trkset.setSbusTxRate(ui->spnSBUSRate->value()); trkset.setCrsfTxRate(ui->spnCRSFRate->value()); diff --git a/gui/src/mainwindow.ui b/gui/src/mainwindow.ui index 1d344dfd..a4de28a0 100644 --- a/gui/src/mainwindow.ui +++ b/gui/src/mainwindow.ui @@ -336,14 +336,14 @@ false - 3 + 0 General - + @@ -356,125 +356,34 @@ - - - - - 10 - true - - - - NO CENTER BUTTON DEFINED - - - - - - - - 0 - 0 - - - - Send Recenter on Chan - - - - - - - <html><head/><body><p>When center is pressed this will pulse this channel. Used to notify your radio when centered.</p></body></html> - - - - Off - - - - - 1 - - - - - 2 - - - - - 3 - - - - - 4 - - - - - 5 - - - - - 6 - - - - - 7 - - - - - 8 - - - - - 9 - - - - - 10 - - - - - 11 - - - - - 12 - - + + - - 13 - - - - - 14 - - - - - 15 - + + + Reset Delay + + - - 16 - + + + <html><head/><body><p>How long after a reset event to center.</p></body></html> + + + sec + + + 1.000000000000000 + + + 0.100000000000000 + + - + - + <html><head/><body><p>This function allows you to enable the tilt/roll/pan outputs after a long press of the reset button. Another long press will disable the output. <span style=" font-weight:700;">Note</span>: Output is disabled on startup with this enabled</p></body></html> @@ -484,7 +393,7 @@ - + <html><head/><body><p>Allows you to recenter using roll output. Set your gain on roll below so that you can hit the minimum and maximum easily. When you roll back and forth from min to maxium will cause a Reset Center after a delay</p></body></html> @@ -494,7 +403,7 @@ - + <html><head/><body><p>Sets the output channel you want tilt on</p></body></html> @@ -504,14 +413,97 @@ - + Reset on double tap - + + + + + + m/s^3 + + + 50 + + + 200 + + + + + + + ms + + + 50 + + + 1000 + + + 400 + + + + + + + Threshold + + + + + + + Min Time + + + + + + + ms + + + 50 + + + 400 + + + 100 + + + + + + + Max Time + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + Board Rotation @@ -602,20 +594,7 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - - + @@ -652,75 +631,123 @@ - - - - - - Threshold - - + + + + + 10 + true + + + + NO CENTER BUTTON DEFINED + + + + + + + + 0 + 0 + + + + Send Recenter on Chan + + + + + + + <html><head/><body><p>When center is pressed this will pulse this channel. Used to notify your radio when centered.</p></body></html> + + + + Off + - - - - Min Time - - + + + 1 + - - - - Max Time - - + + + 2 + - - - - m/s^3 - - - 50 - - - 200 - - + + + 3 + - - - - ms - - - 50 - - - 400 - - - 100 - - + + + 4 + - - - - ms - - - 50 - - - 1000 - - - 400 - - + + + 5 + - + + + 6 + + + + + 7 + + + + + 8 + + + + + 9 + + + + + 10 + + + + + 11 + + + + + 12 + + + + + 13 + + + + + 14 + + + + + 15 + + + + + 16 + + + diff --git a/settings/settings.csv b/settings/settings.csv index 07587880..de10d02a 100644 --- a/settings/settings.csv +++ b/settings/settings.csv @@ -175,6 +175,8 @@ Other Features,,,,,,,,,, bool,Setting,RstOnWave,FALSE,,,Reset on Proximity Sense,,,, bool,Setting,ButLngPs,FALSE,,,Long Press on the Button to Enable/Disable Tilt Roll and Pan,,,, bool,Setting,RstOnTlt,FALSE,,,Reset Center on a Head Tilt,,,, +float,Setting,RstDelay,0,0,1,Delay to Reset in Seconds,,,4, +,,,,,,,,,, Reset On Double Tap,,,,,,,,,, bool,Setting,RstOnDbltTap,FALSE,,,Reset on a double tap,,,, float,Setting,RstOnDblTapThres,80,50,200,Double Tap Threshold,,,4,