Shop OBEX P1 Docs P2 Docs Learn Events
float to string — Parallax Forums

float to string

I'm having a problem "intercepting" values from gps code i found on parallax site. The code works and puts the correct lat./lon. values in the serial terminal. I want to be able to use the same values for lat/lon that are displayed in the serial terminal to do calculations for other sections of code. The correct lat. is 42.32377. When i try to do float math with (fv) or debug.dec, i get 10 digit,4 digit, or just numbers other than the 42.32377. I've done a lot of reading and having a problem figuring it out.
CON
        _clkmode = xtal1 + pll16x                                               'Standard clock mode * crystal frequency = 80 MHz
        _xinfreq = 5_000_000


OBJ
 Debug : "FullDuplexSerialPlus"
 GPS : "GPS_Float_Lite"
 FS : "FloatString"

PUB Init | fv
 'Start FullDuplexSerialPlus terminal
 Debug.Start(31, 30, 0, 115200)
 Debug.Str(String("Reading GPS..."))

 WaitCnt(ClkFreq * 2 + Cnt)

 'Start GPS object, GPS connected to P7
 GPS.Init

 Repeat
    Debug.Str(String(16, 1))

    FS.SetPrecision(7) 
   
    fv := GPS.Float_Latitude_Deg ' Get latitude                                                                             
    If fv <> floatNaN
       
       Debug.Str(FS.FloatToString(fv))       '''''this line will print the correct latitude: 42.32377'''''''''''''''''
       
    Else
      Debug.Str(String("---"))

    Debug.Str(String(","))
    fv := GPS.Float_Longitude_Deg ' Get longitude
    If fv <> floatNaN
       Debug.Str(FS.FloatToString(fv))
    Else
       Debug.Str(String("---"))
  WaitCnt(ClkFreq / 2 + ClkFreq / 4 + Cnt)
DAT
 floatNaN LONG $7FFF_FFFF 'Means Not a Number

Comments

  • You can take a look at my Propeller Based Reverse Geocache Project for some potential help, but it's been a number of years, so not sure how I did what you are asking about. There is also a link in the code portion of that thread to a Google Earth GPS SD Card logger (KML datalogger) I based some of my work on from. Also, the two zip files containing code are hard to find with the new forum format, but they are the white boxes next to the 2 program flowcharts. Here is a direct link for the ReverseGeoCache_vU16-Archive.zip file that contains all my code.

    PS, the last forum migration broke numerous links in my thread, so I will have to work on fixing those at some point. I guess I should download all of my text from the forums to preserve the content as well as all of my referenced threads....

Sign In or Register to comment.