commit
c87113fc2e
@ -100,6 +100,6 @@ private:
|
||||
};
|
||||
|
||||
extern PayloadConvert payload;
|
||||
extern uint8_t batt_level;
|
||||
extern int8_t batt_level;
|
||||
|
||||
#endif // _PAYLOAD_H_
|
||||
|
@ -131,6 +131,6 @@ static inline uint8_t linear(uint16_t voltage, uint16_t minVoltage,
|
||||
(maxVoltage - minVoltage);
|
||||
}
|
||||
|
||||
uint8_t read_battlevel(mapFn_t mapFunction = &sigmoidal);
|
||||
int8_t read_battlevel(mapFn_t mapFunction = &sigmoidal);
|
||||
|
||||
#endif
|
@ -46,7 +46,7 @@ description = Paxcounter is a device for metering passenger flows in realtime. I
|
||||
|
||||
[common]
|
||||
; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
|
||||
release_version = 3.3.1
|
||||
release_version = 3.3.2
|
||||
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running!
|
||||
; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
|
||||
debug_level = 3
|
||||
@ -71,11 +71,11 @@ lib_deps_rgbled =
|
||||
lib_deps_gps =
|
||||
mikalhart/TinyGPSPlus @ ^1.0.2
|
||||
lib_deps_sensors =
|
||||
adafruit/Adafruit Unified Sensor @ ^1.1.4
|
||||
adafruit/Adafruit BME280 Library @ ^2.2.1
|
||||
adafruit/Adafruit BMP085 Library @ ^1.2.0
|
||||
adafruit/Adafruit Unified Sensor @ ^1.1.6
|
||||
adafruit/Adafruit BME280 Library @ ^2.2.2
|
||||
adafruit/Adafruit BMP085 Library @ ^1.2.1
|
||||
boschsensortec/BSEC Software Library @ 1.6.1480
|
||||
https://github.com/cyberman54/sds-dust-sensors-arduino-library.git
|
||||
lewapek/Nova Fitness Sds dust sensors library @ ^1.5.1
|
||||
lib_deps_basic =
|
||||
https://github.com/dbSuS/libpax.git
|
||||
https://github.com/SukkoPera/Arduino-Rokkit-Hash.git
|
||||
@ -83,7 +83,7 @@ lib_deps_basic =
|
||||
makuna/RTC @ ^2.3.5
|
||||
spacehuhn/SimpleButton
|
||||
lewisxhe/XPowersLib @ ^0.1.4
|
||||
256dpi/MQTT @ ^2.4.8
|
||||
256dpi/MQTT @ ^2.5.0
|
||||
lib_deps_all =
|
||||
${common.lib_deps_basic}
|
||||
${common.lib_deps_lora}
|
||||
|
@ -226,10 +226,10 @@ void dp_refresh(bool nextPage) {
|
||||
// line 4: Battery + GPS status + Wifi channel
|
||||
// B:a.bcV Sats:ab ch:ab
|
||||
#if (defined BAT_MEASURE_ADC || defined HAS_PMU || defined HAS_IP5306)
|
||||
if (batt_level == 0)
|
||||
dp->printf("No batt ");
|
||||
else
|
||||
if (batt_level > 0)
|
||||
dp->printf("Batt:%3u%% ", batt_level);
|
||||
else
|
||||
dp->printf("No batt ");
|
||||
#else
|
||||
dp->printf(" ");
|
||||
#endif
|
||||
|
@ -5,7 +5,7 @@
|
||||
// Local logging tag
|
||||
static const char TAG[] = __FILE__;
|
||||
|
||||
uint8_t batt_level = 0; // display value
|
||||
int8_t batt_level = -1; // percent batt level, global variable, -1 means no batt
|
||||
|
||||
#ifdef BAT_MEASURE_ADC
|
||||
esp_adc_cal_characteristics_t *adc_characs =
|
||||
@ -92,11 +92,11 @@ void AXP192_showstatus(void) {
|
||||
if (pmu.isBatteryConnect())
|
||||
if (pmu.isCharging())
|
||||
ESP_LOGI(TAG, "Battery charging, %.2fV @ %.0fmAh",
|
||||
pmu.getBattVoltage() / 1000, pmu.getBatteryChargeCurrent());
|
||||
pmu.getBattVoltage() / 1000.0, pmu.getBatteryChargeCurrent());
|
||||
else
|
||||
ESP_LOGI(TAG, "Battery not charging");
|
||||
else
|
||||
ESP_LOGI(TAG, "No Battery");
|
||||
ESP_LOGI(TAG, "Battery not present");
|
||||
|
||||
if (pmu.isVbusIn())
|
||||
ESP_LOGI(TAG, "USB powered, %.0fmW",
|
||||
@ -142,10 +142,14 @@ void AXP192_init(void) {
|
||||
// clear all interrupt flags
|
||||
pmu.clearIrqStatus();
|
||||
// enable the required interrupt function
|
||||
pmu.enableIRQ(XPOWERS_AXP192_BAT_INSERT_IRQ | XPOWERS_AXP192_BAT_REMOVE_IRQ | // BATTERY
|
||||
XPOWERS_AXP192_VBUS_INSERT_IRQ | XPOWERS_AXP192_VBUS_REMOVE_IRQ | // VBUS
|
||||
XPOWERS_AXP192_PKEY_SHORT_IRQ | XPOWERS_AXP192_PKEY_LONG_IRQ | // POWER KEY
|
||||
XPOWERS_AXP192_BAT_CHG_DONE_IRQ | XPOWERS_AXP192_BAT_CHG_START_IRQ // CHARGE
|
||||
pmu.enableIRQ(XPOWERS_AXP192_BAT_INSERT_IRQ |
|
||||
XPOWERS_AXP192_BAT_REMOVE_IRQ | // BATTERY
|
||||
XPOWERS_AXP192_VBUS_INSERT_IRQ |
|
||||
XPOWERS_AXP192_VBUS_REMOVE_IRQ | // VBUS
|
||||
XPOWERS_AXP192_PKEY_SHORT_IRQ |
|
||||
XPOWERS_AXP192_PKEY_LONG_IRQ | // POWER KEY
|
||||
XPOWERS_AXP192_BAT_CHG_DONE_IRQ |
|
||||
XPOWERS_AXP192_BAT_CHG_START_IRQ // CHARGE
|
||||
);
|
||||
#endif // PMU_INT
|
||||
|
||||
@ -231,14 +235,13 @@ uint16_t read_voltage(void) {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
uint8_t read_battlevel(mapFn_t mapFunction) {
|
||||
int8_t read_battlevel(mapFn_t mapFunction) {
|
||||
// returns the estimated battery level in values 0 ... 100 [percent]
|
||||
uint8_t batt_percent = 0;
|
||||
#ifdef HAS_IP5306
|
||||
batt_percent = IP5306_GetBatteryLevel();
|
||||
#elif defined HAS_PMU
|
||||
int bp = pmu.getBatteryPercent();
|
||||
batt_percent = bp < 0 ? 0 : bp;
|
||||
batt_percent = pmu.getBatteryPercent();
|
||||
#else
|
||||
const uint16_t batt_voltage = read_voltage();
|
||||
if (batt_voltage <= BAT_MIN_VOLTAGE)
|
||||
@ -260,7 +263,7 @@ uint8_t read_battlevel(mapFn_t mapFunction) {
|
||||
// we calculate the applicable value from MCMD_DEVS_BATT_MIN to
|
||||
// MCMD_DEVS_BATT_MAX from batt_percent value
|
||||
|
||||
if (batt_percent == 0)
|
||||
if (batt_percent == -1)
|
||||
LMIC_setBatteryLevel(MCMD_DEVS_BATT_NOINFO);
|
||||
else
|
||||
LMIC_setBatteryLevel(batt_percent / 100.0 *
|
||||
@ -282,7 +285,7 @@ uint8_t read_battlevel(mapFn_t mapFunction) {
|
||||
|
||||
bool batt_sufficient() {
|
||||
#if (defined HAS_PMU || defined BAT_MEASURE_ADC || defined HAS_IP5306)
|
||||
if (batt_level) // we have a battery voltage
|
||||
if (batt_level > 0) // we have a battery percent value
|
||||
return (batt_level > OTA_MIN_BATT);
|
||||
else
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user