GPS enable/disable from WWW

pull/22/head
Rysiek Labus 2021-03-08 18:55:52 +01:00
parent ba7c08a9d0
commit b96ce7fdab
5 changed files with 24 additions and 6 deletions

Binary file not shown.

View File

@ -67,6 +67,10 @@
<input class="u-full-width" type="text" minlength="1" maxlength="1" name="aprs_symbol"
id="aprs_symbol">
</div>
<div>
<label for="aprs_alt">Show Altitude</label>
<input name="aprs_alt" id="aprs_alt" type="checkbox" value="1">
</div>
<div>
<label for="aprs_comment">Comment</label>
<input class="u-full-width" type="text" minlength="0" maxlength="64" name="aprs_comment"
@ -76,10 +80,6 @@
<label for="aprs_batt">Show Battery</label>
<input name="aprs_batt" id="aprs_batt" type="checkbox" value="1">
</div>
<div>
<label for="aprs_alt">Show Altitude</label>
<input name="aprs_alt" id="aprs_alt" type="checkbox" value="1">
</div>
</div>
<div class="grid-container quarters">
<div>
@ -99,6 +99,12 @@
<input class="u-full-width" type="text" minlength="0" name="aprs_lon_p" id="aprs_lon_p">
</div>
</div>
<div class="grid-container quarters">
<div>
<label for="gps_enabled">GPS enabled</label>
<input name="gps_enabled" id="gps_enabled" type="checkbox" value="1">
</div>
</div>
<div class="grid-container full">
<div>
<input class="button-primary u-full-width" type="submit" value="Save">

View File

@ -35,6 +35,8 @@ static const char *const PREF_APRS_FIXED_BEACON_PRESET = "aprs_fixed_beac";
static const char *const PREF_APRS_FIXED_BEACON_PRESET_INIT = "aprs_fix_b_init";
static const char *const PREF_APRS_FIXED_BEACON_INTERVAL_PRESET = "aprs_fb_interv";
static const char *const PREF_APRS_FIXED_BEACON_INTERVAL_PRESET_INIT = "aprs_fb_in_init";
static const char *const PREF_APRS_GPS_EN = "gps_enabled";
static const char *const PREF_APRS_GPS_EN_INIT = "gps_state_init";
typedef struct {
String callsign;

View File

@ -428,6 +428,12 @@ void setup(){
}
showAltitude = preferences.getBool(PREF_APRS_SHOW_ALTITUDE);
if (!preferences.getBool(PREF_APRS_GPS_EN_INIT)){
preferences.putBool(PREF_APRS_GPS_EN_INIT, true);
preferences.putBool(PREF_APRS_GPS_EN, gps_state);
}
gps_state = preferences.getBool(PREF_APRS_GPS_EN);
if (!preferences.getBool(PREF_APRS_SHOW_BATTERY_INIT)){
preferences.putBool(PREF_APRS_SHOW_BATTERY_INIT, true);
preferences.putBool(PREF_APRS_SHOW_BATTERY, showBattery);
@ -607,6 +613,8 @@ void loop() {
#endif
writedisplaytext("((GPSOFF))","","","","","");
next_fixed_beacon = millis() + fix_beacon_interval;
preferences.putBool(PREF_APRS_GPS_EN_INIT, false);
preferences.putBool(PREF_APRS_GPS_EN, false);
}else{
gps_state = true;
@ -614,6 +622,8 @@ void loop() {
axp.setPowerOutPut(AXP192_LDO3, AXP202_ON);
#endif
writedisplaytext("((GPS ON))","","","","",""); // GPS ON
preferences.putBool(PREF_APRS_GPS_EN_INIT, true);
preferences.putBool(PREF_APRS_GPS_EN, true);
}
}

View File

@ -118,6 +118,7 @@ void handle_Cfg() {
jsonData += jsonLineFromPreferenceBool(PREF_APRS_SHOW_BATTERY);
jsonData += jsonLineFromPreferenceBool(PREF_APRS_FIXED_BEACON_PRESET);
jsonData += jsonLineFromPreferenceBool(PREF_APRS_SHOW_ALTITUDE);
jsonData += jsonLineFromPreferenceBool(PREF_APRS_GPS_EN);
jsonData += jsonLineFromString("FreeHeap", String(ESP.getFreeHeap()).c_str());
jsonData += jsonLineFromString("HeapSize", String(ESP.getHeapSize()).c_str());
jsonData += jsonLineFromString("FreeSketchSpace", String(ESP.getFreeSketchSpace()).c_str(), true);
@ -154,8 +155,7 @@ void handle_SaveAPRSCfg() {
preferences.putBool(PREF_APRS_SHOW_BATTERY, server.hasArg(PREF_APRS_SHOW_BATTERY));
preferences.putBool(PREF_APRS_SHOW_ALTITUDE, server.hasArg(PREF_APRS_SHOW_ALTITUDE));
preferences.putBool(PREF_APRS_FIXED_BEACON_PRESET, server.hasArg(PREF_APRS_FIXED_BEACON_PRESET));
preferences.putBool(PREF_APRS_GPS_EN, server.hasArg(PREF_APRS_GPS_EN));
server.sendHeader("Location", "/");
server.send(302,"text/html", "");