mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 13:25:30 +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:
commit
c9e96a6d7f
1 changed files with 9 additions and 4 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue