Skip to content

Commit c87113f

Browse files
authored
Merge pull request #894 from cyberman54/development
Development
2 parents 26b0a55 + 6c44865 commit c87113f

File tree

5 files changed

+26
-23
lines changed

5 files changed

+26
-23
lines changed

include/payload.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,6 @@ class PayloadConvert {
100100
};
101101

102102
extern PayloadConvert payload;
103-
extern uint8_t batt_level;
103+
extern int8_t batt_level;
104104

105105
#endif // _PAYLOAD_H_

include/power.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,6 @@ static inline uint8_t linear(uint16_t voltage, uint16_t minVoltage,
131131
(maxVoltage - minVoltage);
132132
}
133133

134-
uint8_t read_battlevel(mapFn_t mapFunction = &sigmoidal);
134+
int8_t read_battlevel(mapFn_t mapFunction = &sigmoidal);
135135

136136
#endif

platformio_orig.ini

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ description = Paxcounter is a device for metering passenger flows in realtime. I
4646

4747
[common]
4848
; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
49-
release_version = 3.3.1
49+
release_version = 3.3.2
5050
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running!
5151
; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
5252
debug_level = 3
@@ -71,19 +71,19 @@ lib_deps_rgbled =
7171
lib_deps_gps =
7272
mikalhart/TinyGPSPlus @ ^1.0.2
7373
lib_deps_sensors =
74-
adafruit/Adafruit Unified Sensor @ ^1.1.4
75-
adafruit/Adafruit BME280 Library @ ^2.2.1
76-
adafruit/Adafruit BMP085 Library @ ^1.2.0
74+
adafruit/Adafruit Unified Sensor @ ^1.1.6
75+
adafruit/Adafruit BME280 Library @ ^2.2.2
76+
adafruit/Adafruit BMP085 Library @ ^1.2.1
7777
boschsensortec/BSEC Software Library @ 1.6.1480
78-
https://github.com/cyberman54/sds-dust-sensors-arduino-library.git
78+
lewapek/Nova Fitness Sds dust sensors library @ ^1.5.1
7979
lib_deps_basic =
8080
https://github.com/dbSuS/libpax.git
8181
https://github.com/SukkoPera/Arduino-Rokkit-Hash.git
8282
bblanchon/ArduinoJson @ ^6
8383
makuna/RTC @ ^2.3.5
8484
spacehuhn/SimpleButton
8585
lewisxhe/XPowersLib @ ^0.1.4
86-
256dpi/MQTT @ ^2.4.8
86+
256dpi/MQTT @ ^2.5.0
8787
lib_deps_all =
8888
${common.lib_deps_basic}
8989
${common.lib_deps_lora}

src/display.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,10 @@ void dp_refresh(bool nextPage) {
226226
// line 4: Battery + GPS status + Wifi channel
227227
// B:a.bcV Sats:ab ch:ab
228228
#if (defined BAT_MEASURE_ADC || defined HAS_PMU || defined HAS_IP5306)
229-
if (batt_level == 0)
230-
dp->printf("No batt ");
231-
else
229+
if (batt_level > 0)
232230
dp->printf("Batt:%3u%% ", batt_level);
231+
else
232+
dp->printf("No batt ");
233233
#else
234234
dp->printf(" ");
235235
#endif

src/power.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Local logging tag
66
static const char TAG[] = __FILE__;
77

8-
uint8_t batt_level = 0; // display value
8+
int8_t batt_level = -1; // percent batt level, global variable, -1 means no batt
99

1010
#ifdef BAT_MEASURE_ADC
1111
esp_adc_cal_characteristics_t *adc_characs =
@@ -92,11 +92,11 @@ void AXP192_showstatus(void) {
9292
if (pmu.isBatteryConnect())
9393
if (pmu.isCharging())
9494
ESP_LOGI(TAG, "Battery charging, %.2fV @ %.0fmAh",
95-
pmu.getBattVoltage() / 1000, pmu.getBatteryChargeCurrent());
95+
pmu.getBattVoltage() / 1000.0, pmu.getBatteryChargeCurrent());
9696
else
9797
ESP_LOGI(TAG, "Battery not charging");
9898
else
99-
ESP_LOGI(TAG, "No Battery");
99+
ESP_LOGI(TAG, "Battery not present");
100100

101101
if (pmu.isVbusIn())
102102
ESP_LOGI(TAG, "USB powered, %.0fmW",
@@ -142,10 +142,14 @@ void AXP192_init(void) {
142142
// clear all interrupt flags
143143
pmu.clearIrqStatus();
144144
// enable the required interrupt function
145-
pmu.enableIRQ(XPOWERS_AXP192_BAT_INSERT_IRQ | XPOWERS_AXP192_BAT_REMOVE_IRQ | // BATTERY
146-
XPOWERS_AXP192_VBUS_INSERT_IRQ | XPOWERS_AXP192_VBUS_REMOVE_IRQ | // VBUS
147-
XPOWERS_AXP192_PKEY_SHORT_IRQ | XPOWERS_AXP192_PKEY_LONG_IRQ | // POWER KEY
148-
XPOWERS_AXP192_BAT_CHG_DONE_IRQ | XPOWERS_AXP192_BAT_CHG_START_IRQ // CHARGE
145+
pmu.enableIRQ(XPOWERS_AXP192_BAT_INSERT_IRQ |
146+
XPOWERS_AXP192_BAT_REMOVE_IRQ | // BATTERY
147+
XPOWERS_AXP192_VBUS_INSERT_IRQ |
148+
XPOWERS_AXP192_VBUS_REMOVE_IRQ | // VBUS
149+
XPOWERS_AXP192_PKEY_SHORT_IRQ |
150+
XPOWERS_AXP192_PKEY_LONG_IRQ | // POWER KEY
151+
XPOWERS_AXP192_BAT_CHG_DONE_IRQ |
152+
XPOWERS_AXP192_BAT_CHG_START_IRQ // CHARGE
149153
);
150154
#endif // PMU_INT
151155

@@ -231,14 +235,13 @@ uint16_t read_voltage(void) {
231235
return voltage;
232236
}
233237

234-
uint8_t read_battlevel(mapFn_t mapFunction) {
238+
int8_t read_battlevel(mapFn_t mapFunction) {
235239
// returns the estimated battery level in values 0 ... 100 [percent]
236240
uint8_t batt_percent = 0;
237241
#ifdef HAS_IP5306
238242
batt_percent = IP5306_GetBatteryLevel();
239243
#elif defined HAS_PMU
240-
int bp = pmu.getBatteryPercent();
241-
batt_percent = bp < 0 ? 0 : bp;
244+
batt_percent = pmu.getBatteryPercent();
242245
#else
243246
const uint16_t batt_voltage = read_voltage();
244247
if (batt_voltage <= BAT_MIN_VOLTAGE)
@@ -260,7 +263,7 @@ uint8_t read_battlevel(mapFn_t mapFunction) {
260263
// we calculate the applicable value from MCMD_DEVS_BATT_MIN to
261264
// MCMD_DEVS_BATT_MAX from batt_percent value
262265

263-
if (batt_percent == 0)
266+
if (batt_percent == -1)
264267
LMIC_setBatteryLevel(MCMD_DEVS_BATT_NOINFO);
265268
else
266269
LMIC_setBatteryLevel(batt_percent / 100.0 *
@@ -282,7 +285,7 @@ uint8_t read_battlevel(mapFn_t mapFunction) {
282285

283286
bool batt_sufficient() {
284287
#if (defined HAS_PMU || defined BAT_MEASURE_ADC || defined HAS_IP5306)
285-
if (batt_level) // we have a battery voltage
288+
if (batt_level > 0) // we have a battery percent value
286289
return (batt_level > OTA_MIN_BATT);
287290
else
288291
#endif

0 commit comments

Comments
 (0)