mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 01:35:41 +03:00
Add altitude variant for OSD (#13716)
This commit is contained in:
parent
2ceb8e0417
commit
0686b74197
5 changed files with 31 additions and 11 deletions
|
@ -223,6 +223,13 @@ float getAltitude(void)
|
||||||
return zeroedAltitudeCm;
|
return zeroedAltitudeCm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_GPS
|
||||||
|
float getAltitudeAsl(void)
|
||||||
|
{
|
||||||
|
return gpsSol.llh.altCm;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_VARIO
|
#ifdef USE_VARIO
|
||||||
int16_t getEstimatedVario(void)
|
int16_t getEstimatedVario(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,4 +37,5 @@ void calculateEstimatedAltitude(void);
|
||||||
void positionInit(void);
|
void positionInit(void);
|
||||||
int32_t getEstimatedAltitudeCm(void);
|
int32_t getEstimatedAltitudeCm(void);
|
||||||
float getAltitude(void);
|
float getAltitude(void);
|
||||||
|
float getAltitudeAsl(void);
|
||||||
int16_t getEstimatedVario(void);
|
int16_t getEstimatedVario(void);
|
||||||
|
|
|
@ -318,19 +318,26 @@ int osdConvertTemperatureToSelectedUnit(int tempInDegreesCelcius)
|
||||||
|
|
||||||
static void osdFormatAltitudeString(char * buff, int32_t altitudeCm, osdElementType_e variantType)
|
static void osdFormatAltitudeString(char * buff, int32_t altitudeCm, osdElementType_e variantType)
|
||||||
{
|
{
|
||||||
const char unitSymbol = osdGetMetersToSelectedUnitSymbol();
|
static const struct {
|
||||||
unsigned decimalPlaces;
|
uint8_t decimals;
|
||||||
|
bool asl;
|
||||||
|
} variantMap[] = {
|
||||||
|
[OSD_ELEMENT_TYPE_1] = { 1, false },
|
||||||
|
[OSD_ELEMENT_TYPE_2] = { 0, false },
|
||||||
|
[OSD_ELEMENT_TYPE_3] = { 1, true },
|
||||||
|
[OSD_ELEMENT_TYPE_4] = { 0, true },
|
||||||
|
};
|
||||||
|
|
||||||
switch (variantType) {
|
int32_t alt = altitudeCm;
|
||||||
case OSD_ELEMENT_TYPE_2: // whole number altitude (no decimal places)
|
#ifdef USE_GPS
|
||||||
decimalPlaces = 0;
|
if (variantMap[variantType].asl) {
|
||||||
break;
|
alt = getAltitudeAsl();
|
||||||
case OSD_ELEMENT_TYPE_1: // one decimal place (default)
|
|
||||||
default:
|
|
||||||
decimalPlaces = 1;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
osdPrintFloat(buff, SYM_ALTITUDE, osdGetMetersToSelectedUnit(altitudeCm) / 100.0f, "", decimalPlaces, true, unitSymbol);
|
#endif
|
||||||
|
unsigned decimalPlaces = variantMap[variantType].decimals;
|
||||||
|
const char unitSymbol = osdGetMetersToSelectedUnitSymbol();
|
||||||
|
|
||||||
|
osdPrintFloat(buff, SYM_ALTITUDE, osdGetMetersToSelectedUnit(alt) / 100.0f, "", decimalPlaces, true, unitSymbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_GPS
|
#ifdef USE_GPS
|
||||||
|
|
|
@ -482,6 +482,7 @@ extern "C" {
|
||||||
int32_t getMAhDrawn() { return 0; }
|
int32_t getMAhDrawn() { return 0; }
|
||||||
float getWhDrawn() { return 0.0; }
|
float getWhDrawn() { return 0.0; }
|
||||||
int32_t getEstimatedAltitudeCm() { return 0; }
|
int32_t getEstimatedAltitudeCm() { return 0; }
|
||||||
|
int32_t getAltitudeAsl() { return 0; }
|
||||||
int32_t getEstimatedVario() { return 0; }
|
int32_t getEstimatedVario() { return 0; }
|
||||||
int32_t blackboxGetLogNumber() { return 0; }
|
int32_t blackboxGetLogNumber() { return 0; }
|
||||||
bool isBlackboxDeviceWorking() { return true; }
|
bool isBlackboxDeviceWorking() { return true; }
|
||||||
|
|
|
@ -1357,6 +1357,10 @@ extern "C" {
|
||||||
return simulationAltitude;
|
return simulationAltitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t getAltitudeAsl() {
|
||||||
|
return simulationAltitude;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t getEstimatedVario() {
|
int32_t getEstimatedVario() {
|
||||||
return simulationVerticalSpeed;
|
return simulationVerticalSpeed;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue