Use defines instead of hardcoded magic values for maximum number of output channels and rpm filter time constant

This commit is contained in:
Matthias Grob
2024-12-19 07:30:25 +01:00
parent 8ce6ad6662
commit b85ad98a98
5 changed files with 7 additions and 5 deletions
+2 -2
View File
@@ -59,7 +59,7 @@ bool RPMCapture::init()
{
bool success = false;
for (unsigned i = 0; i < 16; ++i) {
for (unsigned i = 0; i < PWM_OUTPUT_MAX_CHANNELS; ++i) {
char param_name[17];
snprintf(param_name, sizeof(param_name), "%s_%s%d", PARAM_PREFIX, "FUNC", i + 1);
param_t function_handle = param_find(param_name);
@@ -138,7 +138,7 @@ void RPMCapture::Run()
// Don't update RPM filter with outliers
const float dt = math::min((now - _timestamp_last_update) * 1e-6f, 1.f);
_timestamp_last_update = now;
_rpm_filter.setParameters(dt, 0.5f);
_rpm_filter.setParameters(dt, RPM_FILTER_TIME_CONSTANT);
_rpm_filter.update(_rpm_median_filter.apply(rpm_raw));
}
+1
View File
@@ -72,6 +72,7 @@ public:
private:
static constexpr hrt_abstime RPM_PULSE_TIMEOUT = 1_s;
static constexpr float RPM_MAX_VALUE = 50e3f;
static constexpr float RPM_FILTER_TIME_CONSTANT = .5f;
void Run() override;