Commit 5bea1b90 authored by Philippe Kalaf's avatar Philippe Kalaf

Implement auto flowrate adjustment for fixed yield/volume mode

parent 322c14c9
......@@ -217,6 +217,12 @@ void BrewControl::set_shot_volume(int volume)
_target_shot_volume = volume;
}
// This is to set the wanted flow rate (ml/s)
void BrewControl::set_shot_flow_rate(float flow_rate)
{
_target_flow_rate = flow_rate;
}
// return current shot_clock in seconds
float BrewControl::get_current_time()
{
......@@ -292,8 +298,20 @@ void BrewControl::brew_worker()
if(_flow_sensor.read() >= _target_shot_volume)
soft_stop();
}
else if(_mode == MODE_PRESSURE)
else if(_mode == MODE_FLOW_RATE)
{
// Re-calculate target flowrate
_target_flow_rate = (_target_shot_volume - _flow_sensor.read())
/ (_target_shot_time - _shot_clock);
// Auto-adjust flow-rate
if(_target_flow_rate - _flow_sensor.get_flow_rate() < 0)
pressure_down();
else
pressure_up();
// Stop when target shot volume is reached
if(_flow_sensor.read() >= _target_shot_volume)
soft_stop();
}
else if(_mode == MODE_MANUAL)
{
......@@ -321,9 +339,9 @@ uint8_t BrewControl::start()
else if(!_target_shot_time && _target_shot_volume)
_mode = MODE_VOLUME;
// Pressure mode - constant volume, constant time, variable pressure
// Flowrate mode - constant volume, constant time, variable flow-rate
else if(_target_shot_time && _target_shot_volume)
_mode = MODE_PRESSURE;
_mode = MODE_FLOW_RATE;
// Manual on/off via start(), stop(), toggle()
else
......
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