mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-21 16:18:29 -04:00
AP_BattMonitor: use method for downcast
Instead of just doing a static cast to the desired class, use a method named "from". Pros: - When we have data shared on the parent class, the code is cleaner in child class when it needs to access this data. Almost all the data we use in AP_HAL benefits from this - There's a minimal type checking because now we are using a method that can only receive the type of the parent class
This commit is contained in:
parent
294298ea34
commit
6c19f741df
@ -142,9 +142,8 @@ void AP_BattMonitor_Bebop::read(void)
|
||||
uint32_t tnow;
|
||||
BebopBLDC_ObsData data;
|
||||
float remaining, vbat, vbat_raw;
|
||||
Linux::LinuxRCOutput_Bebop *rcout;
|
||||
|
||||
rcout = (Linux::LinuxRCOutput_Bebop *)hal.rcout;
|
||||
auto rcout = Linux::LinuxRCOutput_Bebop::from(hal.rcout);
|
||||
tnow = hal.scheduler->micros();
|
||||
|
||||
ret = rcout->read_obs_data(data);
|
||||
|
Loading…
Reference in New Issue
Block a user