From f875f92292fbe4c78319512ba65d20ce8e5ebe3a Mon Sep 17 00:00:00 2001 From: Andreas Bertheussen Date: Thu, 3 Aug 2017 18:16:34 +0200 Subject: [PATCH] Update osd.c Correct the heading boundaries used to display "numerical heading" arrow symbol, and "compass bar" direction. The direction indicators get shifted by 1/32th of a circle. For instance the forward arrow and north direction will now be displayed for headings 349..011, instead of at headings 000..022. --- src/main/io/osd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 4dfebf1eaf..b8a94e77ec 100755 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -213,8 +213,10 @@ static void osdFormatPID(char * buff, const char * label, const pid8_t * pid) static uint8_t osdGetHeadingIntoDiscreteDirections(int heading, int directions) { - heading = (heading + 360) % 360; - heading = heading * 2 / (360 * 2 / directions); + // 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); return heading; }