1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-24 16:55:29 +03:00

Initial coding

Should work, not tested in the field. OSD stats part lines up fine.
This commit is contained in:
Darren Lines 2021-09-08 16:08:47 +01:00
parent 05629c8669
commit ccb0d57a11
2 changed files with 17 additions and 1 deletions

View file

@ -421,7 +421,9 @@ static int32_t osdConvertVelocityToUnit(int32_t vel)
/**
* 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)
{
@ -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
* always 3 digits and an additional character for the unit at the right. buff
@ -3541,6 +3551,11 @@ static void osdShowStatsPage1(void)
osdLeftAlignString(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 :");
osdFormatDistanceStr(buff, stats.max_distance*100);
displayWrite(osdDisplayPort, statValuesX, top++, buff);

View file

@ -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);
void osdFormatAltitudeSymbol(char *buff, int32_t alt);
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).
int osdGetHeadingAngle(int angle);