Skip to content

Commit 4c53172

Browse files
committed
Change to shutdownNoChargeTimeoutMinutes
Make work over web config
1 parent de621fd commit 4c53172

File tree

6 files changed

+43
-26
lines changed

6 files changed

+43
-26
lines changed

Firmware/RTK_Everywhere/AP-Config/index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,28 +2200,28 @@
22002200
</div>
22012201
</div>
22022202

2203-
<div id="shutdownNoChargeTimeoutCheckbox">
2203+
<div id="shutdownNoChargeTimeoutMinutesCheckboxDetail">
22042204
<div class="form-check mt-3">
2205-
<label class="form-check-label" for="shutdownNoChargeTimeout">Shutdown if not charging:</label>
2206-
<input class="form-check-input" type="checkbox" value="" id="shutdownNoChargeTimeout">
2205+
<label class="form-check-label" for="shutdownNoChargeTimeoutMinutes">Shutdown if not charging:</label>
2206+
<input class="form-check-input" type="checkbox" value="" id="shutdownNoChargeTimeoutMinutesCheckbox">
22072207
<span class="tt" data-bs-placement="right"
22082208
title="If enabled, device will turn off if no external charger is present. This is helpful when deploying in machinery or where a user may forget to turn the device off. Default: Disabled">
22092209
<span class="icon-info-circle text-primary ms-2"></span>
22102210
</span>
22112211
</div>
22122212
</div>
22132213

2214-
<div id="shutdownNoChargeTimeoutDetails" class="collapse mb-2">
2214+
<div id="shutdownNoChargeTimeoutMinutesDetails" class="collapse mb-2">
22152215
<div class="form-group row">
2216-
<label for="rebootMinutes" class="box-margin40 col-sm-3 col-7 col-form-label">Seconds before
2216+
<label for="shutdownNoChargeTimeoutMinutes" class="box-margin40 col-sm-3 col-7 col-form-label">Minutes before
22172217
shutdown:
22182218
<span class="tt" data-bs-placement="right"
2219-
title="If shutdown is enabled, the device will turn off after this many seconds if no external charger is detected. Limits: 0 (disabled) to 604800.">
2219+
title="If shutdown is enabled, the device will turn off after this many minutes if no external charger is detected. Limits: 0 (disabled) to 10,080.">
22202220
<span class="icon-info-circle text-primary ms-2"></span>
22212221
</span>
22222222
</label>
2223-
<input type="number" class="form-control box-small" id="rebootMinutes">
2224-
<p id="rebootMinutesError" class="inlineError"></p>
2223+
<input type="number" class="form-control box-small" id="shutdownNoChargeTimeoutMinutes">
2224+
<p id="shutdownNoChargeTimeoutMinutesError" class="inlineError"></p>
22252225
</div>
22262226
</div>
22272227

Firmware/RTK_Everywhere/AP-Config/src/main.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function parseIncoming(msg) {
121121
show("useLocalizedDistributionCheckbox");
122122
show("useEnableExtCorrRadio");
123123
show("extCorrRadioSPARTNSourceDropdown");
124-
hide("shutdownNoChargeTimeoutCheckbox");
124+
hide("shutdownNoChargeTimeoutMinutesCheckboxDetail");
125125

126126
hide("constellationNavic"); //Not supported on ZED
127127
}
@@ -512,6 +512,18 @@ function parseIncoming(msg) {
512512
hide("enableAutomaticResetDetails");
513513
}
514514
}
515+
else if (id.includes("shutdownNoChargeTimeoutMinutes")) {
516+
if (val > 0) {
517+
ge("shutdownNoChargeTimeoutMinutes").value = val;
518+
ge("shutdownNoChargeTimeoutMinutesCheckbox").checked = true;
519+
show("shutdownNoChargeTimeoutMinutesDetails");
520+
}
521+
else {
522+
ge("shutdownNoChargeTimeoutMinutes").value = 0;
523+
ge("shutdownNoChargeTimeoutMinutesCheckbox").checked = false;
524+
hide("shutdownNoChargeTimeoutMinutesDetails");
525+
}
526+
}
515527

516528
//Convert incoming mm to local meters
517529
else if (id.includes("antennaHeight_mm")) {
@@ -960,12 +972,18 @@ function validateFields() {
960972
}
961973

962974
if (ge("enableAutoReset").checked == true) {
963-
checkElementValue("rebootMinutes", 1, 4294967, "Must be 1 to 4294967", "collapseSystemConfig");
975+
checkElementValue("rebootMinutes", 0, 4294967, "Must be 0 to 4,294,967", "collapseSystemConfig");
964976
}
965977
else {
966978
clearElement("rebootMinutes", 0); //0 = disable
967979
}
968980

981+
if (ge("shutdownNoChargeTimeoutMinutesCheckbox").checked == true) {
982+
checkElementValue("shutdownNoChargeTimeoutMinutes", 0, 604800, "Must be 0 to 604,800", "collapseSystemConfig");
983+
}
984+
else {
985+
clearElement("shutdownNoChargeTimeoutMinutes", 0); //0 = disable
986+
}
969987

970988
//Ethernet
971989
if (platformPrefix == "EVK") {
@@ -1737,12 +1755,12 @@ document.addEventListener("DOMContentLoaded", (event) => {
17371755
}
17381756
});
17391757

1740-
ge("shutdownNoChargeTimeout").addEventListener("change", function () {
1741-
if (ge("shutdownNoChargeTimeout").checked == true) {
1742-
show("shutdownNoChargeTimeoutDetails");
1758+
ge("shutdownNoChargeTimeoutMinutesCheckbox").addEventListener("change", function () {
1759+
if (ge("shutdownNoChargeTimeoutMinutesCheckbox").checked == true) {
1760+
show("shutdownNoChargeTimeoutMinutesDetails");
17431761
}
17441762
else {
1745-
hide("shutdownNoChargeTimeoutDetails");
1763+
hide("shutdownNoChargeTimeoutMinutesDetails");
17461764
}
17471765
});
17481766

Firmware/RTK_Everywhere/Network.ino

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,12 +1645,11 @@ uint8_t networkConsumers(uint16_t *consumerTypes)
16451645
*consumerTypes |= (1 << NETCONSUMER_WIFI_AP); // WebConfig requires both AP and STA (for firmware check)
16461646

16471647
// A good number of RTK products have only WiFi
1648-
// If WiFi STA has failed, fall back to WiFi AP, but allow STA to keep hunting
1648+
// If WiFi STA has failed or we have no WiFi SSIDs, fall back to WiFi AP, but allow STA to keep hunting
16491649
if (networkIsPresent(NETWORK_ETHERNET) == false && networkIsPresent(NETWORK_CELLULAR) == false &&
1650-
settings.wifiConfigOverAP == false && wifiGetStartTimeout() > 0)
1650+
settings.wifiConfigOverAP == false && (wifiGetStartTimeout() > 0 || wifiNetworkCount() == 0))
16511651
{
16521652
*consumerTypes |= (1 << NETCONSUMER_WIFI_AP); // Re-allow Webconfig over AP
1653-
wifiResetTimeout(); // Force immediate switch to AP mode
16541653
}
16551654
}
16561655

Firmware/RTK_Everywhere/System.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,12 @@ void updateBattery()
162162
}
163163

164164
// Check if we need to shutdown due to no charging
165-
if (settings.shutdownNoChargeTimeout_s > 0)
165+
if (settings.shutdownNoChargeTimeoutMinutes > 0)
166166
{
167167
if (isCharging() == false)
168168
{
169-
int secondsSinceLastCharger = (millis() - shutdownNoChargeTimer) / 1000;
170-
if (secondsSinceLastCharger > settings.shutdownNoChargeTimeout_s)
169+
int minutesSinceLastCharge = ((millis() - shutdownNoChargeTimer) / 1000) / 60;
170+
if (minutesSinceLastCharge > settings.shutdownNoChargeTimeoutMinutes)
171171
powerDown(true);
172172
}
173173
else

Firmware/RTK_Everywhere/menuSystem.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,10 @@ void menuSystem()
200200

201201
if (present.fuelgauge_max17048 || present.fuelgauge_bq40z50 || present.charger_mp2762a)
202202
{
203-
if (settings.shutdownNoChargeTimeout_s == 0)
203+
if (settings.shutdownNoChargeTimeoutMinutes == 0)
204204
systemPrintln("c) Shutdown if not charging: Disabled");
205205
else
206-
systemPrintf("c) Shutdown if not charging after: %d seconds\r\n", settings.shutdownNoChargeTimeout_s);
206+
systemPrintf("c) Shutdown if not charging after: %d minutes\r\n", settings.shutdownNoChargeTimeoutMinutes);
207207
}
208208

209209
systemPrintln("d) Debug software");
@@ -299,8 +299,8 @@ void menuSystem()
299299
else if ((incoming == 'c') &&
300300
(present.fuelgauge_max17048 || present.fuelgauge_bq40z50 || present.charger_mp2762a))
301301
{
302-
getNewSetting("Enter time in seconds to shutdown unit if not charging (0 to disable)", 0, 60 * 60 * 24 * 7,
303-
&settings.shutdownNoChargeTimeout_s); // Arbitrary 7 day limit
302+
getNewSetting("Enter time in minutes to shutdown unit if not charging (0 to disable)", 0, 60 * 24 * 7,
303+
&settings.shutdownNoChargeTimeoutMinutes); // Arbitrary 7 day limit
304304
}
305305
else if (incoming == 'd')
306306
menuDebugSoftware();

Firmware/RTK_Everywhere/settings.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ struct Settings
594594

595595
// Battery
596596
bool enablePrintBatteryMessages = true;
597-
uint32_t shutdownNoChargeTimeout_s = 0; // If > 0, shut down unit after timeout if not charging
597+
uint32_t shutdownNoChargeTimeoutMinutes = 0; // If > 0, shut down unit after timeout if not charging
598598

599599
// Beeper
600600
bool enableBeeper = true; // Some platforms have an audible notification
@@ -1136,7 +1136,7 @@ const RTK_Settings_Entry rtkSettingsEntries[] =
11361136

11371137
// Battery
11381138
{ 0, 0, 0, 0, 1, 1, 1, 1, 1, _bool, 0, & settings.enablePrintBatteryMessages, "enablePrintBatteryMessages", },
1139-
{ 1, 1, 0, 0, 1, 1, 1, 1, 1, _uint32_t, 0, & settings.shutdownNoChargeTimeout_s, "shutdownNoChargeTimeout", },
1139+
{ 1, 1, 0, 0, 1, 1, 1, 1, 1, _uint32_t, 0, & settings.shutdownNoChargeTimeoutMinutes, "shutdownNoChargeTimeoutMinutes", },
11401140

11411141
// F
11421142
// a

0 commit comments

Comments
 (0)