mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 05:23:34 +08:00
param: add param_notify_changes() method
Can be used for example after several calls to param_set_no_notification() to avoid unnecessary system notifications, as it is an expensive change.
This commit is contained in:
@@ -236,7 +236,7 @@ param_find_changed(param_t param)
|
||||
}
|
||||
|
||||
static void
|
||||
param_notify_changes(bool is_saved)
|
||||
_param_notify_changes(bool is_saved)
|
||||
{
|
||||
#if !defined(PARAM_NO_ORB)
|
||||
struct parameter_update_s pup = {
|
||||
@@ -258,6 +258,12 @@ param_notify_changes(bool is_saved)
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
param_notify_changes(void)
|
||||
{
|
||||
_param_notify_changes(true);
|
||||
}
|
||||
|
||||
param_t
|
||||
param_find_internal(const char *name, bool notification)
|
||||
{
|
||||
@@ -601,7 +607,7 @@ out:
|
||||
* a thing has been set.
|
||||
*/
|
||||
if (params_changed && notify_changes) {
|
||||
param_notify_changes(is_saved);
|
||||
_param_notify_changes(is_saved);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -687,7 +693,7 @@ param_reset(param_t param)
|
||||
param_unlock();
|
||||
|
||||
if (s != NULL) {
|
||||
param_notify_changes(false);
|
||||
_param_notify_changes(false);
|
||||
}
|
||||
|
||||
return (!param_found);
|
||||
@@ -707,7 +713,7 @@ param_reset_all(void)
|
||||
|
||||
param_unlock();
|
||||
|
||||
param_notify_changes(false);
|
||||
_param_notify_changes(false);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -739,7 +745,7 @@ param_reset_excludes(const char *excludes[], int num_excludes)
|
||||
|
||||
param_unlock();
|
||||
|
||||
param_notify_changes(false);
|
||||
_param_notify_changes(false);
|
||||
}
|
||||
|
||||
static const char *param_default_file = PX4_ROOTFSDIR"/eeprom/parameters";
|
||||
|
||||
@@ -236,6 +236,12 @@ __EXPORT int param_set_no_autosave(param_t param, const void *val);
|
||||
*/
|
||||
__EXPORT int param_set_no_notification(param_t param, const void *val);
|
||||
|
||||
/**
|
||||
* Notify the system about parameter changes. Can be used for example after several calls to
|
||||
* param_set_no_notification() to avoid unnecessary system notifications.
|
||||
*/
|
||||
__EXPORT void param_notify_changes(void);
|
||||
|
||||
/**
|
||||
* Reset a parameter to its default value.
|
||||
*
|
||||
|
||||
@@ -246,8 +246,8 @@ param_find_changed(param_t param)
|
||||
return s;
|
||||
}
|
||||
|
||||
static void
|
||||
param_notify_changes(bool is_saved)
|
||||
void
|
||||
_param_notify_changes(bool is_saved)
|
||||
{
|
||||
struct parameter_update_s pup = { .timestamp = hrt_absolute_time(), .saved = is_saved };
|
||||
|
||||
@@ -263,6 +263,13 @@ param_notify_changes(bool is_saved)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
param_notify_changes(void)
|
||||
{
|
||||
_param_notify_changes(true);
|
||||
}
|
||||
|
||||
|
||||
param_t
|
||||
param_find_internal(const char *name, bool notification)
|
||||
{
|
||||
@@ -643,7 +650,7 @@ out:
|
||||
if (!param_import_done) { notify_changes = 0; }
|
||||
|
||||
if (params_changed && notify_changes) {
|
||||
param_notify_changes(is_saved);
|
||||
_param_notify_changes(is_saved);
|
||||
}
|
||||
|
||||
if (result == 0 && !set_called_from_get) {
|
||||
@@ -740,7 +747,7 @@ param_reset(param_t param)
|
||||
param_unlock();
|
||||
|
||||
if (s != NULL) {
|
||||
param_notify_changes(false);
|
||||
_param_notify_changes(false);
|
||||
}
|
||||
|
||||
return (!param_found);
|
||||
@@ -760,7 +767,7 @@ param_reset_all(void)
|
||||
|
||||
param_unlock();
|
||||
|
||||
param_notify_changes(false);
|
||||
_param_notify_changes(false);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -792,7 +799,7 @@ param_reset_excludes(const char *excludes[], int num_excludes)
|
||||
|
||||
param_unlock();
|
||||
|
||||
param_notify_changes(false);
|
||||
_param_notify_changes(false);
|
||||
}
|
||||
|
||||
#ifdef __PX4_QURT
|
||||
|
||||
Reference in New Issue
Block a user