float to string
mikea
Posts: 283
in Propeller 1
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
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....