ben-pololu-imu

Changeset

2:448730147f03
2013-10-14 Paul Boddie raw files shortlog changelog graph Added direction labels for the most central elevation.
gui.c (file)
     1.1 --- a/gui.c	Mon Oct 14 14:36:36 2013 +0000
     1.2 +++ b/gui.c	Mon Oct 14 15:39:39 2013 +0000
     1.3 @@ -111,21 +111,23 @@
     1.4  void gui_sky(vectorf *viewx, vectorf *viewy, vectorf *viewz)
     1.5  {
     1.6      double direction, elevation;
     1.7 -    int d, e, estart, efinish, dcount;
     1.8 +    int d, e, eclosest, estart, efinish, dcount;
     1.9      int16_t lastminx, lastminy, thisminx, thisminy,
    1.10              lastmaxx, lastmaxy, thismaxx, thismaxy;
    1.11      uint32_t colour;
    1.12      vectorf point;
    1.13 +    char buffer[5];
    1.14  
    1.15      direction = vectorf_direction(viewz);
    1.16      elevation = vectorf_elevation(viewz);
    1.17  
    1.18      d = closest(raddeg(direction), SKY_GRID_STEP);
    1.19 +    eclosest = closest(raddeg(elevation), SKY_GRID_STEP);
    1.20  
    1.21      /* Plot points between elevations -90 and 90 degrees. */
    1.22  
    1.23 -    estart = max(-90, closest(raddeg(elevation), SKY_GRID_STEP) - (SKY_GRID_STEP * 3));
    1.24 -    efinish = min(90, closest(raddeg(elevation), SKY_GRID_STEP) + (SKY_GRID_STEP * 3));
    1.25 +    estart = max(-90, eclosest - (SKY_GRID_STEP * 3));
    1.26 +    efinish = min(90, eclosest + (SKY_GRID_STEP * 3));
    1.27  
    1.28      for (e = estart; e <= efinish; e += SKY_GRID_STEP)
    1.29      {
    1.30 @@ -196,6 +198,16 @@
    1.31                  break;
    1.32              }
    1.33  
    1.34 +            /* Write labels for the most central set of points. */
    1.35 +
    1.36 +            if (e == eclosest)
    1.37 +            {
    1.38 +                sprintf(buffer, "%d", d - dcount);
    1.39 +                stringRGBA(screen, thisminx, thisminy, buffer, 255, 255, 255, 255);
    1.40 +                sprintf(buffer, "%d", d + dcount);
    1.41 +                stringRGBA(screen, thismaxx, thismaxy, buffer, 255, 255, 255, 255);
    1.42 +            }
    1.43 +
    1.44              lastminx = thisminx; lastminy = thisminy;
    1.45              lastmaxx = thismaxx; lastmaxy = thismaxy;
    1.46          }