Merge pull request #894 from cyberman54/development

Development
This commit is contained in:
Verkehrsrot 2022-09-18 17:22:02 +02:00 committed by GitHub
commit c87113fc2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 23 deletions

View File

@ -100,6 +100,6 @@ private:
}; };
extern PayloadConvert payload; extern PayloadConvert payload;
extern uint8_t batt_level; extern int8_t batt_level;
#endif // _PAYLOAD_H_ #endif // _PAYLOAD_H_

View File

@ -131,6 +131,6 @@ static inline uint8_t linear(uint16_t voltage, uint16_t minVoltage,
(maxVoltage - minVoltage); (maxVoltage - minVoltage);
} }
uint8_t read_battlevel(mapFn_t mapFunction = &sigmoidal); int8_t read_battlevel(mapFn_t mapFunction = &sigmoidal);
#endif #endif

View File

@ -46,7 +46,7 @@ description = Paxcounter is a device for metering passenger flows in realtime. I
[common] [common]
; for release_version use max. 10 chars total, use any decimal format like "a.b.c" ; 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! ; 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 ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
debug_level = 3 debug_level = 3
@ -71,11 +71,11 @@ lib_deps_rgbled =
lib_deps_gps = lib_deps_gps =
mikalhart/TinyGPSPlus @ ^1.0.2 mikalhart/TinyGPSPlus @ ^1.0.2
lib_deps_sensors = lib_deps_sensors =
adafruit/Adafruit Unified Sensor @ ^1.1.4 adafruit/Adafruit Unified Sensor @ ^1.1.6
adafruit/Adafruit BME280 Library @ ^2.2.1 adafruit/Adafruit BME280 Library @ ^2.2.2
adafruit/Adafruit BMP085 Library @ ^1.2.0 adafruit/Adafruit BMP085 Library @ ^1.2.1
boschsensortec/BSEC Software Library @ 1.6.1480 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 = lib_deps_basic =
https://github.com/dbSuS/libpax.git https://github.com/dbSuS/libpax.git
https://github.com/SukkoPera/Arduino-Rokkit-Hash.git https://github.com/SukkoPera/Arduino-Rokkit-Hash.git
@ -83,7 +83,7 @@ lib_deps_basic =
makuna/RTC @ ^2.3.5 makuna/RTC @ ^2.3.5
spacehuhn/SimpleButton spacehuhn/SimpleButton
lewisxhe/XPowersLib @ ^0.1.4 lewisxhe/XPowersLib @ ^0.1.4
256dpi/MQTT @ ^2.4.8 256dpi/MQTT @ ^2.5.0
lib_deps_all = lib_deps_all =
${common.lib_deps_basic} ${common.lib_deps_basic}
${common.lib_deps_lora} ${common.lib_deps_lora}

View File

@ -226,10 +226,10 @@ void dp_refresh(bool nextPage) {
// line 4: Battery + GPS status + Wifi channel // line 4: Battery + GPS status + Wifi channel
// B:a.bcV Sats:ab ch:ab // B:a.bcV Sats:ab ch:ab
#if (defined BAT_MEASURE_ADC || defined HAS_PMU || defined HAS_IP5306) #if (defined BAT_MEASURE_ADC || defined HAS_PMU || defined HAS_IP5306)
if (batt_level == 0) if (batt_level > 0)
dp->printf("No batt ");
else
dp->printf("Batt:%3u%% ", batt_level); dp->printf("Batt:%3u%% ", batt_level);
else
dp->printf("No batt ");
#else #else
dp->printf(" "); dp->printf(" ");
#endif #endif

View File

@ -5,7 +5,7 @@
// Local logging tag // Local logging tag
static const char TAG[] = __FILE__; 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 #ifdef BAT_MEASURE_ADC
esp_adc_cal_characteristics_t *adc_characs = esp_adc_cal_characteristics_t *adc_characs =
@ -92,11 +92,11 @@ void AXP192_showstatus(void) {
if (pmu.isBatteryConnect()) if (pmu.isBatteryConnect())
if (pmu.isCharging()) if (pmu.isCharging())
ESP_LOGI(TAG, "Battery charging, %.2fV @ %.0fmAh", ESP_LOGI(TAG, "Battery charging, %.2fV @ %.0fmAh",
pmu.getBattVoltage() / 1000, pmu.getBatteryChargeCurrent()); pmu.getBattVoltage() / 1000.0, pmu.getBatteryChargeCurrent());
else else
ESP_LOGI(TAG, "Battery not charging"); ESP_LOGI(TAG, "Battery not charging");
else else
ESP_LOGI(TAG, "No Battery"); ESP_LOGI(TAG, "Battery not present");
if (pmu.isVbusIn()) if (pmu.isVbusIn())
ESP_LOGI(TAG, "USB powered, %.0fmW", ESP_LOGI(TAG, "USB powered, %.0fmW",
@ -142,10 +142,14 @@ void AXP192_init(void) {
// clear all interrupt flags // clear all interrupt flags
pmu.clearIrqStatus(); pmu.clearIrqStatus();
// enable the required interrupt function // enable the required interrupt function
pmu.enableIRQ(XPOWERS_AXP192_BAT_INSERT_IRQ | XPOWERS_AXP192_BAT_REMOVE_IRQ | // BATTERY pmu.enableIRQ(XPOWERS_AXP192_BAT_INSERT_IRQ |
XPOWERS_AXP192_VBUS_INSERT_IRQ | XPOWERS_AXP192_VBUS_REMOVE_IRQ | // VBUS XPOWERS_AXP192_BAT_REMOVE_IRQ | // BATTERY
XPOWERS_AXP192_PKEY_SHORT_IRQ | XPOWERS_AXP192_PKEY_LONG_IRQ | // POWER KEY XPOWERS_AXP192_VBUS_INSERT_IRQ |
XPOWERS_AXP192_BAT_CHG_DONE_IRQ | XPOWERS_AXP192_BAT_CHG_START_IRQ // CHARGE 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 #endif // PMU_INT
@ -231,14 +235,13 @@ uint16_t read_voltage(void) {
return voltage; 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] // returns the estimated battery level in values 0 ... 100 [percent]
uint8_t batt_percent = 0; uint8_t batt_percent = 0;
#ifdef HAS_IP5306 #ifdef HAS_IP5306
batt_percent = IP5306_GetBatteryLevel(); batt_percent = IP5306_GetBatteryLevel();
#elif defined HAS_PMU #elif defined HAS_PMU
int bp = pmu.getBatteryPercent(); batt_percent = pmu.getBatteryPercent();
batt_percent = bp < 0 ? 0 : bp;
#else #else
const uint16_t batt_voltage = read_voltage(); const uint16_t batt_voltage = read_voltage();
if (batt_voltage <= BAT_MIN_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 // we calculate the applicable value from MCMD_DEVS_BATT_MIN to
// MCMD_DEVS_BATT_MAX from batt_percent value // MCMD_DEVS_BATT_MAX from batt_percent value
if (batt_percent == 0) if (batt_percent == -1)
LMIC_setBatteryLevel(MCMD_DEVS_BATT_NOINFO); LMIC_setBatteryLevel(MCMD_DEVS_BATT_NOINFO);
else else
LMIC_setBatteryLevel(batt_percent / 100.0 * LMIC_setBatteryLevel(batt_percent / 100.0 *
@ -282,7 +285,7 @@ uint8_t read_battlevel(mapFn_t mapFunction) {
bool batt_sufficient() { bool batt_sufficient() {
#if (defined HAS_PMU || defined BAT_MEASURE_ADC || defined HAS_IP5306) #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); return (batt_level > OTA_MIN_BATT);
else else
#endif #endif