core/units/wind.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /** | ||
| 2 | * @file wind.c | ||
| 3 | * @brief Pure wind-speed conversions and unit labels, no SDK behind them. | ||
| 4 | * | ||
| 5 | * @ingroup lib_core | ||
| 6 | */ | ||
| 7 | #include "units/wind.h" | ||
| 8 | |||
| 9 | 6 | int wind_from_kmh(int kmh, WindUnit unit) | |
| 10 | { | ||
| 11 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 2 times.
|
6 | switch (unit) |
| 12 | { | ||
| 13 | 2 | case WIND_UNIT_MPH: return (kmh * 621) / 1000; // mph | |
| 14 | 1 | case WIND_UNIT_KTS: return (kmh * 540) / 1000; // kts | |
| 15 | 1 | case WIND_UNIT_MS: return (kmh * 278) / 1000; // m/s | |
| 16 | 2 | default: return kmh; // km/h | |
| 17 | } | ||
| 18 | } | ||
| 19 | |||
| 20 | 5 | const char *wind_unit_label(WindUnit unit) | |
| 21 | { | ||
| 22 |
4/4✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 2 times.
|
5 | switch (unit) |
| 23 | { | ||
| 24 | 1 | case WIND_UNIT_MPH: return "MPH"; | |
| 25 | 1 | case WIND_UNIT_KTS: return "KTS"; | |
| 26 | 1 | case WIND_UNIT_MS: return "M/S"; | |
| 27 | 2 | default: return "KM/H"; | |
| 28 | } | ||
| 29 | } | ||
| 30 |