mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 14:38:30 -04:00
AP_OSD: reduce scope of WITH_SEMAPHORE
The backend write() calls don't look nasty ATM - but we should get in, get out data and get out again ASAP.
This commit is contained in:
parent
d167dacfae
commit
9410d40b2f
@ -1439,9 +1439,12 @@ void AP_OSD_Screen::draw_flightime(uint8_t x, uint8_t y)
|
||||
void AP_OSD_Screen::draw_eff(uint8_t x, uint8_t y)
|
||||
{
|
||||
AP_BattMonitor &battery = AP::battery();
|
||||
Vector2f v;
|
||||
{
|
||||
AP_AHRS &ahrs = AP::ahrs();
|
||||
WITH_SEMAPHORE(ahrs.get_semaphore());
|
||||
Vector2f v = ahrs.groundspeed_vector();
|
||||
v = ahrs.groundspeed_vector();
|
||||
}
|
||||
float speed = u_scale(SPEED,v.length());
|
||||
float current_amps;
|
||||
if ((speed > 2.0) && battery.current_amps(current_amps)) {
|
||||
@ -1456,15 +1459,19 @@ void AP_OSD_Screen::draw_climbeff(uint8_t x, uint8_t y)
|
||||
char unit_icon = u_icon(DISTANCE);
|
||||
Vector3f v;
|
||||
float vspd;
|
||||
do {
|
||||
{
|
||||
auto &ahrs = AP::ahrs();
|
||||
WITH_SEMAPHORE(ahrs.get_semaphore());
|
||||
if (ahrs.get_velocity_NED(v)) {
|
||||
vspd = -v.z;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto &baro = AP::baro();
|
||||
WITH_SEMAPHORE(baro.get_semaphore());
|
||||
vspd = baro.get_climb_rate();
|
||||
}
|
||||
} while (false);
|
||||
if (vspd < 0.0) {
|
||||
vspd = 0.0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user