mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-23 16:23:56 -04:00
AP_Stats: use set_and_save_ifchanged()
if the board has no GPS then the values usually don't change
This commit is contained in:
parent
c21509e118
commit
ea203520fa
@ -60,8 +60,8 @@ void AP_Stats::init()
|
||||
|
||||
void AP_Stats::flush()
|
||||
{
|
||||
params.flttime.set_and_save(flttime);
|
||||
params.runtime.set_and_save(runtime);
|
||||
params.flttime.set_and_save_ifchanged(flttime);
|
||||
params.runtime.set_and_save_ifchanged(runtime);
|
||||
}
|
||||
|
||||
void AP_Stats::update_flighttime()
|
||||
@ -91,12 +91,11 @@ void AP_Stats::update()
|
||||
flush();
|
||||
last_flush_ms = now_ms;
|
||||
}
|
||||
|
||||
const uint32_t params_reset = params.reset;
|
||||
if (params_reset != reset || params_reset == 0) {
|
||||
params.bootcount.set_and_save(params_reset == 0 ? 1 : 0);
|
||||
params.flttime.set_and_save(0);
|
||||
params.runtime.set_and_save(0);
|
||||
params.bootcount.set_and_save_ifchanged(params_reset == 0 ? 1 : 0);
|
||||
params.flttime.set_and_save_ifchanged(0);
|
||||
params.runtime.set_and_save_ifchanged(0);
|
||||
uint32_t system_clock = 0; // in seconds
|
||||
uint64_t rtc_clock_us;
|
||||
if (AP::rtc().get_utc_usec(rtc_clock_us)) {
|
||||
@ -105,7 +104,7 @@ void AP_Stats::update()
|
||||
// time base to Jan 1st 2016:
|
||||
system_clock -= 1451606400;
|
||||
}
|
||||
params.reset.set_and_save(system_clock);
|
||||
params.reset.set_and_save_ifchanged(system_clock);
|
||||
copy_variables_from_parameters();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user