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
Only use serial crsf battery sensor if detected #1968
Only use serial crsf battery sensor if detected #1968
Conversation
@@ -74,5 +76,6 @@ class Telemetry | |||
bool callEnterBind; | |||
bool callUpdateModelMatch; | |||
bool sendDeviceFrame; | |||
bool crsfBatterySensorDetected; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could be wrong, but its probably not the best practice to assume this bool will initialise to false...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C++ guarantees that variables are created with a specific initial value. And for booleans that is the false
value 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats not what 5mins on stackoverflow taught me, but fair enough. I was always told that member vars should always be initialised (i.e. in the class constructor etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im happy to change it just for the readability. But there are multiple instances that should be updated and probably not as part of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, you are right Wez, only globals are automatically set to defaults.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving this on the assumption that the un-initialised bool is working fine, given there are plenty of other examples in the code where it seems to be.
If a receiver contains an internal battery sensor, and a user also connects a FC with vbat tlm, then they will both be sent to the handset. This may cause confusion with the numbers being displayed, or alarms configured.
This PR disables devAnalogVbat (the internal battery sensor) if a serial crsf battery sensor is detected.