Skip to content

Commit

Permalink
improved battery management for Uni
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed Jun 16, 2020
1 parent 4e545a7 commit 0104ca4
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 20 deletions.
3 changes: 3 additions & 0 deletions software/firmware/source/SkyView/BatteryHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
#define BATTERY_THRESHOLD_NIMHX2 2.3
#define BATTERY_THRESHOLD_LIPO 3.5
#define BATTERY_THRESHOLD_LIFE 3.0
#define BATTERY_THRESHOLD_NIZNX2 3.0

#define BATTERY_CUTOFF_NIMHX2 2.1
#define BATTERY_CUTOFF_LIPO 3.2
#define BATTERY_CUTOFF_NIZNX2 2.9

void Battery_setup(void);
void Battery_loop(void);
Expand Down
6 changes: 3 additions & 3 deletions software/firmware/source/SkyView/SkyView.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ enum

enum
{
POWER_SAVE_NONE,
POWER_SAVE_WIFI,
POWER_SAVE_GNSS
POWER_SAVE_NONE = 0,
POWER_SAVE_WIFI = 1,
POWER_SAVE_GNSS = 2
};

enum
Expand Down
2 changes: 1 addition & 1 deletion software/firmware/source/SkyView/WiFiHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void WiFi_loop()
#endif

#if defined(POWER_SAVING_WIFI_TIMEOUT)
if (settings->power_save == POWER_SAVE_WIFI && WiFi.getMode() == WIFI_AP) {
if ((settings->power_save & POWER_SAVE_WIFI) && WiFi.getMode() == WIFI_AP) {
if (SoC->WiFi_clients_count() == 0) {
if ((millis() - WiFi_No_Clients_Time_ms) > POWER_SAVING_WIFI_TIMEOUT) {
Web_fini();
Expand Down
8 changes: 5 additions & 3 deletions software/firmware/source/SkyWatch/BatteryHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@
#define BATTERY_THRESHOLD_NIMHX2 2.3
#define BATTERY_THRESHOLD_LIPO 3.5
#define BATTERY_THRESHOLD_LIFE 3.0
#define BATTERY_THRESHOLD_NIZNX2 3.0

#define BATTERY_CUTOFF_NIMHX2 2.1
#define BATTERY_CUTOFF_LIPO 3.2
#define BATTERY_CUTOFF_NIZNX2 2.9

enum
{
POWER_SAVE_NONE,
POWER_SAVE_WIFI,
POWER_SAVE_GNSS
POWER_SAVE_NONE = 0,
POWER_SAVE_WIFI = 1,
POWER_SAVE_GNSS = 2
};

void Battery_setup(void);
Expand Down
2 changes: 1 addition & 1 deletion software/firmware/source/SkyWatch/WiFiHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void WiFi_loop()
#endif

#if defined(POWER_SAVING_WIFI_TIMEOUT)
if (settings->s.power_save == POWER_SAVE_WIFI && WiFi.getMode() == WIFI_AP) {
if ((settings->s.power_save & POWER_SAVE_WIFI) && WiFi.getMode() == WIFI_AP) {
if (SoC->WiFi_clients_count() == 0) {
if ((millis() - WiFi_No_Clients_Time_ms) > POWER_SAVING_WIFI_TIMEOUT) {
NMEA_fini();
Expand Down
10 changes: 6 additions & 4 deletions software/firmware/source/SoftRF/BatteryHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@ float Battery_voltage()
float Battery_threshold()
{
return hw_info.model == SOFTRF_MODEL_PRIME_MK2 ||
hw_info.model == SOFTRF_MODEL_DONGLE ?
BATTERY_THRESHOLD_LIPO : BATTERY_THRESHOLD_NIMHX2;
hw_info.model == SOFTRF_MODEL_DONGLE ? BATTERY_THRESHOLD_LIPO :
hw_info.model == SOFTRF_MODEL_UNI ? BATTERY_THRESHOLD_NIZNX2 :
BATTERY_THRESHOLD_NIMHX2;
}

/* Battery is empty */
float Battery_cutoff()
{
return hw_info.model == SOFTRF_MODEL_PRIME_MK2 ||
hw_info.model == SOFTRF_MODEL_DONGLE ?
BATTERY_CUTOFF_LIPO : BATTERY_CUTOFF_NIMHX2;
hw_info.model == SOFTRF_MODEL_DONGLE ? BATTERY_CUTOFF_LIPO :
hw_info.model == SOFTRF_MODEL_UNI ? BATTERY_CUTOFF_NIZNX2 :
BATTERY_CUTOFF_NIMHX2;
}

void Battery_loop()
Expand Down
8 changes: 5 additions & 3 deletions software/firmware/source/SoftRF/BatteryHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@
#define BATTERY_THRESHOLD_NIMHX2 2.3
#define BATTERY_THRESHOLD_LIPO 3.5
#define BATTERY_THRESHOLD_LIFE 3.0
#define BATTERY_THRESHOLD_NIZNX2 3.0

#define BATTERY_CUTOFF_NIMHX2 2.1
#define BATTERY_CUTOFF_LIPO 3.2
#define BATTERY_CUTOFF_NIZNX2 2.9

enum
{
POWER_SAVE_NONE,
POWER_SAVE_WIFI,
POWER_SAVE_GNSS
POWER_SAVE_NONE = 0,
POWER_SAVE_WIFI = 1,
POWER_SAVE_GNSS = 2
};

void Battery_setup(void);
Expand Down
2 changes: 1 addition & 1 deletion software/firmware/source/SoftRF/GNSSHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ void GNSS_loop()
GNSSTimeSync();

#if defined(USE_GNSS_PSM)
if (settings->power_save == POWER_SAVE_GNSS) {
if (settings->power_save & POWER_SAVE_GNSS) {
if (hw_info.model == SOFTRF_MODEL_UNI) {
if (hw_info.gnss == GNSS_MODULE_U6 ||
hw_info.gnss == GNSS_MODULE_U7 ||
Expand Down
6 changes: 3 additions & 3 deletions software/firmware/source/SoftRF/Platform_CC13XX.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ struct rst_info {
#define EXCLUDE_NRF905
#define EXCLUDE_UATM

/* SoftRF/S7xG PFLAU NMEA sentence extension(s) */
#define PFLAU_EXT1_FMT ",%06X,%d,%d,%d"
#define PFLAU_EXT1_ARGS ,ThisAircraft.addr,settings->rf_protocol,rx_packets_counter,tx_packets_counter
/* SoftRF/CC13XX PFLAU NMEA sentence extension(s) */
#define PFLAU_EXT1_FMT ",%06X,%d,%d,%d,%d"
#define PFLAU_EXT1_ARGS ,ThisAircraft.addr,settings->rf_protocol,rx_packets_counter,tx_packets_counter,(int)(SoC->Battery_voltage()*100)

#include "hal_conf_extra.h" // Sketch-specific definitions are located there

Expand Down
2 changes: 1 addition & 1 deletion software/firmware/source/SoftRF/WiFiHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void WiFi_loop()
#endif

#if defined(POWER_SAVING_WIFI_TIMEOUT)
if (settings->power_save == POWER_SAVE_WIFI && WiFi.getMode() == WIFI_AP) {
if ((settings->power_save & POWER_SAVE_WIFI) && WiFi.getMode() == WIFI_AP) {
if (SoC->WiFi_clients_count() == 0) {
if ((millis() - WiFi_No_Clients_Time_ms) > POWER_SAVING_WIFI_TIMEOUT) {
NMEA_fini();
Expand Down

0 comments on commit 0104ca4

Please sign in to comment.