Browse Source

AP_Param: add set_and_save_ifchanged for Vector3f params

c415-sdk
bugobliterator 5 years ago committed by Andrew Tridgell
parent
commit
c6e45dd536
  1. 17
      libraries/AP_Param/AP_Param.h

17
libraries/AP_Param/AP_Param.h

@ -887,6 +887,23 @@ public: @@ -887,6 +887,23 @@ public:
save(force);
}
/// Combined set and save, but only does the save if the value is
/// different from the current ram value, thus saving us a
/// scan(). This should only be used where we have not set() the
/// value separately, as otherwise the value in EEPROM won't be
/// updated correctly.
void set_and_save_ifchanged(const T &v) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
if (_value == v) {
#pragma GCC diagnostic pop
return;
}
set(v);
save(true);
}
/// Conversion to T returns a reference to the value.
///
/// This allows the class to be used in many situations where the value would be legal.

Loading…
Cancel
Save