From 15cb6ad7ad52620a954fead3fb8ed4c06da993a3 Mon Sep 17 00:00:00 2001 From: Sanyog Date: Sat, 30 Nov 2024 16:14:15 +0530 Subject: [PATCH] Add Speed conversion to kmph --- main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 97331a0..1f24998 100644 --- a/main.c +++ b/main.c @@ -88,6 +88,7 @@ void nmea_sentence_process(const char *nmea_sentence) { uint8_t i = 0; uint8_t field_number = 0; + float speed_knots = 0.0; float speed_kmh = 0.0; uint8_t field_index = 0; @@ -100,7 +101,9 @@ void nmea_sentence_process(const char *nmea_sentence) if (nmea_sentence[i] == ',') { if (field_number == 7) // Speed in knots (field 7) - { speed_kmh = atof(nmea_sentence + i - field_index); + { + speed_knots = atof(nmea_sentence + i - field_index); + speed_kmh = speed_knots * 1.852; control_leds_based_on_speed(speed_kmh); } field_number++; @@ -124,7 +127,9 @@ void nmea_sentence_process(const char *nmea_sentence) { if (field_number == 6) { - speed_kmh = atof(nmea_sentence + i - field_index); + speed_knots = atof(nmea_sentence + i - field_index); + speed_kmh = speed_knots * 1.852; + control_leds_based_on_speed(speed_kmh); } field_number++;