Compare commits

...

2 Commits

Author SHA1 Message Date
Sebastien
bbbc924fcd Add nvs "wifi_ps" to disable wifi power save mode - release
Set disable_ps = n to disable power save mode. This may help with wifi
signal stability, but will likely result in a higher power consumption.
2020-09-12 16:05:49 -04:00
Chuck
cc5fb49ff8 Battery gauge fix (#52)
* Fix battery reporting in status.json, and adjust scaling for bettery level representation

* remove comment verbosity

* change battery_value_svc to return float

Co-authored-by: rochuck <chuck@zethus.ca>
2020-09-12 11:31:28 -04:00
4 changed files with 27 additions and 11 deletions

View File

@@ -43,7 +43,7 @@ static struct {
/****************************************************************************************
*
*/
int battery_value_svc(void) {
float battery_value_svc(void) {
return battery.avg;
}

View File

@@ -16,6 +16,6 @@ extern bool jack_inserted_svc(void);
extern void (*spkfault_handler_svc)(bool inserted);
extern bool spkfault_svc(void);
extern int battery_value_svc(void);
extern float battery_value_svc(void);
extern uint8_t battery_level_svc(void);

View File

@@ -1028,19 +1028,27 @@ function checkStatus() {
if (data.hasOwnProperty('Voltage')) {
var voltage = data['Voltage'];
var layer;
/* Assuming Li-ion 18650s as a power source, 3.9V per cell, or above is treated
as full charge (>75% of capacity). 3.4V is empty. The gauge is loosely
following the graph here:
https://learn.adafruit.com/li-ion-and-lipoly-batteries/voltages
using the 0.2C discharge profile for the rest of the values.
*/
if (voltage > 0) {
if (inRange(voltage, 5.8, 6.2) || inRange(voltage, 8.8, 9.2)) {
if (inRange(voltage, 5.8, 6.8) || inRange(voltage, 8.8, 10.2)) {
layer = bat0;
} else if (inRange(voltage, 6.2, 6.8) || inRange(voltage, 9.2, 10.0)) {
} else if (inRange(voltage, 6.8, 7.4) || inRange(voltage, 10.2, 11.1)) {
layer = bat1;
} else if (inRange(voltage, 6.8, 7.1) || inRange(voltage, 10.0, 10.5)) {
} else if (inRange(voltage, 7.4, 7.5) || inRange(voltage, 11.1, 11.25)) {
layer = bat2;
} else if (inRange(voltage, 7.1, 7.5) || inRange(voltage, 10.5, 11.0)) {
layer = bat3;
} else if (inRange(voltage, 7.5, 7.8) || inRange(voltage, 11.25, 11.7)) {
layer = bat3;
} else {
layer = bat4;
}
layer.setAttribute("display", "inline");
layer.setAttribute("display","inline");
}
}
if (data.hasOwnProperty('Jack')) {

View File

@@ -272,10 +272,18 @@ void wifi_manager_init_wifi(){
ESP_LOGD(TAG, "Initializing wifi. Setting WiFi mode to WIFI_MODE_NULL");
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_NULL) );
ESP_LOGD(TAG, "Initializing wifi. Starting wifi");
if (gpio36_39_used) {
ESP_LOGW(TAG, "GPIO 36 or 39 are in use, need to disable WiFi PowerSave!");
esp_wifi_set_ps(WIFI_PS_NONE);
char * disable_ps = config_alloc_get_default(NVS_TYPE_STR, "disable_ps", "n", 0);
if (gpio36_39_used || (disable_ps && strcasecmp(disable_ps,"y"))) {
if(gpio36_39_used){
ESP_LOGW(TAG, "GPIO 36 or 39 are in use, need to disable WiFi PowerSave!");
}
else {
ESP_LOGW(TAG, "wifi powersave config is disabled. Disabling WiFi PowerSave!");
}
esp_wifi_set_ps(WIFI_PS_NONE);
}
FREE_AND_NULL(disable_ps);
ESP_ERROR_CHECK( esp_wifi_start() );
taskYIELD();