From 80edd095285a6d9955ab2a1aa563e9d64a19db55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sat, 29 Aug 2020 08:53:23 +0200 Subject: [PATCH] temperature converter: Replace division with multiplication. This makes the code faster --- stm-firmware/temp-converter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stm-firmware/temp-converter.c b/stm-firmware/temp-converter.c index 82465ab..b0649ac 100644 --- a/stm-firmware/temp-converter.c +++ b/stm-firmware/temp-converter.c @@ -68,7 +68,7 @@ int temp_converter_convert_resistance_to_temp(float resistance, float *temp_out) diff_to_low_resistance = resistance - (float)(TEMP_CONVERSION_MIN_RES + TEMP_CONVERSION_RES_STEP * lower_idx); /* Calculate output temperature */ - *temp_out = (diff_to_low_resistance / TEMP_CONVERSION_RES_STEP) * diff_high_low + low; + *temp_out = (diff_to_low_resistance * (1.0f / TEMP_CONVERSION_RES_STEP)) * diff_high_low + low; return_ret_val: return ret_val;