Skip to content

Commit 078871e

Browse files
committed
Fixed compression change effect during respiration
Only before every respiration, the compression value will take effect. This will prevent unwanted behavior when the user change the compression during respiration. Code was tested on the ambovent. Runned clang format.
1 parent b64f3db commit 078871e

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

3-Software/Arduino/ventilation_machine/ventilation_machine.ino

+16-8
Original file line numberDiff line numberDiff line change
@@ -1101,14 +1101,17 @@ void read_IO()
11011101
}
11021102
}
11031103
}
1104-
range_factor = perc_of_lower_volume
1105-
+ (Compression_perc - perc_of_lower_vol_display) * (100 - perc_of_lower_volume)
1106-
/ (100 - perc_of_lower_vol_display);
1107-
range_factor = range_factor / 100;
1108-
if (range_factor > 1)
1109-
range_factor = 1;
1110-
if (range_factor < 0)
1111-
range_factor = 0;
1104+
if (is_starting_respiration())
1105+
{
1106+
range_factor = perc_of_lower_volume
1107+
+ (Compression_perc - perc_of_lower_vol_display)
1108+
* (100 - perc_of_lower_volume) / (100 - perc_of_lower_vol_display);
1109+
range_factor = range_factor / 100;
1110+
if (range_factor > 1)
1111+
range_factor = 1;
1112+
if (range_factor < 0)
1113+
range_factor = 0;
1114+
}
11121115

11131116
#if (pressure_sensor_available == 1)
11141117
{
@@ -1131,6 +1134,11 @@ void read_IO()
11311134
wanted_cycle_time = cycleTime;
11321135
}
11331136

1137+
bool is_starting_respiration()
1138+
{
1139+
return index == 0;
1140+
}
1141+
11341142
void send_data_to_monitor()
11351143
{
11361144
if (monitor_index == 0)

0 commit comments

Comments
 (0)