1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-25 17:25:18 +03:00

Add a new MSP2_INAV_MISC2 message type, that allows a peer to fetch the On Time, Flight Time, Throttle percent and Auto Throttle flag.

This commit is contained in:
Daniel Arruda Ribeiro 2021-01-14 21:18:11 -03:00
parent c5d544295e
commit 2277239215
2 changed files with 22 additions and 0 deletions

View file

@ -824,6 +824,25 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF
sbufWriteU8(dst, currentBatteryProfile->capacity.unit);
break;
case MSP2_INAV_MISC2:
// Timers
sbufWriteU32(dst, micros() / 1000000); // On time (seconds)
sbufWriteU32(dst, getFlightTime()); // Flight time (seconds)
// Throttle
int16_t thr = 0;
const int minThrottle = getThrottleIdleValue();
bool autoThrottle = navigationIsControllingThrottle();
if(autoThrottle)
thr = (constrain(rcCommand[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX) - PWM_RANGE_MIN) * 100 / (PWM_RANGE_MAX - PWM_RANGE_MIN);
else
thr = (constrain(rcCommand[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX ) - minThrottle) * 100 / (motorConfig()->maxthrottle - minThrottle);
sbufWriteU8(dst, thr); // Throttle Percent
sbufWriteU8(dst, autoThrottle ? 1 : 0); // Auto Throttle Flag (0 or 1)
break;
case MSP2_INAV_BATTERY_CONFIG:
sbufWriteU16(dst, batteryMetersConfig()->voltage.scale);
sbufWriteU8(dst, batteryMetersConfig()->voltageSource);