AP_LTM_Telem: add and use AP_BATTERY_ENABLED

This commit is contained in:
Peter Barker 2024-01-31 19:38:49 +11:00 committed by Andrew Tridgell
parent 7f6cb0eab3
commit 55dbee78f8
1 changed files with 5 additions and 0 deletions

View File

@ -116,6 +116,7 @@ void AP_LTM_Telem::send_Gframe(void)
// Sensors frame
void AP_LTM_Telem::send_Sframe(void)
{
#if AP_BATTERY_ENABLED
const AP_BattMonitor &battery = AP::battery();
const uint16_t volt = (uint16_t) roundf(battery.voltage() * 1000.0f); // battery voltage (expects value in mV)
float current;
@ -124,6 +125,10 @@ void AP_LTM_Telem::send_Sframe(void)
}
// note: max. current value we can send is 65.536 A
const uint16_t amp = (uint16_t) roundf(current * 100.0f); // current sensor (expects value in hundredth of A)
#else
const uint16_t volt = 0;
const uint16_t amp = 0;
#endif
// airspeed in m/s if available and enabled - even if not used - otherwise send 0
uint8_t airspeed = 0; // airspeed sensor (m/s)