Browse Source

v28 优化电池电量

master
zhaohe 1 year ago
parent
commit
2517a005a3
  1. BIN
      522728-520 0.5C放电曲线2.xls
  2. 3
      README.md
  3. 2
      app/src/basic/version.h
  4. 2
      app/src/board/board.h
  5. 63
      app/src/board/board_battery_state.c
  6. 15484
      release/V28/three_lead_ecg_v28.hex
  7. BIN
      release/V28/three_lead_ecg_v28.zip
  8. 35
      scripter/build_app.bat
  9. 35
      scripter/flash.bat

BIN
522728-520 0.5C放电曲线2.xls

3
README.md

@ -1,6 +1,9 @@
# three_lead_ecg_v2
```
V28:
1.优化电池电量
V27:
1.修复最大记录时间为 (72小时-1s)的BUG

2
app/src/basic/version.h

@ -2,7 +2,7 @@
#define CATEGORY "M1002" // Èýµ¼Áª
#define MANUFACTURER_NAME "iflytop"
#define FIRMWARE_VERSION (27)
#define FIRMWARE_VERSION (28)
#define BLESTACK_VERSION 1
#define BOOTLOADER_VERSION 1
#define HARDWARE_VERSION (1)

2
app/src/board/board.h

@ -75,6 +75,6 @@
#define APP_LOW_BATTERY_LIMIT 2 // 低电量关机阈值
#define APP_LOW_BATTERY_POWER_ON_LIMIT 8 // 是否能开机判定阈值
#define APP_LOW_BATTERY_WARNING_LIMIT 10 // 低电量事件上报阈值
#define APP_LOW_BATTERY_WARNING_LIMIT 20 // 低电量事件上报阈值
#define BLE_UNCONNECTED_OVERTIME_S 300 // 蓝牙未连接_心跳超时判定时间 300s

63
app/src/board/board_battery_state.c

@ -26,29 +26,68 @@ int16_t BoardBattery_get_adc_val() {
int16_t val = znrf_adc_channel_read_val(BATTERY_ADC_CHANNEL);
return val;
}
// int16_t BoardBattery_get_battery_level() {
// static const float maxv = 4.3;
// static const float minv = 3.3;
// int16_t rawval = BoardBattery_get_adc_val();
// //TODO:使3.6
// float voltage = rawval / 4096.0 * 3.6 / 2.0 * 3;
// if (voltage > maxv) voltage = maxv;
// if (voltage < minv) voltage = minv;
// float percent = (voltage - minv) / (maxv - minv) * 100 + (float)0.1 /*加0.1是为了避免999.999时显示电量为90*/;
// int16_t percent_int = (int16_t)percent;
// if (percent_int < 0) {
// percent_int = 0;
// } else if (percent_int > 100) {
// percent_int = 100;
// }
// // ZLOGI("%d voltage:%d, percent:%d",rawval, (int)voltage, percent_int);
// // // if (percent_int < 10 && percent_int != 0) {
// // // percent_int = 3;
// // // } else {
// // // percent_int = percent_int / 10 * 10;
// // // }
// return percent_int;
// // return percent_int;
// }
static int16_t battery_level_filter(int16_t nowlevel) {
static int16_t lastlevel = 0;
if (abs(nowlevel - lastlevel) >= 5) {
lastlevel = nowlevel;
} else if (nowlevel >= 95) {
lastlevel = 100;
} else if (nowlevel <= 5) {
lastlevel = nowlevel;
}
int16_t retlevel = lastlevel;
retlevel = retlevel / 5 * 5;
return retlevel;
}
int16_t BoardBattery_get_battery_level() {
static const float maxv = 4.0;
static const float minv = 3.3;
static const float maxv = 4.3;
static const float minv = 3.6;
int16_t rawval = BoardBattery_get_adc_val();
//TODO:使3.6
float voltage = rawval / 4096.0 * 3.6 / 2.0 * 3;
if (voltage > maxv) voltage = maxv;
if (voltage < minv) voltage = minv;
float percent = (voltage - minv) / (maxv - minv) * 100 + (float)0.1 /*加0.1是为了避免999.999时显示电量为90*/;
int16_t percent_int = (int16_t)percent;
// if (battery_get_chargeing_state()) {
// percent_int = percent_int - 10;
// }
if (percent_int < 0) {
percent_int = 0;
} else if (percent_int > 100) {
percent_int = 100;
}
// ZLOGI("%d voltage:%d, percent:%d",rawval, (int)voltage, percent_int);
// // if (percent_int < 10 && percent_int != 0) {
// // percent_int = 3;
// // } else {
// // percent_int = percent_int / 10 * 10;
// // }
return percent_int;
return battery_level_filter(percent_int);
// return percent_int;
}

15484
release/V28/three_lead_ecg_v28.hex
File diff suppressed because it is too large
View File

BIN
release/V28/three_lead_ecg_v28.zip

35
scripter/build_app.bat

@ -56,38 +56,3 @@ del output\app.hex
copy /y output\app.zip output\three_lead_ecg.zip
copy /y output\app_whole.hex output\three_lead_ecg.hex
echo "Start flashing..."
call scripter\unlock.bat
@REM 烧录整体镜像
nrfjprog --eraseall -f NRF52 %全擦除%
if %errorlevel% neq 0 (
echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
echo E 擦除失败 E
echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
exit /b 1
)
nrfjprog --program output/app_whole.hex --verify -f NRF52 %烧录%
if %errorlevel% neq 0 (
echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
echo E 烧录失败 E
echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
exit /b 1
)
nrfjprog --reset -f NRF52 %复位%
if %errorlevel% neq 0 (
echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
echo E 复位失败 E
echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
exit /b 1
)
echo ---------------------------------------------------------------
echo - done
echo ---------------------------------------------------------------

35
scripter/flash.bat

@ -0,0 +1,35 @@
echo "Start flashing..."
call scripter\unlock.bat
@REM 烧录整体镜像
nrfjprog --eraseall -f NRF52 %全擦除%
if %errorlevel% neq 0 (
echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
echo E 擦除失败 E
echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
exit /b 1
)
nrfjprog --program output/app_whole.hex --verify -f NRF52 %烧录%
if %errorlevel% neq 0 (
echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
echo E 烧录失败 E
echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
exit /b 1
)
nrfjprog --reset -f NRF52 %复位%
if %errorlevel% neq 0 (
echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
echo E 复位失败 E
echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
exit /b 1
)
echo ---------------------------------------------------------------
echo - done
echo ---------------------------------------------------------------
Loading…
Cancel
Save