Add Speed conversion to kmph
This commit is contained in:
parent
c16e5fa816
commit
15cb6ad7ad
9
main.c
9
main.c
|
@ -88,6 +88,7 @@ void nmea_sentence_process(const char *nmea_sentence)
|
||||||
{
|
{
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
uint8_t field_number = 0;
|
uint8_t field_number = 0;
|
||||||
|
float speed_knots = 0.0;
|
||||||
float speed_kmh = 0.0;
|
float speed_kmh = 0.0;
|
||||||
uint8_t field_index = 0;
|
uint8_t field_index = 0;
|
||||||
|
|
||||||
|
@ -100,7 +101,9 @@ void nmea_sentence_process(const char *nmea_sentence)
|
||||||
if (nmea_sentence[i] == ',')
|
if (nmea_sentence[i] == ',')
|
||||||
{
|
{
|
||||||
if (field_number == 7) // Speed in knots (field 7)
|
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);
|
control_leds_based_on_speed(speed_kmh);
|
||||||
}
|
}
|
||||||
field_number++;
|
field_number++;
|
||||||
|
@ -124,7 +127,9 @@ void nmea_sentence_process(const char *nmea_sentence)
|
||||||
{
|
{
|
||||||
if (field_number == 6)
|
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);
|
control_leds_based_on_speed(speed_kmh);
|
||||||
}
|
}
|
||||||
field_number++;
|
field_number++;
|
||||||
|
|
Loading…
Reference in New Issue