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

Add power limits (#6929)

* Add power limits

* condition USE_ADC

* Minor changes

* Increase max burst time to 5m
This commit is contained in:
Michel Pastor 2021-05-08 21:57:01 +02:00 committed by GitHub
parent e2052a7c8f
commit e5888089a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 557 additions and 18 deletions

View file

@ -85,10 +85,11 @@ FILE_COMPILE_FOR_SPEED
#include "flight/imu.h"
#include "flight/mixer.h"
#include "flight/pid.h"
#include "flight/power_limits.h"
#include "flight/rth_estimator.h"
#include "flight/wind_estimator.h"
#include "flight/secondary_imu.h"
#include "flight/servos.h"
#include "flight/wind_estimator.h"
#include "navigation/navigation.h"
#include "navigation/navigation_private.h"
@ -915,9 +916,15 @@ static void osdFormatThrottlePosition(char *buff, bool autoThr, textAttributes_t
if (autoThr && navigationIsControllingThrottle()) {
buff[0] = SYM_AUTO_THR0;
buff[1] = SYM_AUTO_THR1;
if (isFixedWingAutoThrottleManuallyIncreased())
if (isFixedWingAutoThrottleManuallyIncreased()) {
TEXT_ATTRIBUTES_ADD_BLINK(*elemAttr);
}
}
#ifdef USE_POWER_LIMITS
if (powerLimiterIsLimiting()) {
TEXT_ATTRIBUTES_ADD_BLINK(*elemAttr);
}
#endif
tfp_sprintf(buff + 2, "%3d", getThrottlePercent());
}
@ -2697,9 +2704,47 @@ static bool osdDrawSingleElement(uint8_t item)
return true;
}
case OSD_NAV_FW_CONTROL_SMOOTHNESS:
osdDisplayAdjustableDecimalValue(elemPosX, elemPosY, "CTL S", 0, navConfig()->fw.control_smoothness, 1, 0, ADJUSTMENT_NAV_FW_CONTROL_SMOOTHNESS);
return true;
#ifdef USE_POWER_LIMITS
case OSD_PLIMIT_REMAINING_BURST_TIME:
osdFormatCentiNumber(buff, powerLimiterGetRemainingBurstTime() * 100, 0, 1, 0, 3);
buff[3] = 'S';
buff[4] = '\0';
break;
case OSD_PLIMIT_ACTIVE_CURRENT_LIMIT:
if (powerLimitsConfig()->continuousCurrent) {
osdFormatCentiNumber(buff, powerLimiterGetActiveCurrentLimit(), 0, 2, 0, 3);
buff[3] = SYM_AMP;
buff[4] = '\0';
if (powerLimiterIsLimitingCurrent()) {
TEXT_ATTRIBUTES_ADD_BLINK(elemAttr);
}
}
break;
#ifdef USE_ADC
case OSD_PLIMIT_ACTIVE_POWER_LIMIT:
{
if (powerLimitsConfig()->continuousPower) {
bool kiloWatt = osdFormatCentiNumber(buff, powerLimiterGetActivePowerLimit(), 1000, 2, 2, 3);
buff[3] = kiloWatt ? SYM_KILOWATT : SYM_WATT;
buff[4] = '\0';
if (powerLimiterIsLimitingPower()) {
TEXT_ATTRIBUTES_ADD_BLINK(elemAttr);
}
}
break;
}
#endif // USE_ADC
#endif // USE_POWER_LIMITS
default:
return false;
}
@ -2774,6 +2819,12 @@ static uint8_t osdIncElementIndex(uint8_t elementIndex)
}
}
#ifndef USE_POWER_LIMITS
if (elementIndex == OSD_NAV_FW_CONTROL_SMOOTHNESS) {
elementIndex = OSD_ITEM_COUNT;
}
#endif
if (elementIndex == OSD_ITEM_COUNT) {
elementIndex = 0;
}
@ -3020,6 +3071,12 @@ void pgResetFn_osdLayoutsConfig(osdLayoutsConfig_t *osdLayoutsConfig)
osdLayoutsConfig->item_pos[0][OSD_RC_SOURCE] = OSD_POS(3, 4);
#endif
#ifdef USE_POWER_LIMITS
osdLayoutsConfig->item_pos[0][OSD_PLIMIT_REMAINING_BURST_TIME] = OSD_POS(3, 4);
osdLayoutsConfig->item_pos[0][OSD_PLIMIT_ACTIVE_CURRENT_LIMIT] = OSD_POS(3, 5);
osdLayoutsConfig->item_pos[0][OSD_PLIMIT_ACTIVE_POWER_LIMIT] = OSD_POS(3, 6);
#endif
// Under OSD_FLYMODE. TODO: Might not be visible on NTSC?
osdLayoutsConfig->item_pos[0][OSD_MESSAGES] = OSD_POS(1, 13) | OSD_VISIBLE_FLAG;