mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-26 01:35:35 +03:00
Initial coding
Should work, not tested in the field. OSD stats part lines up fine.
This commit is contained in:
parent
05629c8669
commit
ccb0d57a11
2 changed files with 17 additions and 1 deletions
|
@ -421,7 +421,9 @@ static int32_t osdConvertVelocityToUnit(int32_t vel)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts velocity into a string based on the current unit system.
|
* Converts velocity into a string based on the current unit system.
|
||||||
* @param alt Raw velocity (i.e. as taken from gpsSol.groundSpeed in centimeters/seconds)
|
* @param vel Raw velocity (i.e. as taken from gpsSol.groundSpeed in centimeters/seconds)
|
||||||
|
* @param _3D is a 3D velocity
|
||||||
|
* @param _max is a maximum velocity
|
||||||
*/
|
*/
|
||||||
void osdFormatVelocityStr(char* buff, int32_t vel, bool _3D, bool _max)
|
void osdFormatVelocityStr(char* buff, int32_t vel, bool _3D, bool _max)
|
||||||
{
|
{
|
||||||
|
@ -454,6 +456,14 @@ void osdFormatVelocityStr(char* buff, int32_t vel, bool _3D, bool _max)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the average velocity. This always uses stats, so can be called as an OSD element later if wanted, to show a real time average
|
||||||
|
*/
|
||||||
|
void osdFormatAverageVelocityStr(char* buff) {
|
||||||
|
uint32_t cmPerSec = getTotalTravelDistance() / getFlightTime();
|
||||||
|
osdFormatVelocityStr(buff, cmPerSec, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts wind speed into a string based on the current unit system, using
|
* Converts wind speed into a string based on the current unit system, using
|
||||||
* always 3 digits and an additional character for the unit at the right. buff
|
* always 3 digits and an additional character for the unit at the right. buff
|
||||||
|
@ -3541,6 +3551,11 @@ static void osdShowStatsPage1(void)
|
||||||
osdLeftAlignString(buff);
|
osdLeftAlignString(buff);
|
||||||
displayWrite(osdDisplayPort, statValuesX, top++, buff);
|
displayWrite(osdDisplayPort, statValuesX, top++, buff);
|
||||||
|
|
||||||
|
displayWrite(osdDisplayPort, statNameX, top, "AVG SPEED :");
|
||||||
|
osdFormatAverageVelocityStr(buff);
|
||||||
|
osdLeftAlignString(buff);
|
||||||
|
displayWrite(osdDisplayPort, statValuesX, top++, buff);
|
||||||
|
|
||||||
displayWrite(osdDisplayPort, statNameX, top, "MAX DISTANCE :");
|
displayWrite(osdDisplayPort, statNameX, top, "MAX DISTANCE :");
|
||||||
osdFormatDistanceStr(buff, stats.max_distance*100);
|
osdFormatDistanceStr(buff, stats.max_distance*100);
|
||||||
displayWrite(osdDisplayPort, statValuesX, top++, buff);
|
displayWrite(osdDisplayPort, statValuesX, top++, buff);
|
||||||
|
|
|
@ -416,6 +416,7 @@ void osdCrosshairPosition(uint8_t *x, uint8_t *y);
|
||||||
bool osdFormatCentiNumber(char *buff, int32_t centivalue, uint32_t scale, int maxDecimals, int maxScaledDecimals, int length);
|
bool osdFormatCentiNumber(char *buff, int32_t centivalue, uint32_t scale, int maxDecimals, int maxScaledDecimals, int length);
|
||||||
void osdFormatAltitudeSymbol(char *buff, int32_t alt);
|
void osdFormatAltitudeSymbol(char *buff, int32_t alt);
|
||||||
void osdFormatVelocityStr(char* buff, int32_t vel, bool _3D, bool _max);
|
void osdFormatVelocityStr(char* buff, int32_t vel, bool _3D, bool _max);
|
||||||
|
void osdFormatAverageVelocityStr(char* buff);
|
||||||
// Returns a heading angle in degrees normalized to [0, 360).
|
// Returns a heading angle in degrees normalized to [0, 360).
|
||||||
int osdGetHeadingAngle(int angle);
|
int osdGetHeadingAngle(int angle);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue