1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 12:55:19 +03:00

Corrected missed USE_ACC logic and some minor cleanup (#14093)

This commit is contained in:
Jay Blackman 2024-12-21 01:22:22 +11:00 committed by GitHub
parent f27da4ed8d
commit 7dec49ce42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 13 additions and 5 deletions

View file

@ -46,14 +46,20 @@
#define CM_S_TO_KM_H(centimetersPerSecond) ((centimetersPerSecond) * 36 / 1000)
#define CM_S_TO_MPH(centimetersPerSecond) ((centimetersPerSecond) * 10000 / 5080 / 88)
#ifndef MIN
#define MIN(a,b) \
__extension__ ({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })
#endif
#ifndef MAX
#define MAX(a,b) \
__extension__ ({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
#endif
#define ABS(x) \
__extension__ ({ __typeof__ (x) _x = (x); \
_x > 0 ? _x : -_x; })

View file

@ -1328,7 +1328,7 @@ void FAST_CODE pidController(const pidProfile_t *pidProfile, timeUs_t currentTim
float pidSetpointDelta = 0;
#ifdef USE_FEEDFORWARD
#if defined(USE_FEEDFORWARD) && defined(USE_ACC)
if (FLIGHT_MODE(ANGLE_MODE) && pidRuntime.axisInAngleMode[axis]) {
// this axis is fully under self-levelling control
// it will already have stick based feedforward applied in the input to their angle setpoint

View file

@ -397,8 +397,9 @@ void pidInitConfig(const pidProfile_t *pidProfile)
}
pidRuntime.angleGain = pidProfile->pid[PID_LEVEL].P / 10.0f;
pidRuntime.angleFeedforwardGain = pidProfile->pid[PID_LEVEL].F / 100.0f;
#ifdef USE_ACC
pidRuntime.angleEarthRef = pidProfile->angle_earth_ref / 100.0f;
#endif
pidRuntime.horizonGain = MIN(pidProfile->pid[PID_LEVEL].I / 100.0f, 1.0f);
pidRuntime.horizonIgnoreSticks = (pidProfile->horizon_ignore_sticks) ? 1.0f : 0.0f;
@ -406,7 +407,9 @@ void pidInitConfig(const pidProfile_t *pidProfile)
pidRuntime.horizonLimitSticksInv = (pidProfile->pid[PID_LEVEL].D) ? 1.0f / pidRuntime.horizonLimitSticks : 1.0f;
pidRuntime.horizonLimitDegrees = (float)pidProfile->horizon_limit_degrees;
pidRuntime.horizonLimitDegreesInv = (pidProfile->horizon_limit_degrees) ? 1.0f / pidRuntime.horizonLimitDegrees : 1.0f;
#ifdef USE_ACC
pidRuntime.horizonDelayMs = pidProfile->horizon_delay_ms;
#endif
pidRuntime.maxVelocity[FD_ROLL] = pidRuntime.maxVelocity[FD_PITCH] = pidProfile->rateAccelLimit * 100 * pidRuntime.dT;
pidRuntime.maxVelocity[FD_YAW] = pidProfile->yawRateAccelLimit * 100 * pidRuntime.dT;

View file

@ -34,7 +34,6 @@
#include "drivers/adc.h"
#include "drivers/io.h"
#include "drivers/io_def.h"
#include "drivers/io_types.h"
#include "drivers/resource.h"
#include "drivers/rx/rx_cc2500.h"

View file

@ -34,7 +34,6 @@
#include "config/feature.h"
#include "drivers/adc.h"
#include "drivers/io.h"
#include "drivers/io_def.h"
#include "drivers/io_types.h"
#include "drivers/resource.h"
#include "drivers/rx/rx_cc2500.h"

View file

@ -83,7 +83,7 @@ timeUs_t RcStatsGetFullThrottleTimeUs(void)
int8_t RcStatsGetAverageThrottle(void)
{
return (float)totalTrottleNumber/(float)counter + 0.5; // rounding
return (float)totalTrottleNumber/(float)counter + 0.5f; // rounding
}
void NotifyRcStatsArming(void)

View file

@ -445,6 +445,7 @@ uint32_t clockMicrosToCycles(uint32_t micros)
{
return micros;
}
uint32_t getCycleCounter(void)
{
return (uint32_t) (micros64() & 0xFFFFFFFF);