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++;