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:
Lucas De Marchi 2015-09-13 15:28:02 -03:00 committed by Andrew Tridgell
parent 294298ea34
commit 6c19f741df

View File

@ -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);