diff --git a/include/i2c.h b/include/i2c.h index dcf3c8ef..7fcbd33a 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -24,7 +24,7 @@ void i2c_init(void); void i2c_deinit(void); void i2c_scan(void); -uint8_t i2c_readBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len); -uint8_t i2c_writeBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len); +int i2c_readBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len); +int i2c_writeBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len); #endif \ No newline at end of file diff --git a/platformio_orig.ini b/platformio_orig.ini index 26c79e8a..4d9163a3 100644 --- a/platformio_orig.ini +++ b/platformio_orig.ini @@ -48,7 +48,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 = 2.2.0 +release_version = 2.3.0 ; 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 @@ -56,7 +56,7 @@ extra_scripts = pre:build.py otakeyfile = ota.conf lorakeyfile = loraconf.h lmicconfigfile = lmic_config.h -platform_espressif32 = espressif32@2.1.0 +platform_espressif32 = espressif32@3.0.0 monitor_speed = 115200 upload_speed = 115200 ; set by build.py and taken from hal file display_library = ; set by build.py and taken from hal file @@ -85,7 +85,8 @@ lib_deps_basic = jchristensen/Timezone @ ^1.2.4 makuna/RTC @ ^2.3.5 spacehuhn/SimpleButton - lewisxhe/AXP202X_Library @ ^1.1.2 + ;lewisxhe/AXP202X_Library @ ^1.1.2 + https://github.com/lewisxhe/AXP202X_Library.git geeksville/esp32-micro-sdcard @ ^0.1.1 256dpi/MQTT @ ^2.4.7 lib_deps_all = diff --git a/src/gpsread.cpp b/src/gpsread.cpp index a38a175d..d253bcb2 100644 --- a/src/gpsread.cpp +++ b/src/gpsread.cpp @@ -119,7 +119,7 @@ time_t get_gpstime(uint16_t *msec) { tm.Year = CalendarYrToTm(atoi(gpsyear.value())); // year offset from 1970 t = makeTime(tm); - ESP_LOGD(TAG, "GPS time/date = %2d:%2d:%2d / %2d.%2d.%2d", tm.Hour, + ESP_LOGD(TAG, "GPS time/date = %02d:%02d:%02d / %02d.%02d.%2d", tm.Hour, tm.Minute, tm.Second, tm.Day, tm.Month, tm.Year + 1970); // add protocol delay with millisecond precision diff --git a/src/i2c.cpp b/src/i2c.cpp index 226d08c8..f8f1bbdf 100644 --- a/src/i2c.cpp +++ b/src/i2c.cpp @@ -84,7 +84,7 @@ void i2c_scan(void) { } // mutexed functions for i2c r/w access -uint8_t i2c_readBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len) { +int i2c_readBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len) { if (I2C_MUTEX_LOCK()) { uint8_t ret = 0; @@ -112,7 +112,7 @@ uint8_t i2c_readBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len) { } } -uint8_t i2c_writeBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len) { +int i2c_writeBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len) { if (I2C_MUTEX_LOCK()) { uint8_t ret = 0; diff --git a/src/power.cpp b/src/power.cpp index 70c300dd..048a4385 100644 --- a/src/power.cpp +++ b/src/power.cpp @@ -46,6 +46,14 @@ void AXP192_powerevent_IRQ(void) { ESP_LOGI(TAG, "Battery high temperature."); if (pmu.isBattTempHighIRQ()) ESP_LOGI(TAG, "Battery low temperature."); + if (pmu.isLowVoltageLevel1IRQ()) { + ESP_LOGI(TAG, "Battery has reached voltage level 1."); + pmu.setChgLEDMode(AXP20X_LED_BLINK_4HZ); + } + if (pmu.isLowVoltageLevel2IRQ()) { + ESP_LOGI(TAG, "Battery has reached voltage level 2."); + pmu.setChgLEDMode(AXP20X_LED_BLINK_1HZ); + } // short press -> esp32 deep sleep mode, can be exited by pressing user button if (pmu.isPEKShortPressIRQ()) { @@ -129,10 +137,15 @@ void AXP192_init(void) { pmu.setLDO2Voltage(3300); // LORA VDD 3v3 pmu.setLDO3Voltage(3300); // GPS VDD 3v3 + // configure voltage warning levels + pmu.setVWarningLevel1(3600); + pmu.setVWarningLevel2(3800); + pmu.setPowerDownVoltage(3300); + // configure PEK button settings pmu.setTimeOutShutdown(false); // forced shutdown by PEK enabled pmu.setShutdownTime( - AXP_POWER_OFF_TIME_65); // 6 sec button press for shutdown + AXP_POWER_OFF_TIME_6S); // 6 sec button press for shutdown pmu.setlongPressTime( AXP_LONGPRESS_TIME_1S5); // 1.5 sec button press for long press pmu.setStartupTime( diff --git a/src/rcommand.cpp b/src/rcommand.cpp index d39ba1f3..c902a9d5 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -166,7 +166,7 @@ void set_payloadmask(uint8_t val[]) { void set_sensor(uint8_t val[]) { #if (HAS_SENSORS) - switch (val[0]) { // check if valid sensor number 1...4 + switch (val[0]) { // check if valid sensor number 1..3 case 1: case 2: case 3: