1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 05:15:25 +03:00

Merge pull request #4445 from McGiverGim/bf-fix_negative_rth_arrow_osd

Fix negative direction in HOME ARROW in OSD
This commit is contained in:
Michael Keller 2017-11-02 03:08:40 +13:00 committed by GitHub
commit c9e96a6d7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -88,6 +88,7 @@
#endif
#define VIDEO_BUFFER_CHARS_PAL 480
#define FULL_CIRCLE 360
const char * const osdTimerSourceNames[] = {
"ON TIME ",
@ -221,14 +222,18 @@ static void osdFormatPID(char * buff, const char * label, const pid8_t * pid)
tfp_sprintf(buff, "%s %3d %3d %3d", label, pid->P, pid->I, pid->D);
}
static uint8_t osdGetHeadingIntoDiscreteDirections(int heading, int directions)
static uint8_t osdGetHeadingIntoDiscreteDirections(int heading, unsigned directions)
{
heading += FULL_CIRCLE; // Ensure positive value
// Split input heading 0..359 into sectors 0..(directions-1), but offset
// by half a sector so that sector 0 gets centered around heading 0.
heading = (heading * 2 + 360 / directions) % 720;
heading = heading / (360 * 2 / directions);
// We multiply heading by directions to not loose precision in divisions
// In this way each segment will be a FULL_CIRCLE length
int direction = (heading * directions + FULL_CIRCLE / 2) / FULL_CIRCLE; // scale with rounding
direction %= directions; // normalize
return heading;
return direction; // return segment number
}
static uint8_t osdGetDirectionSymbolFromHeading(int heading)