-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix disabling sensor configuration (when device needs battery power) #13177
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1b944ad
Fix sensor config
haslinghuis 2cbd1ae
Encapsulate code
haslinghuis 3212b8a
Add new message for detectedSensors
haslinghuis 3abcd0c
Add SENSOR_NOT_AVAILABLE
haslinghuis af3b001
Move comment
haslinghuis 2731503
Add gyro
haslinghuis File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2049,24 +2049,21 @@ case MSP_NAME: | |
sbufWriteU8(dst, currentPidProfile->tpa_rate); | ||
sbufWriteU16(dst, currentPidProfile->tpa_breakpoint); // was currentControlRateProfile->tpa_breakpoint | ||
break; | ||
|
||
case MSP_SENSOR_CONFIG: | ||
// if sensor name is default setting, use name in runtime config | ||
// use sensorIndex_e index: 0:GyroHardware, 1:AccHardware, 2:BaroHardware, 3:MagHardware, 4:RangefinderHardware | ||
#if defined(USE_ACC) | ||
// Changed with API 1.46 | ||
sbufWriteU8(dst, accelerometerConfig()->acc_hardware == ACC_DEFAULT ? detectedSensors[1] : accelerometerConfig()->acc_hardware); | ||
sbufWriteU8(dst, accelerometerConfig()->acc_hardware); | ||
#else | ||
sbufWriteU8(dst, 0); | ||
sbufWriteU8(dst, ACC_NONE); | ||
#endif | ||
#ifdef USE_BARO | ||
// Changed with API 1.46 | ||
sbufWriteU8(dst, barometerConfig()->baro_hardware == BARO_DEFAULT ? detectedSensors[2] : barometerConfig()->baro_hardware); | ||
sbufWriteU8(dst, barometerConfig()->baro_hardware); | ||
#else | ||
sbufWriteU8(dst, BARO_NONE); | ||
#endif | ||
#ifdef USE_MAG | ||
// Changed with API 1.46 | ||
sbufWriteU8(dst, compassConfig()->mag_hardware == MAG_DEFAULT ? detectedSensors[3] : compassConfig()->mag_hardware); | ||
sbufWriteU8(dst, compassConfig()->mag_hardware); | ||
#else | ||
sbufWriteU8(dst, MAG_NONE); | ||
#endif | ||
|
@@ -2078,6 +2075,31 @@ case MSP_NAME: | |
#endif | ||
break; | ||
|
||
case MSP2_SENSOR_CONFIG_ACTIVE: | ||
// use sensorIndex_e index: 0:GyroHardware, 1:AccHardware, 2:BaroHardware, 3:MagHardware, 4:RangefinderHardware | ||
#if defined(USE_ACC) | ||
sbufWriteU8(dst, detectedSensors[SENSOR_INDEX_ACC]); | ||
#else | ||
sbufWriteU8(dst, ACC_NONE); | ||
#endif | ||
#ifdef USE_BARO | ||
sbufWriteU8(dst, detectedSensors[SENSOR_INDEX_BARO]); | ||
#else | ||
sbufWriteU8(dst, BARO_NONE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd send special 'SENSOR_NOT_AVAILABLE' value in this case - this is new code and it may be useful if configurator knows that sensor support is not enabled in firmware |
||
#endif | ||
#ifdef USE_MAG | ||
sbufWriteU8(dst, detectedSensors[SENSOR_INDEX_MAG]); | ||
#else | ||
sbufWriteU8(dst, MAG_NONE); | ||
#endif | ||
// Added in MSP API 1.46 | ||
#ifdef USE_RANGEFINDER | ||
sbufWriteU8(dst, detectedSensors[SENSOR_INDEX_RANGEFINDER]); | ||
#else | ||
sbufWriteU8(dst, RANGEFINDER_NONE); | ||
#endif | ||
break; | ||
|
||
#if defined(USE_VTX_COMMON) | ||
case MSP_VTX_CONFIG: | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This looks much better to me.
It may be possible to keep
detectedSensors
in format expected by configurator and just dump it. But it may cause problems on refactoring.