From 2ef014db0f757edf4400911a4606ecb70345c961 Mon Sep 17 00:00:00 2001 From: richardclli Date: Fri, 23 Aug 2024 09:27:24 +0800 Subject: [PATCH] fix(flysky): battery charging animation and other timing issues (#5471) --- radio/src/targets/nv14/battery_driver.cpp | 8 ++++---- radio/src/targets/nv14/board.cpp | 4 ++-- radio/src/targets/nv14/board.h | 2 +- radio/src/targets/nv14/touch_driver.cpp | 4 ++-- radio/src/targets/pl18/battery_driver.cpp | 8 ++++---- radio/src/targets/pl18/board.cpp | 4 ++-- radio/src/targets/pl18/board.h | 2 +- radio/src/targets/pl18/touch_driver.cpp | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/radio/src/targets/nv14/battery_driver.cpp b/radio/src/targets/nv14/battery_driver.cpp index ecbe685cb..772be5a2a 100644 --- a/radio/src/targets/nv14/battery_driver.cpp +++ b/radio/src/targets/nv14/battery_driver.cpp @@ -136,7 +136,7 @@ void drawChargingInfo(uint16_t chargeState) BATTERY_CONNECTOR_H, SOLID, COLOR_THEME_PRIMARY2); } -#define CHARGE_INFO_DURATION 500 +#define CHARGE_INFO_DURATION 5000 // ms //this method should be called by timer interrupt or by GPIO interrupt void handle_battery_charge(uint32_t last_press_time) @@ -147,7 +147,7 @@ void handle_battery_charge(uint32_t last_press_time) static uint32_t info_until = 0; static bool lcdInited = false; - uint32_t now = get_tmr10ms(); + uint32_t now = timersGetMsTick(); uint16_t chargeState = get_battery_charge_state(); if(chargeState != CHARGE_UNKNOWN) { @@ -175,7 +175,7 @@ void handle_battery_charge(uint32_t last_press_time) return; } - if(updateTime == 0 || ((get_tmr10ms() - updateTime) >= 50)) + if(updateTime == 0 || ((timersGetMsTick() - updateTime) >= 500)) { if(!lcdInited) { lcdInitDisplayDriver(); @@ -184,7 +184,7 @@ void handle_battery_charge(uint32_t last_press_time) else { lcdOn(); } - updateTime = get_tmr10ms(); + updateTime = timersGetMsTick(); lcdInitDirectDrawing(); drawChargingInfo(chargeState); lcdRefresh(); diff --git a/radio/src/targets/nv14/board.cpp b/radio/src/targets/nv14/board.cpp index c1fe4e77d..4825668d7 100644 --- a/radio/src/targets/nv14/board.cpp +++ b/radio/src/targets/nv14/board.cpp @@ -144,7 +144,7 @@ void boardInit() usb_state |= usbPlugged(); while (usb_state) { pwrOn(); - uint32_t now = get_tmr10ms(); + uint32_t now = timersGetMsTick(); if (pwrPressed()) { press_end = now; if (press_start == 0) press_start = now; @@ -160,7 +160,7 @@ void boardInit() uint32_t press_end_touch = press_end; if (touchPanelEventOccured()) { touchPanelRead(); - press_end_touch = get_tmr10ms(); + press_end_touch = timersGetMsTick(); } press_start = 0; handle_battery_charge(press_end_touch); diff --git a/radio/src/targets/nv14/board.h b/radio/src/targets/nv14/board.h index a363045bf..e19af17ef 100644 --- a/radio/src/targets/nv14/board.h +++ b/radio/src/targets/nv14/board.h @@ -123,7 +123,7 @@ extern "C" { // Power driver #define SOFT_PWR_CTRL -#define POWER_ON_DELAY 10 // 1s +#define POWER_ON_DELAY 100 // ms void pwrInit(); void extModuleInit(); uint32_t pwrCheck(); diff --git a/radio/src/targets/nv14/touch_driver.cpp b/radio/src/targets/nv14/touch_driver.cpp index e72a4f8c9..e79ba84ac 100644 --- a/radio/src/targets/nv14/touch_driver.cpp +++ b/radio/src/targets/nv14/touch_driver.cpp @@ -50,7 +50,7 @@ static tc_handle_TypeDef tc_handle = {0, 0}; tmr10ms_t downTime = 0; tmr10ms_t tapTime = 0; short tapCount = 0; -#define TAP_TIME 25 +#define TAP_TIME 250 // 250 ms struct TouchControllerDescriptor { @@ -463,7 +463,7 @@ TouchState touchPanelRead() touchEventOccured = false; - tmr10ms_t now = get_tmr10ms(); + uint32_t now = timersGetMsTick(); internalTouchState.tapCount = 0; if (tc->detectTouch()) { diff --git a/radio/src/targets/pl18/battery_driver.cpp b/radio/src/targets/pl18/battery_driver.cpp index 18b113262..f0ad2a93e 100644 --- a/radio/src/targets/pl18/battery_driver.cpp +++ b/radio/src/targets/pl18/battery_driver.cpp @@ -352,7 +352,7 @@ void drawChargingInfo(uint16_t chargeState) { lcd->drawFilledRect((LCD_W - BATTERY_W_INNER) / 2, BATTERY_TOP_INNER + BATTERY_H_INNER - h, BATTERY_W_INNER, h, SOLID, color); lcd->drawFilledRect((LCD_W - BATTERY_CONNECTOR_W) / 2, BATTERY_TOP - BATTERY_CONNECTOR_H, BATTERY_CONNECTOR_W, BATTERY_CONNECTOR_H, SOLID, COLOR_THEME_PRIMARY2); } -#define CHARGE_INFO_DURATION 500 +#define CHARGE_INFO_DURATION 5000 // ms //this method should be called by timer interrupt or by GPIO interrupt void handle_battery_charge(uint32_t last_press_time) @@ -363,7 +363,7 @@ void handle_battery_charge(uint32_t last_press_time) static uint32_t info_until = 0; static bool lcdInited = false; - uint32_t now = get_tmr10ms(); + uint32_t now = timersGetMsTick(); uint16_t chargeState = get_battery_charge_state(); if (chargeState != CHARGE_UNKNOWN) { @@ -381,9 +381,9 @@ void handle_battery_charge(uint32_t last_press_time) lastState = chargeState; } - if (updateTime == 0 || ((get_tmr10ms() - updateTime) >= 50)) + if (updateTime == 0 || ((timersGetMsTick() - updateTime) >= 500)) { - updateTime = get_tmr10ms(); + updateTime = timersGetMsTick(); ledChargingInfo(chargeState); if(now > info_until) { diff --git a/radio/src/targets/pl18/board.cpp b/radio/src/targets/pl18/board.cpp index 5013da46f..d56a847a1 100644 --- a/radio/src/targets/pl18/board.cpp +++ b/radio/src/targets/pl18/board.cpp @@ -130,7 +130,7 @@ void boardInit() } else if (isChargerActive()) { while (true) { pwrOn(); - uint32_t now = get_tmr10ms(); + uint32_t now = timersGetMsTick(); if (pwrPressed()) { press_end = now; if (press_start == 0) press_start = now; @@ -143,7 +143,7 @@ void boardInit() uint32_t press_end_touch = press_end; if (touchPanelEventOccured()) { touchPanelRead(); - press_end_touch = get_tmr10ms(); + press_end_touch = timersGetMsTick(); } press_start = 0; handle_battery_charge(press_end_touch); diff --git a/radio/src/targets/pl18/board.h b/radio/src/targets/pl18/board.h index 1f4ac4d35..d05b45a7b 100644 --- a/radio/src/targets/pl18/board.h +++ b/radio/src/targets/pl18/board.h @@ -102,7 +102,7 @@ extern "C" { // Power driver #define SOFT_PWR_CTRL -#define POWER_ON_DELAY 10 // 1s +#define POWER_ON_DELAY 100 // ms void pwrInit(); void extModuleInit(); uint32_t pwrCheck(); diff --git a/radio/src/targets/pl18/touch_driver.cpp b/radio/src/targets/pl18/touch_driver.cpp index 1815b2908..8e09f810b 100644 --- a/radio/src/targets/pl18/touch_driver.cpp +++ b/radio/src/targets/pl18/touch_driver.cpp @@ -35,7 +35,7 @@ #include "debug.h" -#define TAP_TIME 25 +#define TAP_TIME 250 // 250 ms #define I2C_TIMEOUT_MAX 5 // 5 ms // FT6236 definitions @@ -348,7 +348,7 @@ struct TouchState touchPanelRead() touchEventOccured = false; - tmr10ms_t now = get_tmr10ms(); + uint32_t now = timersGetMsTick(); internalTouchState.tapCount = 0; unsigned short touchX; unsigned short touchY;