Newbie GPS_demo.spin question
w4fej
Posts: 264
I have the new GPS module from Parallax (28509) and have it working just fine. (neat part by the way) The demo outputs everything to the serial terminal (PST) just fine. The altitude is displayed in meters and I am trying to change it to feet using the "n_altf" method. I cannot for the life of me get that conversion to work and display properly on PST. I'm sure it is something simple that I just can't get my head around. Both files are from the OBEX. Any help would be much appreciated .
Thanks, Mike B.
This code fragment is from GPS_basic.spin
This code fragment is from GPS_demo.spin
Thanks, Mike B.
This code fragment is from GPS_basic.spin
pub s_altm '' Altitude in meters as z-string, "0.0".."9999.9" bytefill(@gpsrslt, 0, RSLT_SIZE) ' clear result gps_fcopy(@gpsrslt, @ggawork, 9) ' get field 9 return @gpsrslt ' return pointer pub n_altm | len '' Altitude in 0.1 meters as decimal value, 0..99999 s_altm ' get altitude string len := strsize(@gpsrslt) ' get length gpsrslt[len-2] := gpsrslt[len-1] ' remove decimal point gpsrslt[len-1] := 0 ' terminate return str2dec(@gpsrslt, 6) ' return 0.1 meters pub n_altf '' Altitude in 0.1 feet as decimal value, 0..~30480 '' -- 1 foot = 0.3048 meters n_altm return (n_altm * 3_048 / 10_000) ' return 0.1 feet
This code fragment is from GPS_demo.spin
moveto(16, 11) term.str(gps.n_altf) term.tx(CLREOL)
Comments
I stumbled onto the answer myself !! I simply changed "term.str(gps.n_altf) to "term.dec(gps.n_altf)" and bang, it displays feet as pretty as you please.....
Mike B.
Thanks for posting your solution here for everyone to benefit from.
Thanks. Sometimes you can't see the forest because of all the stinking trees in the way!! lol
Mike B.