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

Add packetSnrRaw method to avoid floating-point #570

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

Conversation

ZacJW
Copy link

@ZacJW ZacJW commented Mar 12, 2022

This patch is motivated by a well known (#459, #460) limitation, that ESP microcontrollers can't use float LoRa.packetSnr() in ISR because that method performs a floating point operation.

My proposed solution is to add a method int LoRa.packetSnrRaw() that returns the REG_PKT_SNR_VALUE register as an int unmodified, rather than as a float divided by 4. I've written documentation for it noting that since it forgoes the division by 4, its value is 4 times the actual SNR.

Some microcontrollers cannot use their floating-point coprocessor during
interrupts (e.g. ESP32) which means they can't use the packetSnr
method. packetSnrRaw allows the user to forgo the `* 0.25` in such cases
@torntrousers
Copy link
Contributor

@ZacJW
Copy link
Author

ZacJW commented Mar 12, 2022

My thought is to leave it up to the user. I would like to keep the full precision of it, but I'd accept the loss of 2 bits.

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.

2 participants