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

RX - minor optimizations/minor cleanup #13493

Merged
merged 2 commits into from Apr 23, 2024

Conversation

ledvinap
Copy link
Contributor

@ledvinap ledvinap commented Apr 3, 2024

  • reuse millis() in rxInit
  • rcData[] is float
  • cleanup some float math
  • fix GET_FRAME_ERR_LPF_FREQUENCY macro argument

- reuse millis() in rxInit
- rcData[] is float
- cleanup some float math
- fix GET_FRAME_ERR_LPF_FREQUENCY macro argument
Copy link

github-actions bot commented Apr 3, 2024

Do you want to test this code? You can flash it directly from Betaflight Configurator:

  • Simply put #13493 (this pull request number) in the Select commit field of the Configurator firmware flasher tab (you need to Enable expert mode, Show release candidates and Development).

WARNING: It may be unstable. Use only for testing!

src/main/pg/rx.h Outdated
@@ -24,7 +24,7 @@

#include "pg/pg.h"

#define GET_FRAME_ERR_LPF_FREQUENCY(period) (1 / (period / 10.0f))
#define GET_FRAME_ERR_LPF_FREQUENCY(period) (1.0f / ((period) * 0.1f/*[s]*/))
Copy link
Member

Choose a reason for hiding this comment

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

I guess the intent is that the LPF cutoff is set to ten times the inverse of the period ie 10Hz when period is 1s.
Perhaps it might be easier to conceptualise that relationship with:

define GET_FRAME_ERR_LPF_FREQUENCY(period) (10.0f / period)    // period is in seconds

Copy link
Contributor Author

Choose a reason for hiding this comment

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

uint8_t rssi_src_frame_lpf_period; // Period of the cutoff frequency for the source frame RSSI filter (in 0.1 s)

it is in 0.1s units

@ledvinap
Copy link
Contributor Author

Can we get this merged? Except for not calling millis() multiple times, this PR makes not functional changes.

@nerdCopter
Copy link
Member

for my understanding, is the uint32_t now = millis(); a one-time occurrence at init only, or continuous?

@ledvinap
Copy link
Contributor Author

for my understanding, is the uint32_t now = millis(); a one-time occurrence at init only, or continuous?

It is used to initialize RC channel timeouts. Old code called millis() for each channel, now single timestamp is used in loop. The loop runs once, on RC initialization (rxInit).

@haslinghuis haslinghuis modified the milestones: 4.6, 4.5 Apr 17, 2024
src/main/pg/rx.h Outdated Show resolved Hide resolved
Co-authored-by: Jan Post <Rm2k-Freak@web.de>
@haslinghuis haslinghuis merged commit 7bf3928 into betaflight:master Apr 23, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: COMPLETED
Development

Successfully merging this pull request may close these issues.

None yet

6 participants