Merge pull request #79 from iu2frl/master

Trying to reduce power consumption
pull/80/head^2
Rysiek Labus (SQ9MDD) 2021-09-19 20:52:29 +02:00 zatwierdzone przez GitHub
commit d7ae2f23b3
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 24 dodań i 11 usunięć

Wyświetl plik

@ -4,6 +4,7 @@
#include <ESPmDNS.h>
#include <Update.h>
#include <BG_RF95.h>
#include <esp_wifi.h>
#ifndef TASK_WEBSERVER
#define TASK_WEBSERVER
@ -24,7 +25,6 @@ typedef struct {
int SNR;
} tReceivedPacketData;
extern QueueHandle_t webListReceivedQueue;
[[noreturn]] void taskWebServer(void *parameter);

Wyświetl plik

@ -400,6 +400,7 @@ void batt_read(){
InpVolts = axp.getVbusVoltage()/1000;
#elif T_BEAM_V0_7
BattVolts = (((float)analogRead(35) / 8192.0) * 2.0 * 3.3 * (1100.0 / 1000.0))+0.41; // fixed thanks to Luca IU2FRL
//BattVolts = adc1_get_raw(ADC1_CHANNEL_7)/1000;
#else
BattVolts = analogRead(35)*7.221/4096;
#endif
@ -441,15 +442,15 @@ String getSatAndBatInfo() {
String line5;
if(gps_state == true){
if(InpVolts > 4){
line5 = "SAT: " + String(gps.satellites.value()) + " BAT: " + String(BattVolts, 1) + "V *";
line5 = "SAT: " + String(gps.satellites.value()) + " BAT: " + String(BattVolts, 1) + "V*";
}else{
line5 = "SAT: " + String(gps.satellites.value()) + " BAT: " + String(BattVolts, 1) + "V";
line5 = "SAT: " + String(gps.satellites.value()) + " BAT: " + String(BattVolts, 2) + "V";
}
}else{
if(InpVolts > 4){
line5 = "SAT: X BAT: " + String(BattVolts, 1) + "V *";
line5 = "SAT: X BAT: " + String(BattVolts, 1) + "V*";
}else{
line5 = "SAT: X BAT: " + String(BattVolts, 1) + "V";
line5 = "SAT: X BAT: " + String(BattVolts, 2) + "V";
}
}
@ -579,17 +580,21 @@ String prepareCallsign(const String& callsign){
}
preferences.putUInt(PREF_TNC_SELF_TELEMETRY_SEQ, tel_sequence);
#endif
}
}
}
#endif
// + SETUP --------------------------------------------------------------+//
void setup(){
//#ifdef T_BEAM_V0_7
// adcAttachPin(35);
// adcStart(35);
// analogReadResolution(10);
//#endif
#ifdef T_BEAM_V0_7 /*
adcAttachPin(35);
adcStart(35);
analogReadResolution(10);
analogSetAttenuation(ADC_6db); */
pinMode(35, INPUT);
//adc1_config_width(ADC_WIDTH_BIT_12);
//adc1_config_channel_atten(ADC1_CHANNEL_7,ADC_ATTEN_DB_11);
#endif
SPI.begin(SPI_sck,SPI_miso,SPI_mosi,SPI_ss); //DO2JMG Heltec Patch
Serial.begin(115200);

Wyświetl plik

@ -402,6 +402,9 @@ void handle_saveDeviceCfg(){
int retryWifi = 0;
WiFi.begin(wifi_ssid.c_str(), wifi_password.length() ? wifi_password.c_str() : nullptr);
Serial.println("Connecting to " + wifi_ssid);
// Set power to minimum (max 20)
// https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_wifi.html
esp_wifi_set_max_tx_power(8);
while (WiFi.status() != WL_CONNECTED) {
Serial.print("Not connected: ");
Serial.println((int)WiFi.status());
@ -417,6 +420,8 @@ void handle_saveDeviceCfg(){
Serial.print(apSSID.c_str());
Serial.print(" Password: ");
Serial.println(apPassword.c_str());
// Set power to minimum (max 20)
esp_wifi_set_max_tx_power(8);
break;
}
}
@ -430,6 +435,9 @@ void handle_saveDeviceCfg(){
infoApPass = apSSID.c_str();
infoApAddr = WiFi.softAPIP().toString();
} else if (WiFi.getMode() == 1) {
// Save some battery
//WiFi.setSleep(true);
esp_wifi_set_ps(WIFI_PS_MAX_MODEM);
Serial.println("Connected. IP: " + WiFi.localIP().toString());
apConnected=true;
infoApName = wifi_ssid.c_str();