fix(flysky): battery charging animation and other timing issues (#5471)

This commit is contained in:
richardclli
2024-08-23 11:27:24 +10:00
committed by GitHub
parent e0ec49d84e
commit 2ef014db0f
8 changed files with 18 additions and 18 deletions
+4 -4
View File
@@ -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();
+2 -2
View File
@@ -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);
+1 -1
View File
@@ -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();
+2 -2
View File
@@ -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()) {
+4 -4
View File
@@ -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) {
+2 -2
View File
@@ -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);
+1 -1
View File
@@ -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();
+2 -2
View File
@@ -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;