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

SPI ELRS: Add bind the receiver with power-cycle 3 times #13475

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Linjieqiang
Copy link
Contributor

Because some flight controllers do not have a reserved binding button, convenient binding cannot be performed outdoors. This idea comes from the ELRS external receiver.

Copy link

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

  • Simply put #13475 (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!

@Linjieqiang Linjieqiang changed the title SPI ELRS: Added three power on and off to bind the rx SPI ELRS: Add bind the receiver with power-cycle 3 times Mar 23, 2024
Copy link
Member

@SteveCEvans SteveCEvans left a comment

Choose a reason for hiding this comment

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

This will hammer the flash memory. Perhaps gate this behaviour using ‎USE_PERSISTENT_STATS?

@Linjieqiang
Copy link
Contributor Author

Sorry, can you be more specific?

@SteveCEvans
Copy link
Member

Put #ifdef USE_PERSISTENT_STATS around your code.

Because there is no reserved bind button.
@Linjieqiang Linjieqiang force-pushed the add_elrs_bind_with_three_power branch from b379a9a to eaa05e2 Compare March 23, 2024 15:20
@haslinghuis
Copy link
Member

Needs increasing PG version to 1:

PG_REGISTER_WITH_RESET_TEMPLATE(rxExpressLrsSpiConfig_t, rxExpressLrsSpiConfig, PG_RX_EXPRESSLRS_SPI_CONFIG, 0);

@haslinghuis
Copy link
Member

@SteveCEvans USE_PERSISTENT_STATS is always defined in common_pre.h

  • Testing can lead to configuration lost as I think premature power recycling will make the eeprom write non-atomic.
  • Also have used this function before without this PR.
  • Any ideas to fix this?

Currently not have access to my ELRS TX - so waiting for delivery.

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
@Linjieqiang
Copy link
Contributor Author

How? @SteveCEvans @haslinghuis Could you help me take a look?

@haslinghuis
Copy link
Member

Finally got a new radio with ELRS TX to test binding using the 3 power cycles method - which failed.
It's important to reset the expresslrs_uid to 0,0,0,0,0,0 before every retry.

Using the bind RX button in configurator I was able to bind with the SPI ELRS receiver without the code in the PR.
Set the packet rate mode from F1000 to 250Hz in between - so that might be of influence.

@Linjieqiang
Copy link
Contributor Author

So I need to set the UID to 0, 0, 0, 0, 0, 0. That’s it, but occasionally the problem of losing all flash occurs. @haslinghuis

@ledvinap
Copy link
Contributor

As written, it will overwrite config every power-up, even when receiver is already bound. At least gate it by receiver not detected before increasing counter.

Much more useful would be gesture-based actions - wait for IMU calibration/stabilization, than start recognizing user gestures. For example roll-90-left, flat, roll-90-left, flat, pitch-90-up, flat (for right-handed people) could trigger binding (probably set binding flag and reboot). Hard to bind by mistake, easy to trigger (and we can add more gestures eventually)

@Linjieqiang
Copy link
Contributor Author

As written, it will overwrite config every power-up, even when receiver is already bound. At least gate it by receiver not detected before increasing counter.

Much more useful would be gesture-based actions - wait for IMU calibration/stabilization, than start recognizing user gestures. For example roll-90-left, flat, roll-90-left, flat, pitch-90-up, flat (for right-handed people) could trigger binding (probably set binding flag and reboot). Hard to bind by mistake, easy to trigger (and we can add more gestures eventually)

So how to fix it? I want add this feature in it.

@ledvinap
Copy link
Contributor

@Linjieqiang: You should probably write user documentation how to use this feature first. Just a draft here as comment should do. It will be then easier to comment code.

At least gate it by receiver not detected before increasing counter.

Do not increment count immediately after boot, but after delay. This dlay should be long enough for bound receiver to provide data. If RC is receiving data at this time, do not modify counter (or reset it to zero it is not reset).

Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within a week.

@github-actions github-actions bot added the Inactive Automatically detected and labeled, will be closed after another week of inactivity. label May 23, 2024
@Linjieqiang
Copy link
Contributor Author

Need to finish it...

@github-actions github-actions bot removed the Inactive Automatically detected and labeled, will be closed after another week of inactivity. label May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants