mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 10:46:33 +08:00
commander: add option to exclude mag to param SYS_FAC_CAL_MODE
This commit is contained in:
@@ -239,7 +239,9 @@ PARAM_DEFINE_INT32(SYS_HAS_NUM_DIST, 0);
|
||||
* Note: this is only supported on boards with a separate calibration storage
|
||||
* /fs/mtd_caldata.
|
||||
*
|
||||
* @boolean
|
||||
* @value 0 Disabled
|
||||
* @value 1 All sensors
|
||||
* @value 2 All sensors except mag
|
||||
* @group System
|
||||
*/
|
||||
PARAM_DEFINE_INT32(SYS_FAC_CAL_MODE, 0);
|
||||
|
||||
@@ -43,6 +43,12 @@
|
||||
|
||||
static const char *CALIBRATION_STORAGE = "/fs/mtd_caldata";
|
||||
|
||||
enum class FactoryCalibrationMode : uint32_t {
|
||||
Disabled = 0,
|
||||
AllSensors,
|
||||
AllSensorsExceptMag,
|
||||
};
|
||||
|
||||
static bool ends_with(const char *str, const char *suffix)
|
||||
{
|
||||
if (!str || !suffix) {
|
||||
@@ -59,9 +65,18 @@ static bool ends_with(const char *str, const char *suffix)
|
||||
return strncmp(str + len_str - len_suffix, suffix, len_suffix) == 0;
|
||||
}
|
||||
|
||||
static FactoryCalibrationMode factory_calibration_mode{FactoryCalibrationMode::Disabled};
|
||||
|
||||
static bool filter_calibration_params(param_t handle)
|
||||
{
|
||||
const char *name = param_name(handle);
|
||||
|
||||
if (factory_calibration_mode == FactoryCalibrationMode::AllSensorsExceptMag) {
|
||||
if (strncmp(name, "CAL_MAG", 7) == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// filter all non-calibration params
|
||||
return (strncmp(name, "CAL_", 4) == 0
|
||||
&& strcmp(name, "CAL_MAG_SIDES") != 0
|
||||
@@ -73,7 +88,8 @@ FactoryCalibrationStorage::FactoryCalibrationStorage()
|
||||
{
|
||||
int32_t param = 0;
|
||||
param_get(param_find("SYS_FAC_CAL_MODE"), ¶m);
|
||||
_enabled = param == 1;
|
||||
_enabled = param >= 1;
|
||||
factory_calibration_mode = (FactoryCalibrationMode)param;
|
||||
}
|
||||
|
||||
int FactoryCalibrationStorage::open()
|
||||
|
||||
Reference in New Issue
Block a user