Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions radio/src/targets/nv14/battery_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {

Expand Down Expand Up @@ -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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change the 500 to a constant, rather than a magic number for half second? ;) For both NV14/PL18, etc... can be in the common PR if not already there...

{
if(!lcdInited) {
lcdInitDisplayDriver();
Expand All @@ -184,7 +184,7 @@ void handle_battery_charge(uint32_t last_press_time)
else {
lcdOn();
}
updateTime = get_tmr10ms();
updateTime = timersGetMsTick();
lcdInitDirectDrawing();
drawChargingInfo(chargeState);
lcdRefresh();
Expand Down
4 changes: 2 additions & 2 deletions radio/src/targets/nv14/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion radio/src/targets/nv14/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions radio/src/targets/nv14/touch_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -463,7 +463,7 @@ TouchState touchPanelRead()

touchEventOccured = false;

tmr10ms_t now = get_tmr10ms();
uint32_t now = timersGetMsTick();
internalTouchState.tapCount = 0;

if (tc->detectTouch()) {
Expand Down
8 changes: 4 additions & 4 deletions radio/src/targets/pl18/battery_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {

Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions radio/src/targets/pl18/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion radio/src/targets/pl18/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions radio/src/targets/pl18/touch_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down