@@ -45,7 +45,6 @@ TinyGPSPlus gps_parser; // Shared with sensor.cpp
4545static struct os_callout rx_callout;
4646static void rx_event (void *drv);
4747static void rx_callback (struct os_event *ev);
48- static void printfloat (float f);
4948static const char *compute_checksum (const uint8_t *buf);
5049static char nibble_to_hex (uint8_t n);
5150
@@ -323,12 +322,12 @@ static void rx_callback(struct os_event *ev) {
323322 while (serial.readable ()) {
324323 int ch = serial.getc (0 ); // Note: this will block if there is nothing to read.
325324 gps_parser.encode (ch); // Parse the GPS data.
326- char buf[1 ]; buf[0 ] = (char ) ch; console_buffer (buf, 1 ); // //
325+ if (ch != ' \r ' ) { char buf[1 ]; buf[0 ] = (char ) ch; console_buffer (buf, 1 ); } // //
327326 if (ch == ' \n ' ) { console_flush (); } // //
328327 }
329328 if (gps_parser.location .isUpdated ()) {
330- console_printf (" *** lat: " ); printfloat (gps_parser.location .lat ());
331- console_printf (" / lng: " ); printfloat (gps_parser.location .lng ());
329+ console_printf (" *** lat: " ); console_printdouble (gps_parser.location .lat ());
330+ console_printf (" / lng: " ); console_printdouble (gps_parser.location .lng ());
332331 console_printf (" / alt: " ); console_printfloat (gps_parser.altitude .meters ());
333332 console_printf (" \n " ); console_flush (); // //
334333 } else if (gps_parser.satellites .isUpdated ()) {
@@ -341,21 +340,6 @@ static void rx_callback(struct os_event *ev) {
341340 }
342341}
343342
344- static void split_float (float f, bool *neg, int *i, int *d) {
345- // Split the float f into 3 parts: neg is true if negative, the absolute integer part i, and the decimal part d, with 6 decimal places.
346- *neg = (f < 0 .0f ); // True if f is negative
347- float f_abs = *neg ? -f : f; // Absolute value of f
348- *i = (int ) f_abs; // Integer part
349- *d = ((int ) (1000000 .0f * f_abs)) % 1000000 ; // 6 decimal places
350- }
351-
352- static void printfloat (float f) {
353- // Write a float to the output buffer, with 6 decimal places.
354- bool neg; int i, d;
355- split_float (f, &neg, &i, &d); // Split the float into neg, integer and decimal parts to 6 decimal places
356- console_printf (" %s%d.%06d" , neg ? " -" : " " , i, d); // Combine the sign, integer and decimal parts
357- }
358-
359343// / Given n=0..15, return '0'..'F'.
360344static char nibble_to_hex (uint8_t n) {
361345 return (n < 10 )
0 commit comments