Mascobot / pandemic-ventilator-2.0

Open Source Pandemic Ventilator with Raspberry Pi and Arduino
238 stars 49 forks source link

vent.ino: less truncation in calculation of time_ratio #2

Open paul-wilkinson opened 4 years ago

paul-wilkinson commented 4 years ago

breath and ratio are of type int, so (60/breath)/(1+ratio) uses integer division, which leads to truncation for some values of breath and ratio.

This patch avoids the truncation in the expression above by casting breath and ratio to double.