kopia lustrzana https://github.com/SQ9MDD/TTGO-T-Beam-LoRa-APRS
Trying to reduce power consumption
rodzic
00b08722b5
commit
b760fd9a23
|
@ -4,6 +4,7 @@
|
||||||
#include <ESPmDNS.h>
|
#include <ESPmDNS.h>
|
||||||
#include <Update.h>
|
#include <Update.h>
|
||||||
#include <BG_RF95.h>
|
#include <BG_RF95.h>
|
||||||
|
#include <esp_wifi.h>
|
||||||
|
|
||||||
#ifndef TASK_WEBSERVER
|
#ifndef TASK_WEBSERVER
|
||||||
#define TASK_WEBSERVER
|
#define TASK_WEBSERVER
|
||||||
|
@ -24,7 +25,6 @@ typedef struct {
|
||||||
int SNR;
|
int SNR;
|
||||||
} tReceivedPacketData;
|
} tReceivedPacketData;
|
||||||
|
|
||||||
|
|
||||||
extern QueueHandle_t webListReceivedQueue;
|
extern QueueHandle_t webListReceivedQueue;
|
||||||
|
|
||||||
[[noreturn]] void taskWebServer(void *parameter);
|
[[noreturn]] void taskWebServer(void *parameter);
|
||||||
|
|
|
@ -400,6 +400,7 @@ void batt_read(){
|
||||||
InpVolts = axp.getVbusVoltage()/1000;
|
InpVolts = axp.getVbusVoltage()/1000;
|
||||||
#elif T_BEAM_V0_7
|
#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 = (((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
|
#else
|
||||||
BattVolts = analogRead(35)*7.221/4096;
|
BattVolts = analogRead(35)*7.221/4096;
|
||||||
#endif
|
#endif
|
||||||
|
@ -441,15 +442,15 @@ String getSatAndBatInfo() {
|
||||||
String line5;
|
String line5;
|
||||||
if(gps_state == true){
|
if(gps_state == true){
|
||||||
if(InpVolts > 4){
|
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{
|
}else{
|
||||||
line5 = "SAT: " + String(gps.satellites.value()) + " BAT: " + String(BattVolts, 1) + "V";
|
line5 = "SAT: " + String(gps.satellites.value()) + " BAT: " + String(BattVolts, 2) + "V";
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(InpVolts > 4){
|
if(InpVolts > 4){
|
||||||
line5 = "SAT: X BAT: " + String(BattVolts, 1) + "V *";
|
line5 = "SAT: X BAT: " + String(BattVolts, 1) + "V*";
|
||||||
}else{
|
}else{
|
||||||
line5 = "SAT: X BAT: " + String(BattVolts, 1) + "V";
|
line5 = "SAT: X BAT: " + String(BattVolts, 2) + "V";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -578,19 +579,22 @@ String prepareCallsign(const String& callsign){
|
||||||
tel_sequence = tel_sequence + 1;
|
tel_sequence = tel_sequence + 1;
|
||||||
}
|
}
|
||||||
preferences.putUInt(PREF_TNC_SELF_TELEMETRY_SEQ, tel_sequence);
|
preferences.putUInt(PREF_TNC_SELF_TELEMETRY_SEQ, tel_sequence);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// + SETUP --------------------------------------------------------------+//
|
// + SETUP --------------------------------------------------------------+//
|
||||||
void setup(){
|
void setup(){
|
||||||
//#ifdef T_BEAM_V0_7
|
#ifdef T_BEAM_V0_7 /*
|
||||||
// adcAttachPin(35);
|
adcAttachPin(35);
|
||||||
// adcStart(35);
|
adcStart(35);
|
||||||
// analogReadResolution(10);
|
analogReadResolution(10);
|
||||||
//#endif
|
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
|
SPI.begin(SPI_sck,SPI_miso,SPI_mosi,SPI_ss); //DO2JMG Heltec Patch
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
|
@ -402,6 +402,9 @@ void handle_saveDeviceCfg(){
|
||||||
int retryWifi = 0;
|
int retryWifi = 0;
|
||||||
WiFi.begin(wifi_ssid.c_str(), wifi_password.length() ? wifi_password.c_str() : nullptr);
|
WiFi.begin(wifi_ssid.c_str(), wifi_password.length() ? wifi_password.c_str() : nullptr);
|
||||||
Serial.println("Connecting to " + wifi_ssid);
|
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) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
Serial.print("Not connected: ");
|
Serial.print("Not connected: ");
|
||||||
Serial.println((int)WiFi.status());
|
Serial.println((int)WiFi.status());
|
||||||
|
@ -417,6 +420,8 @@ void handle_saveDeviceCfg(){
|
||||||
Serial.print(apSSID.c_str());
|
Serial.print(apSSID.c_str());
|
||||||
Serial.print(" Password: ");
|
Serial.print(" Password: ");
|
||||||
Serial.println(apPassword.c_str());
|
Serial.println(apPassword.c_str());
|
||||||
|
// Set power to minimum (max 20)
|
||||||
|
esp_wifi_set_max_tx_power(8);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -430,6 +435,9 @@ void handle_saveDeviceCfg(){
|
||||||
infoApPass = apSSID.c_str();
|
infoApPass = apSSID.c_str();
|
||||||
infoApAddr = WiFi.softAPIP().toString();
|
infoApAddr = WiFi.softAPIP().toString();
|
||||||
} else if (WiFi.getMode() == 1) {
|
} 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());
|
Serial.println("Connected. IP: " + WiFi.localIP().toString());
|
||||||
apConnected=true;
|
apConnected=true;
|
||||||
infoApName = wifi_ssid.c_str();
|
infoApName = wifi_ssid.c_str();
|
||||||
|
|
Ładowanie…
Reference in New Issue