Commit 7d7b28f7 authored by Derick's avatar Derick

averaging adc value of differential pressure over a breath cycle and displaying it instead of FiO2

parent ff1f0719
Pipeline #885 canceled with stage
...@@ -95,7 +95,7 @@ BreathingLoop::BreathingLoop() ...@@ -95,7 +95,7 @@ BreathingLoop::BreathingLoop()
_sum_airway_pressure = 0; _sum_airway_pressure = 0;
_ap_readings_N = 0; _ap_readings_N = 0;
_readings_N_ADC = 0;
_running_index = 0; _running_index = 0;
_running_index_peep = 0; _running_index_peep = 0;
...@@ -197,8 +197,9 @@ void BreathingLoop::updateReadings() ...@@ -197,8 +197,9 @@ void BreathingLoop::updateReadings()
_readings_sums.temperature_buffer += static_cast<float>(analogRead(pin_temperature_buffer) ); _readings_sums.temperature_buffer += static_cast<float>(analogRead(pin_temperature_buffer) );
_readings_sums.pressure_o2_regulated += static_cast<float>(analogRead(pin_pressure_o2_regulated) ); _readings_sums.pressure_o2_regulated += static_cast<float>(analogRead(pin_pressure_o2_regulated) );
_readings_sums.pressure_diff_patient += static_cast<float>(analogRead(pin_pressure_diff_patient) ); _readings_sums.pressure_diff_patient += static_cast<float>(analogRead(pin_pressure_diff_patient) );
_readings_sums.o2_percent += static_cast<float>(analogRead(pin_o2_sensor) ); // CHANGED
_readings_sums.o2_percent += static_cast<float>(analogRead(pin_pressure_diff_patient) );
_readings_N_ADC++;
} }
...@@ -277,13 +278,13 @@ void BreathingLoop::updateCycleReadings() ...@@ -277,13 +278,13 @@ void BreathingLoop::updateCycleReadings()
if (_bl_state == BL_STATES::BUFF_PRE_INHALE){ if (_bl_state == BL_STATES::BUFF_PRE_INHALE){
if(_cycle_done == false){ if(_cycle_done == false){
logMsg("hello\n"); logMsg("hello\n");
uint32_t tnow = static_cast<uint32_t>(millis()); uint32_t tnow = static_cast<uint32_t>(millis());
_cycle_index = (_cycle_index == CYCLE_AVG_READINGS-1 ) ? 0 : _cycle_index+1; _cycle_index = (_cycle_index == CYCLE_AVG_READINGS-1 ) ? 0 : _cycle_index+1;
_cycle_readings.timestamp = tnow; _cycle_readings.timestamp = tnow;
_cycle_readings.fiO2_percent = _readings_avgs.o2_percent;// FIXME _cycle_readings.fiO2_percent = _readings_sums.o2_percent / _readings_N_ADC ;// FIXME
_running_inhale_minute_volume[_cycle_index] = _volume_inhale ; _running_inhale_minute_volume[_cycle_index] = _volume_inhale ;
_running_exhale_minute_volume[_cycle_index] = _volume_exhale ; _running_exhale_minute_volume[_cycle_index] = _volume_exhale ;
//logMsg(" I, E "+String(_volume_inhale)+ " "+String(_volume_exhale)); //logMsg(" I, E "+String(_volume_inhale)+ " "+String(_volume_exhale));
...@@ -333,6 +334,8 @@ void BreathingLoop::updateCycleReadings() ...@@ -333,6 +334,8 @@ void BreathingLoop::updateCycleReadings()
//reset //reset
_cycle_done = true; _cycle_done = true;
_readings_sums.o2_percent = 0;
_readings_N_ADC = 0;
} }
/* } else if ((_bl_state == BL_STATES::IDLE ) || (_bl_state == BL_STATES::CALIBRATION ) || (_bl_state == BL_STATES::STOP) ){ /* } else if ((_bl_state == BL_STATES::IDLE ) || (_bl_state == BL_STATES::CALIBRATION ) || (_bl_state == BL_STATES::STOP) ){
_sum_airway_pressure = 0; _sum_airway_pressure = 0;
...@@ -436,7 +439,7 @@ void BreathingLoop::resetReadingSums() ...@@ -436,7 +439,7 @@ void BreathingLoop::resetReadingSums()
_readings_sums.pressure_o2_supply = 0; _readings_sums.pressure_o2_supply = 0;
_readings_sums.pressure_o2_regulated = 0; _readings_sums.pressure_o2_regulated = 0;
_readings_sums.pressure_diff_patient = 0; _readings_sums.pressure_diff_patient = 0;
_readings_sums.o2_percent = 0; //_readings_sums.o2_percent = 0;
} }
//This is used to assign the transitions of the fsm //This is used to assign the transitions of the fsm
......
...@@ -168,6 +168,7 @@ private: ...@@ -168,6 +168,7 @@ private:
uint32_t _readings_avgs_timeout; uint32_t _readings_avgs_timeout;
uint32_t _readings_cycle_time; uint32_t _readings_cycle_time;
uint32_t _readings_cycle_timeout; uint32_t _readings_cycle_timeout;
uint32_t _readings_N_ADC;
uint32_t _tsig_time; uint32_t _tsig_time;
uint32_t _tsig_timeout; uint32_t _tsig_timeout;
uint32_t _calculations_time; uint32_t _calculations_time;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment