param: add param_control_autosave to enable/disable autosave

This commit is contained in:
Beat Küng
2017-03-24 17:01:16 +01:00
committed by Lorenz Meier
parent f3e9739ab0
commit a0e2b0c5a2
3 changed files with 38 additions and 0 deletions
+15
View File
@@ -639,6 +639,21 @@ static void param_autosave(void)
autosave_scheduled = true;
work_queue(LPWORK, &autosave_work, (worker_t)&autosave_worker, NULL, USEC2TICK(delay));
}
void
param_control_autosave(bool enable)
{
param_lock_writer();
if (!enable && autosave_scheduled) {
work_cancel(LPWORK, &autosave_work);
autosave_scheduled = false;
}
autosave_disabled = !enable;
param_unlock_writer();
}
static int
param_set_internal(param_t param, const void *val, bool mark_saved, bool notify_changes)
{
+8
View File
@@ -383,6 +383,14 @@ __EXPORT int param_load_default(void);
*/
__EXPORT uint32_t param_hash_check(void);
/**
* Enable/disable the param autosaving.
* Re-enabling with changed params will not cause an autosave.
* @param enable true: enable autosaving, false: disable autosaving
*/
__EXPORT void param_control_autosave(bool enable);
/*
* Macros creating static parameter definitions.
*
+15
View File
@@ -640,6 +640,21 @@ static void param_autosave(void)
autosave_scheduled = true;
work_queue(LPWORK, &autosave_work, (worker_t)&autosave_worker, NULL, USEC2TICK(delay));
}
void
param_control_autosave(bool enable)
{
param_lock();
if (!enable && autosave_scheduled) {
work_cancel(LPWORK, &autosave_work);
autosave_scheduled = false;
}
autosave_disabled = !enable;
param_unlock();
}
static int
param_set_internal(param_t param, const void *val, bool mark_saved, bool notify_changes)
{