Skip to content

Commit

Permalink
Some adjustments to wifi power saving option
Browse files Browse the repository at this point in the history
  • Loading branch information
gskjold committed Oct 31, 2022
1 parent 69d8fa9 commit 6c0d5fc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/AmsConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ bool AmsConfiguration::getWiFiConfig(WiFiConfig& config) {
EEPROM.begin(EEPROM_SIZE);
EEPROM.get(CONFIG_WIFI_START, config);
EEPROM.end();
if(config.sleep > 2) config.sleep = 0xFF;
if(config.sleep > 2) config.sleep = 1;
return true;
} else {
clearWifi(config);
Expand All @@ -34,7 +34,7 @@ bool AmsConfiguration::getWiFiConfig(WiFiConfig& config) {

bool AmsConfiguration::setWiFiConfig(WiFiConfig& config) {
WiFiConfig existing;
if(config.sleep > 2) config.sleep = 0xFF;
if(config.sleep > 2) config.sleep = 1;
if(getWiFiConfig(existing)) {
wifiChanged |= strcmp(config.ssid, existing.ssid) != 0;
wifiChanged |= strcmp(config.psk, existing.psk) != 0;
Expand Down
14 changes: 10 additions & 4 deletions src/web/AmsWebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,9 +1015,11 @@ void AmsWebServer::handleSetup() {

DebugConfig debugConfig;
config->getDebugConfig(debugConfig);

config->clear();

WiFiConfig wifi;
config->clearWifi(wifi);

switch(sys.boardType) {
case 0: // roarfred
gpioConfig->hanPin = 3;
Expand All @@ -1042,6 +1044,7 @@ void AmsWebServer::handleSetup() {
gpioConfig->ledInverted = true;
gpioConfig->tempSensorPin = 5;
gpioConfig->vccBootLimit = 33;
wifi.sleep = 1;
break;
case 3: // Pow UART0
gpioConfig->hanPin = 3;
Expand All @@ -1051,6 +1054,7 @@ void AmsWebServer::handleSetup() {
gpioConfig->ledPinRed = 13;
gpioConfig->ledPinGreen = 14;
gpioConfig->ledRgbInverted = true;
wifi.sleep = 1;
break;
case 4: // Pow GPIO12
gpioConfig->hanPin = 12;
Expand All @@ -1060,6 +1064,7 @@ void AmsWebServer::handleSetup() {
gpioConfig->ledPinRed = 13;
gpioConfig->ledPinGreen = 14;
gpioConfig->ledRgbInverted = true;
wifi.sleep = 1;
break;
case 5: // Pow-K+ UART2
gpioConfig->hanPin = 16;
Expand All @@ -1070,6 +1075,7 @@ void AmsWebServer::handleSetup() {
gpioConfig->vccPin = 10;
gpioConfig->vccResistorGnd = 22;
gpioConfig->vccResistorVcc = 33;
wifi.sleep = 1;
break;
case 6: // Pow-P1
gpioConfig->hanPin = 16;
Expand All @@ -1090,6 +1096,7 @@ void AmsWebServer::handleSetup() {
gpioConfig->vccPin = 10;
gpioConfig->vccResistorGnd = 22;
gpioConfig->vccResistorVcc = 33;
wifi.sleep = 2;
break;
case 101: // D1
gpioConfig->hanPin = 5;
Expand Down Expand Up @@ -1126,18 +1133,17 @@ void AmsWebServer::handleSetup() {
break;
case 50: // S2
gpioConfig->hanPin = 18;
wifi.sleep = 1;
break;
case 51: // S2-mini
gpioConfig->hanPin = 18;
gpioConfig->ledPin = 15;
gpioConfig->ledInverted = false;
gpioConfig->apPin = 0;
wifi.sleep = 1;
break;
}

WiFiConfig wifi;
config->clearWifi(wifi);

strcpy(wifi.ssid, server.arg(F("wifiSsid")).c_str());
strcpy(wifi.psk, server.arg(F("wifiPassword")).c_str());

Expand Down
4 changes: 2 additions & 2 deletions web/wifi.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ <h6>WiFi</h6>
<select name="z" class="form-control">
<option value="255">Default</option>
<option value="0" {z0}>Off</option>
<option value="1" {z1}>Min</option>
<option value="2" {z2}>Max</option>
<option value="1" {z1}>Minimum</option>
<option value="2" {z2}>Maximum</option>
</select>
</div>
</div>
Expand Down

0 comments on commit 6c0d5fc

Please sign in to comment.