From 4748d007d3044b877576030e7c068e8acc2470e7 Mon Sep 17 00:00:00 2001 From: EricoGR Date: Mon, 23 Sep 2024 21:37:58 -0300 Subject: [PATCH] Enhance AAT configuration via web interface: * Added optional support for fast flip of the azimuth servo * Added configuration of the minimum number of satellites for the home position --- html/scan.js | 3 +++ html/vrx_index.html | 35 ++++++++++++++++++++++++++++++----- lib/config/config.cpp | 13 +++++++++++++ lib/config/config.h | 18 +++++++++++------- src/devwifi_proxy_aat.cpp | 8 ++++++++ src/module_aat.cpp | 2 +- 6 files changed, 66 insertions(+), 13 deletions(-) diff --git a/html/scan.js b/html/scan.js index ed6c9d41..59277d7c 100644 --- a/html/scan.js +++ b/html/scan.js @@ -73,8 +73,10 @@ function updateAatConfig(config) _('azim_center').value = config.aat.azim_center; _('azim_min').value = config.aat.azim_min; _('azim_max').value = config.aat.azim_max; + _('azim_sff').checked = config.aat.azim_sff === 1; _('elev_min').value = config.aat.elev_min; _('elev_max').value = config.aat.elev_max; + _('satmin').value = config.aat.satmin; aatAzimCenterChanged(); // VBAT @@ -412,6 +414,7 @@ function aatLineElementChanged() body: new URLSearchParams({ 'bear': _('bear').value, 'elev': _('elev').value, + 'azim_sff': _('azim_sff').checked ? 1 : 0, }) }); } diff --git a/html/vrx_index.html b/html/vrx_index.html index b8da64ff..8ac22996 100644 --- a/html/vrx_index.html +++ b/html/vrx_index.html @@ -108,8 +108,8 @@

RTC Update via NTP

Servo maximum speed - Use the slider to limit the maximum rotational speed of the servo. Note that when the azimuth servo - must flip from one side to the other, the servo always will move at full speed. + Use the slider to set a limit on the servo's maximum rotational speed. Note that when the azimuth servo + needs to flip from one side to the other, it may move at full speed if the 'Fast Flip' option is enabled. @@ -138,7 +138,7 @@

RTC Update via NTP

Azimuth servo - Enter the micrsecond (us) values for the min and max position of the horizontal servo, using the slider to test positions. + Enter the microsecond (us) values for the min and max position of the horizontal servo, using the slider to test positions. @@ -164,9 +164,15 @@

RTC Update via NTP

+
+ +
Elevation servo - Enter the micrsecond (us) values for the min and max position of the vertical servo, using the slider to test positions. + Enter the microsecond (us) values for the min and max position of the vertical servo, using the slider to test positions. @@ -192,7 +198,7 @@

RTC Update via NTP

Battery voltage - Battery voltage is calculated using the formula VBAT = (ADC - offset) / scale. If voltage is reading too high, increase scale. +
Battery voltage is calculated using the formula VBAT = (ADC - offset) / scale. If voltage is reading too high, increase scale.
@@ -203,6 +209,25 @@

RTC Update via NTP

+
+
+ Home position settings + Define the minimum number of satellites required to establish the home position. + + + + + + + + + + + + +
+
diff --git a/lib/config/config.cpp b/lib/config/config.cpp index cfd82f68..37cbfd5e 100644 --- a/lib/config/config.cpp +++ b/lib/config/config.cpp @@ -164,6 +164,7 @@ VrxBackpackConfig::SetDefaults() m_config.aat.project = 0xff; m_config.aat.servoSmooth = 5; m_config.aat.centerDir = 0; // N + m_config.aat.azimuthServoFastFlip = 1; m_config.aat.servoEndpoints[0].low = 500; // AZIM m_config.aat.servoEndpoints[0].high = 2500; m_config.aat.servoEndpoints[1].low = 1000; // ELEV @@ -220,6 +221,12 @@ VrxBackpackConfig::SetAatServoSmooth(uint8_t val) CONFIG_MOD_CHECK(m_config.aat.servoSmooth, val); } +void +VrxBackpackConfig::SetAatAzimuthServoFastFlip(uint8_t val) +{ + CONFIG_MOD_CHECK(m_config.aat.azimuthServoFastFlip, val); +} + void VrxBackpackConfig::SetAatServoLow(uint8_t idx, uint16_t val) { @@ -256,6 +263,12 @@ VrxBackpackConfig::SetAatServoMode(uint8_t val) CONFIG_MOD_CHECK(m_config.aat.servoMode, val); } +void +VrxBackpackConfig::SetAatSatelliteHomeMin(uint8_t val) +{ + CONFIG_MOD_CHECK(m_config.aat.satelliteHomeMin, val); +} + /** * @brief: Validate that the endpoints have a valid range, i.e. low/high not the same */ diff --git a/lib/config/config.h b/lib/config/config.h index 2f2e29ba..91b1710b 100644 --- a/lib/config/config.h +++ b/lib/config/config.h @@ -84,13 +84,14 @@ typedef struct { #if defined(AAT_BACKPACK) struct __attribute__((packed)) tagAatConfig { - uint8_t satelliteHomeMin; // minimum number of satellites to establish home - uint8_t servoSmooth; // 0-9 for min smoothing to most smoothing - uint8_t centerDir; // Direction servo points at center position 0=N 2=E 4=S 6=W (can hold 45 degrees but only 90 is supported) - uint8_t project; // FUTURE: 0=none, 1=projectAzim, 2=projectElev, 3=projectBoth - uint8_t units; // FUTURE: 0=meters, anything else=also meters :-D - uint8_t servoMode; // 0=2:1, 1=clip180, FUTURE: 180+flip servo - // Also maybe invertAzim / invertElev servo bit or just swap low/high + uint8_t satelliteHomeMin; // minimum number of satellites to establish home + uint8_t azimuthServoFastFlip; // 0=off, 1=on + uint8_t servoSmooth; // 0-9 for min smoothing to most smoothing + uint8_t centerDir; // Direction servo points at center position 0=N 2=E 4=S 6=W (can hold 45 degrees but only 90 is supported) + uint8_t project; // FUTURE: 0=none, 1=projectAzim, 2=projectElev, 3=projectBoth + uint8_t units; // FUTURE: 0=meters, anything else=also meters :-D + uint8_t servoMode; // 0=2:1, 1=clip180, FUTURE: 180+flip servo + // Also maybe invertAzim / invertElev servo bit or just swap low/high struct __attribute__((packed)) tagServoEndoint { uint16_t low; uint16_t high; @@ -129,6 +130,9 @@ class VrxBackpackConfig #if defined(AAT_BACKPACK) uint8_t GetAatSatelliteHomeMin() const { return m_config.aat.satelliteHomeMin; } + void SetAatSatelliteHomeMin(uint8_t val); + uint8_t GetAatAzimuthServoFastFlip() const { return m_config.aat.azimuthServoFastFlip; } + void SetAatAzimuthServoFastFlip(uint8_t val); uint8_t GetAatServoSmooth() const { return m_config.aat.servoSmooth; } void SetAatServoSmooth(uint8_t val); uint8_t GetAatServoMode() const { return m_config.aat.servoMode; } diff --git a/src/devwifi_proxy_aat.cpp b/src/devwifi_proxy_aat.cpp index 37c7e3a9..f10bdc00 100644 --- a/src/devwifi_proxy_aat.cpp +++ b/src/devwifi_proxy_aat.cpp @@ -7,6 +7,7 @@ void WebAatAppendConfig(ArduinoJson::JsonDocument &json) { auto aat = json["config"].createNestedObject("aat"); aat["satmin"] = config.GetAatSatelliteHomeMin(); + aat["azim_sff"] = config.GetAatAzimuthServoFastFlip(); aat["servosmoo"] = config.GetAatServoSmooth(); aat["servomode"] = config.GetAatServoMode(); aat["project"] = config.GetAatProject(); @@ -28,6 +29,10 @@ void WebAatConfig(AsyncWebServerRequest *request) // Servos if (request->hasArg("servosmoo")) config.SetAatServoSmooth(request->arg("servosmoo").toInt()); + if (request->hasArg("azim_sff")) + config.SetAatAzimuthServoFastFlip(request->arg("azim_sff").toInt()); + else + config.SetAatAzimuthServoFastFlip(0); if (request->hasArg("servomode")) config.SetAatServoMode(request->arg("servomode").toInt()); if (request->hasArg("azim_center")) @@ -50,6 +55,9 @@ void WebAatConfig(AsyncWebServerRequest *request) vrxModule.overrideTargetBearing(request->arg("bear").toInt()); if (request->hasArg("elev")) vrxModule.overrideTargetElev(request->arg("elev").toInt()); + // Satellite Config + if (request->hasArg("satmin")) + config.SetAatSatelliteHomeMin(request->arg("satmin").toInt()); const char *response; if (request->arg("commit").toInt() == 1) diff --git a/src/module_aat.cpp b/src/module_aat.cpp index 912fa906..8970e521 100644 --- a/src/module_aat.cpp +++ b/src/module_aat.cpp @@ -578,7 +578,7 @@ void AatModule::servoUpdate(uint32_t now) int32_t maxDiff = (10 - config.GetAatServoSmooth()) * SMOOTHNESS_US_PER_STEP; // If the distance the servo needs to go is more than 80% away // jump immediately. otherwise smooth it - if (idx == IDX_AZIM && (abs(diff) * 100 / range) > 80) + if (config.GetAatAzimuthServoFastFlip() && idx == IDX_AZIM && (abs(diff) * 100 / range) > 80) { // Prevent the servo from flipping back and forth around the 180 point // by only allowing 1 flip ever Xms. Just keep pushing toward the limit