Skip to content

Commit cfeb404

Browse files
authored
Merge pull request #163 from ericogr/aat-improvements
Enhance Automatic Antenna Tracker (AAT) configuration via web interface
2 parents 575681d + 4748d00 commit cfeb404

File tree

6 files changed

+66
-13
lines changed

6 files changed

+66
-13
lines changed

html/scan.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ function updateAatConfig(config)
7373
_('azim_center').value = config.aat.azim_center;
7474
_('azim_min').value = config.aat.azim_min;
7575
_('azim_max').value = config.aat.azim_max;
76+
_('azim_sff').checked = config.aat.azim_sff === 1;
7677
_('elev_min').value = config.aat.elev_min;
7778
_('elev_max').value = config.aat.elev_max;
79+
_('satmin').value = config.aat.satmin;
7880
aatAzimCenterChanged();
7981

8082
// VBAT
@@ -412,6 +414,7 @@ function aatLineElementChanged()
412414
body: new URLSearchParams({
413415
'bear': _('bear').value,
414416
'elev': _('elev').value,
417+
'azim_sff': _('azim_sff').checked ? 1 : 0,
415418
})
416419
});
417420
}

html/vrx_index.html

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ <h2>RTC Update via NTP</h2>
108108
<form action="/aatconfig" id="aatconfig" method="POST" class="mui-form">
109109
<div class="mui-panel">
110110
<fieldset><legend>Servo maximum speed</legend>
111-
Use the slider to limit the maximum rotational speed of the servo. Note that when the azimuth servo
112-
must flip from one side to the other, the servo always will move at full speed.
111+
Use the slider to set a limit on the servo's maximum rotational speed. Note that when the azimuth servo
112+
needs to flip from one side to the other, it may move at full speed if the 'Fast Flip' option is enabled.
113113
<input type="range" id="servosmoo" name="servosmoo" list="servosmoo_markers" value="5" min="0" max="9" step="1" style="width: 100%;"/>
114114
<datalist id="servosmoo_markers">
115115
<option value="0" label="Fast" title="Lickedy Speed"></option>
@@ -138,7 +138,7 @@ <h2>RTC Update via NTP</h2>
138138
</div>
139139
<div class="mui-panel">
140140
<fieldset><legend>Azimuth servo</legend>
141-
Enter the micrsecond (us) values for the min and max position of the horizontal servo, using the slider to test positions.
141+
Enter the microsecond (us) values for the min and max position of the horizontal servo, using the slider to test positions.
142142
<input type="range" id="bear" name="bear" class="aatlive" list="azim_markers" value="0" min="-180" max="180" step="45" style="width: 100%;"/>
143143
<datalist id="bear_markers">
144144
<option value="-180"></option>
@@ -164,9 +164,15 @@ <h2>RTC Update via NTP</h2>
164164
<input id="azim_max" type="number" name="azim_max" min="500" max="2500"/>
165165
<label for="azim_max">Max</label>
166166
</div>
167+
<div class="mui-checkbox mui-col-xs-12">
168+
<label>
169+
<input id="azim_sff" type="checkbox" name="azim_sff" value="1">
170+
Fast Flip (If the azimuth servo needs to move more than 80% of the distance, jump immediately)
171+
</label>
172+
</div>
167173
</fieldset>
168174
<fieldset><legend>Elevation servo</legend>
169-
Enter the micrsecond (us) values for the min and max position of the vertical servo, using the slider to test positions.
175+
Enter the microsecond (us) values for the min and max position of the vertical servo, using the slider to test positions.
170176
<input type="range" id="elev" name="elev" class="aatlive" list="elev_markers" value="45" min="0" max="90" step="15" style="width: 100%;"/>
171177
<datalist id="elev_markers">
172178
<option value="0" label="0"></option>
@@ -192,7 +198,7 @@ <h2>RTC Update via NTP</h2>
192198
</div>
193199
<div class="mui-panel">
194200
<fieldset><legend>Battery voltage</legend>
195-
Battery voltage is calculated using the formula <strong>VBAT = (ADC - offset) / scale</strong>. If voltage is reading too high, increase scale.
201+
<div>Battery voltage is calculated using the formula <strong>VBAT = (ADC - offset) / scale</strong>. If voltage is reading too high, increase scale.</div>
196202
<div class="mui-textfield mui-col-xs-6">
197203
<input id="vbat_scale" type="number" name="vbat_scale" min="1" max="1000"/>
198204
<label for="vbat_scale">Scale</label>
@@ -203,6 +209,25 @@ <h2>RTC Update via NTP</h2>
203209
</div>
204210
</fieldset>
205211
</div>
212+
<div class="mui-panel">
213+
<fieldset>
214+
<legend>Home position settings</legend>
215+
Define the minimum number of satellites required to establish the home position.
216+
<input type="range" id="satmin" name="satmin" list="satmin_markers" min="5" max="21" step="2"
217+
style="width: 100%;" />
218+
<datalist id="satmin_markers">
219+
<option value="5" label="5" title="Less precise"></option>
220+
<option value="7" label="7"></option>
221+
<option value="9" label="9"></option>
222+
<option value="11" label="11"></option>
223+
<option value="13" label="13"></option>
224+
<option value="15" label="15"></option>
225+
<option value="17" label="17"></option>
226+
<option value="19" label="19"></option>
227+
<option value="21" label="21" title="More precise"></option>
228+
</datalist>
229+
</fieldset>
230+
</div>
206231
<input type="hidden" name="commit" value="1"/>
207232
<input type="submit" id="aatsubmit" value="Save" class="mui-btn mui-btn--primary"/>
208233
</form>

lib/config/config.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ VrxBackpackConfig::SetDefaults()
164164
m_config.aat.project = 0xff;
165165
m_config.aat.servoSmooth = 5;
166166
m_config.aat.centerDir = 0; // N
167+
m_config.aat.azimuthServoFastFlip = 1;
167168
m_config.aat.servoEndpoints[0].low = 500; // AZIM
168169
m_config.aat.servoEndpoints[0].high = 2500;
169170
m_config.aat.servoEndpoints[1].low = 1000; // ELEV
@@ -220,6 +221,12 @@ VrxBackpackConfig::SetAatServoSmooth(uint8_t val)
220221
CONFIG_MOD_CHECK(m_config.aat.servoSmooth, val);
221222
}
222223

224+
void
225+
VrxBackpackConfig::SetAatAzimuthServoFastFlip(uint8_t val)
226+
{
227+
CONFIG_MOD_CHECK(m_config.aat.azimuthServoFastFlip, val);
228+
}
229+
223230
void
224231
VrxBackpackConfig::SetAatServoLow(uint8_t idx, uint16_t val)
225232
{
@@ -256,6 +263,12 @@ VrxBackpackConfig::SetAatServoMode(uint8_t val)
256263
CONFIG_MOD_CHECK(m_config.aat.servoMode, val);
257264
}
258265

266+
void
267+
VrxBackpackConfig::SetAatSatelliteHomeMin(uint8_t val)
268+
{
269+
CONFIG_MOD_CHECK(m_config.aat.satelliteHomeMin, val);
270+
}
271+
259272
/**
260273
* @brief: Validate that the endpoints have a valid range, i.e. low/high not the same
261274
*/

lib/config/config.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,14 @@ typedef struct {
8484

8585
#if defined(AAT_BACKPACK)
8686
struct __attribute__((packed)) tagAatConfig {
87-
uint8_t satelliteHomeMin; // minimum number of satellites to establish home
88-
uint8_t servoSmooth; // 0-9 for min smoothing to most smoothing
89-
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)
90-
uint8_t project; // FUTURE: 0=none, 1=projectAzim, 2=projectElev, 3=projectBoth
91-
uint8_t units; // FUTURE: 0=meters, anything else=also meters :-D
92-
uint8_t servoMode; // 0=2:1, 1=clip180, FUTURE: 180+flip servo
93-
// Also maybe invertAzim / invertElev servo bit or just swap low/high
87+
uint8_t satelliteHomeMin; // minimum number of satellites to establish home
88+
uint8_t azimuthServoFastFlip; // 0=off, 1=on
89+
uint8_t servoSmooth; // 0-9 for min smoothing to most smoothing
90+
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)
91+
uint8_t project; // FUTURE: 0=none, 1=projectAzim, 2=projectElev, 3=projectBoth
92+
uint8_t units; // FUTURE: 0=meters, anything else=also meters :-D
93+
uint8_t servoMode; // 0=2:1, 1=clip180, FUTURE: 180+flip servo
94+
// Also maybe invertAzim / invertElev servo bit or just swap low/high
9495
struct __attribute__((packed)) tagServoEndoint {
9596
uint16_t low;
9697
uint16_t high;
@@ -129,6 +130,9 @@ class VrxBackpackConfig
129130

130131
#if defined(AAT_BACKPACK)
131132
uint8_t GetAatSatelliteHomeMin() const { return m_config.aat.satelliteHomeMin; }
133+
void SetAatSatelliteHomeMin(uint8_t val);
134+
uint8_t GetAatAzimuthServoFastFlip() const { return m_config.aat.azimuthServoFastFlip; }
135+
void SetAatAzimuthServoFastFlip(uint8_t val);
132136
uint8_t GetAatServoSmooth() const { return m_config.aat.servoSmooth; }
133137
void SetAatServoSmooth(uint8_t val);
134138
uint8_t GetAatServoMode() const { return m_config.aat.servoMode; }

src/devwifi_proxy_aat.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ void WebAatAppendConfig(ArduinoJson::JsonDocument &json)
77
{
88
auto aat = json["config"].createNestedObject("aat");
99
aat["satmin"] = config.GetAatSatelliteHomeMin();
10+
aat["azim_sff"] = config.GetAatAzimuthServoFastFlip();
1011
aat["servosmoo"] = config.GetAatServoSmooth();
1112
aat["servomode"] = config.GetAatServoMode();
1213
aat["project"] = config.GetAatProject();
@@ -28,6 +29,10 @@ void WebAatConfig(AsyncWebServerRequest *request)
2829
// Servos
2930
if (request->hasArg("servosmoo"))
3031
config.SetAatServoSmooth(request->arg("servosmoo").toInt());
32+
if (request->hasArg("azim_sff"))
33+
config.SetAatAzimuthServoFastFlip(request->arg("azim_sff").toInt());
34+
else
35+
config.SetAatAzimuthServoFastFlip(0);
3136
if (request->hasArg("servomode"))
3237
config.SetAatServoMode(request->arg("servomode").toInt());
3338
if (request->hasArg("azim_center"))
@@ -50,6 +55,9 @@ void WebAatConfig(AsyncWebServerRequest *request)
5055
vrxModule.overrideTargetBearing(request->arg("bear").toInt());
5156
if (request->hasArg("elev"))
5257
vrxModule.overrideTargetElev(request->arg("elev").toInt());
58+
// Satellite Config
59+
if (request->hasArg("satmin"))
60+
config.SetAatSatelliteHomeMin(request->arg("satmin").toInt());
5361

5462
const char *response;
5563
if (request->arg("commit").toInt() == 1)

src/module_aat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ void AatModule::servoUpdate(uint32_t now)
578578
int32_t maxDiff = (10 - config.GetAatServoSmooth()) * SMOOTHNESS_US_PER_STEP;
579579
// If the distance the servo needs to go is more than 80% away
580580
// jump immediately. otherwise smooth it
581-
if (idx == IDX_AZIM && (abs(diff) * 100 / range) > 80)
581+
if (config.GetAatAzimuthServoFastFlip() && idx == IDX_AZIM && (abs(diff) * 100 / range) > 80)
582582
{
583583
// Prevent the servo from flipping back and forth around the 180 point
584584
// by only allowing 1 flip ever Xms. Just keep pushing toward the limit

0 commit comments

Comments
 (0)