Skip to content

Commit

Permalink
Reduce initial map scale, break early when we're too close to home
Browse files Browse the repository at this point in the history
Reduce minum map scale to 10m in SI/0.01mi in IMP. This way the radar
can draw symbols even when the craft is very close to home.

Also, when the craft is too close to the map center to be drawn,
break out early to save some time.
  • Loading branch information
fiam committed May 19, 2018
1 parent bd1f60e commit f2ffbe8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/io/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ static void osdDrawMap(int referenceHeading, uint8_t referenceSym, uint8_t cente

switch (osdConfig()->units) {
case OSD_UNIT_IMPERIAL:
scale = 161; // 161m ~= 0.1miles
scale = 16; // 16m ~= 0.01miles
scaleToUnit = 100 / 1609.3440f; // scale to 0.01mi for osdFormatCentiNumber()
scaleUnitDivisor = 0;
symUnscaled = SYM_MI;
Expand All @@ -890,7 +890,7 @@ static void osdDrawMap(int referenceHeading, uint8_t referenceSym, uint8_t cente
case OSD_UNIT_UK:
FALLTHROUGH;
case OSD_UNIT_METRIC:
scale = 100; // 100m as initial scale
scale = 10; // 10m as initial scale
scaleToUnit = 100; // scale to cm for osdFormatCentiNumber()
scaleUnitDivisor = 1000; // Convert to km when scale gets bigger than 999m
symUnscaled = SYM_M;
Expand Down Expand Up @@ -923,6 +923,13 @@ static void osdDrawMap(int referenceHeading, uint8_t referenceSym, uint8_t cente
continue;
}

if (poiX == midX && poiY == midY && centerSym != SYM_BLANK) {
// We're over the map center symbol, so we would be drawing
// over it even if we increased the scale. No reason to run
// this loop 50 times.
break;
}

uint8_t c;
if (displayReadCharWithAttr(osdDisplayPort, poiY, poiY, &c, NULL) && c != SYM_BLANK) {
// Something else written here, increase scale. If the display doesn't support reading
Expand Down

0 comments on commit f2ffbe8

Please sign in to comment.