-
Notifications
You must be signed in to change notification settings - Fork 18.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AP_Airspeed: keep references to state and params in backend #29107
base: master
Are you sure you want to change the base?
AP_Airspeed: keep references to state and params in backend #29107
Conversation
There are probably a few more hundred bytes to be saved in the calibration stuff yet.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has a few key advantages, and this is a nice refactor to match other newer conventions in AP for drivers.
- the
airspeed_state
struct is now private - the
airspeed_state
now has an instance number raw_pressure
is moved into the state struct to match where the rest of the data, such asraw_airspeed
is at- Instead of the backend constructor taking na instance number, it now takes into account a reference to the state AND params - this makes the access to parameters cleaner, going from
frontend.param[instance].pin
toparams.pin
- A few airspeed drivers now get to rely on the default backend constructor, reducing flash.
- The frontend was able to remove functions such as
get_pressure
@@ -30,12 +30,15 @@ | |||
|
|||
class AP_Airspeed_Backend { | |||
public: | |||
AP_Airspeed_Backend(AP_Airspeed &frontend, uint8_t instance); | |||
AP_Airspeed_Backend(AP_Airspeed &frontend, class AP_Airspeed::airspeed_state &state, class AP_Airspeed_Params ¶ms); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need the constructor changes at all I think, backend has access to the state and params
@@ -605,69 +598,62 @@ AP_Airspeed::CalibrationState AP_Airspeed::get_calibration_state() const | |||
} | |||
|
|||
// read one airspeed sensor | |||
void AP_Airspeed::read(uint8_t i) | |||
void AP_Airspeed_Backend::update() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not a fan of moving the update to the backend class, it means the backend class is dealing with calibration, offsets, limits etc, which I don't think should be part of the backend
... much as we do for GPS, rangefinder and several other libraries
updating healthy magically in here makes logic difficult to follow
eec814d
to
83095be
Compare
... much as we do for GPS, rangefinder and several other libraries