mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-12 19:10:32 +03:00
Fix inevitable timer overflow (#14374)
* Fix beacon timer overflow * fix possible overflow in rc_stats * fix possible overflow in mixer.c * fix possible overflow in osd.c * Update src/main/osd/osd_warnings.c Co-authored-by: Petr Ledvina <ledvinap@gmail.com> * Update src/main/osd/osd_warnings.c Co-authored-by: Petr Ledvina <ledvinap@gmail.com> * Update src/main/rx/rc_stats.c Co-authored-by: Petr Ledvina <ledvinap@gmail.com> * fix typo * Update src/main/osd/osd.c Co-authored-by: Petr Ledvina <ledvinap@gmail.com> --------- Co-authored-by: Petr Ledvina <ledvinap@gmail.com>
This commit is contained in:
parent
b03b57bd90
commit
aa8701ef87
4 changed files with 7 additions and 9 deletions
|
@ -219,7 +219,7 @@ static void calculateThrottleAndCurrentMotorEndpoints(timeUs_t currentTimeUs)
|
|||
throttle = 0;
|
||||
currentThrottleInputRange = rcCommandThrottleRange3dHigh;
|
||||
}
|
||||
if (currentTimeUs - reversalTimeUs < 250000) {
|
||||
if (cmpTimeUs(currentTimeUs, reversalTimeUs) < 250000) {
|
||||
// keep iterm zero for 250ms after motor reversal
|
||||
pidResetIterm();
|
||||
}
|
||||
|
|
|
@ -1243,7 +1243,7 @@ STATIC_UNIT_TESTED bool osdProcessStats1(timeUs_t currentTimeUs)
|
|||
|
||||
if (ARMING_FLAG(ARMED)) {
|
||||
osdUpdateStats();
|
||||
timeUs_t deltaT = currentTimeUs - lastTimeUs;
|
||||
int deltaT = cmpTimeUs(currentTimeUs, lastTimeUs);
|
||||
osdFlyTime += deltaT;
|
||||
stats.armed_time += deltaT;
|
||||
#ifdef USE_LAUNCH_CONTROL
|
||||
|
|
|
@ -115,12 +115,10 @@ void renderOsdWarning(char *warningText, bool *blinking, uint8_t *displayAttr)
|
|||
|
||||
#ifdef USE_DSHOT
|
||||
if (isTryingToArm() && !ARMING_FLAG(ARMED)) {
|
||||
int armingDelayTime = (getLastDshotBeaconCommandTimeUs() + DSHOT_BEACON_GUARD_DELAY_US - currentTimeUs) / 1e5;
|
||||
if (armingDelayTime < 0) {
|
||||
armingDelayTime = 0;
|
||||
}
|
||||
if (armingDelayTime >= (DSHOT_BEACON_GUARD_DELAY_US / 1e5 - 5)) {
|
||||
tfp_sprintf(warningText, " BEACON ON"); // Display this message for the first 0.5 seconds
|
||||
const int beaconGuard = cmpTimeUs(currentTimeUs, getLastDshotBeaconCommandTimeUs());
|
||||
const int armingDelayTime = MAX(DSHOT_BEACON_GUARD_DELAY_US - beaconGuard, 0) / 100000; // time remaining until BEACON_GUARD_DELAY, in tenths of second
|
||||
if (beaconGuard < 500 * 1000) { // first 0.5s since beacon
|
||||
tfp_sprintf(warningText, " BEACON ON");
|
||||
} else {
|
||||
tfp_sprintf(warningText, "ARM IN %d.%d", armingDelayTime / 10, armingDelayTime % 10);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ int8_t previousThrottlePercent = 0;
|
|||
|
||||
void rcStatsUpdate(timeUs_t currentTimeUs)
|
||||
{
|
||||
uint32_t deltaT = currentTimeUs - previousTimeUs;
|
||||
uint32_t deltaT = cmpTimeUs(currentTimeUs, previousTimeUs);
|
||||
previousTimeUs = currentTimeUs;
|
||||
const int8_t throttlePercent = calculateThrottlePercent();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue