GPS LCD display error with negative coordinates

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
User avatar
djrm
Posts: 40
Joined: Wed Feb 15, 2012 11:32 pm
Location: North Yorkshire, UK

GPS LCD display error with negative coordinates

Post by djrm »

I live to the west of Grenwich, the LCD display of my GPS location was corrupted because the LCD display function could not cope with the negative longitude. While fixing it I took the opportunity to include the satellite count too. The new LCD display has the hemisphere N or S, E or W on the top line together with the satelllite count and other existing information. The LCD display format now looks like this:

Code: Select all

N Lat 0 E Lon af
0000000 0000000


Here is the modified diplay code from LCD.pde function lcd_telemetry at around line 930

Code: Select all

    case 7:
    case '7':   // contributed by PatrikE
      #if GPS
      if (linenr++ % 2) {

        strcpy_P(line1,PSTR("- Lat - - Lon --"));
        //                   0123456789012345
        if (armed) line1[14] = 'A'; else line1[14] = 'a';
        if (failsafeCnt > 5) line1[15] = 'F'; else line1[15] = 'f';
        line1[0]=GPS_latitude<0?'S':'N';
        line1[8]=GPS_longitude<0?'W':'E';
        line1[6]=0x30+GPS_numSat;
        LCDsetLine(1);LCDprintChar(line1);
       
      } else {
        int32_t aGPS_latitude = abs(GPS_latitude);
        int32_t aGPS_longitude = abs(GPS_longitude);
        int pos=0;
        strcpy_P(line2,PSTR("------- ------- "));
       
        line2[pos++] = '0' + aGPS_latitude / 1000000 - (aGPS_latitude/10000000) * 10;
        line2[pos++] = '0' + aGPS_latitude / 100000  - (aGPS_latitude/1000000)  * 10;
        line2[pos++] = '0' + aGPS_latitude / 10000   - (aGPS_latitude/100000)   * 10;
        line2[pos++] = '0' + aGPS_latitude / 1000 -    (aGPS_latitude/10000) * 10;
        line2[pos++] = '0' + aGPS_latitude / 100  -    (aGPS_latitude/1000)  * 10;
        line2[pos++] = '0' + aGPS_latitude / 10   -    (aGPS_latitude/100)   * 10;
        line2[pos++] = '0' + aGPS_latitude        -    (aGPS_latitude/10)    * 10;       
       
        pos++;
        line2[pos++] = '0' + aGPS_longitude / 1000000 - (aGPS_longitude/10000000) * 10;
        line2[pos++] = '0' + aGPS_longitude / 100000  - (aGPS_longitude/1000000)  * 10;
        line2[pos++] = '0' + aGPS_longitude / 10000   - (aGPS_longitude/100000)   * 10;
        line2[pos++] = '0' + aGPS_longitude / 1000    - (aGPS_longitude/10000) * 10;
        line2[pos++] = '0' + aGPS_longitude / 100     - (aGPS_longitude/1000)  * 10;
        line2[pos++] = '0' + aGPS_longitude / 10      - (aGPS_longitude/100)   * 10;
        line2[pos++] = '0' + aGPS_longitude           - (aGPS_longitude/10)    * 10;
       
        LCDsetLine(2);LCDprintChar(line2);
      }
      #endif // case 7 : GPS
      break;


hth David.

Wayne
Posts: 86
Joined: Sun Jul 31, 2011 10:44 pm

Re: GPS LCD display error with negative coordinates

Post by Wayne »

I too ran into this when getting GPS current, home and hold locations to display on my OLED.
Its got me thinking maybe this has something to do with my less-than-expected GPS RTH and HOLD results.

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: GPS LCD display error with negative coordinates

Post by Hamburger »

submitted to _shared. Note: I cannot test this in any way. I have no GPS available and never compile in GPS support.

Post Reply