Commit ea2cd3fc authored by Philippe Kalaf's avatar Philippe Kalaf

replace flowsensor.read() with .get_volume()

parent a22baa48
......@@ -255,7 +255,7 @@ float BrewControl::get_current_time()
// return current volume in ml
float BrewControl::get_current_volume()
{
return _flow_sensor.read();
return _flow_sensor.get_volume();
}
// return the current flow rate
......@@ -270,14 +270,34 @@ uint8_t BrewControl::get_state()
return _state;
}
#ifdef LOG
void BrewControl::_log_brew_params()
{
if (_log_file)
{
fprintf(_log_file, "%f,%f,%f,%f,%f,%d\n",
get_current_time(),
get_current_volume(),
get_current_temperature(),
get_current_pressure(),
get_current_flow_rate(),
_state);
}
}
#endif
void BrewControl::_brew_worker()
{
_shot_clock = _shot_clock + BREW_WORKER_PERIOD;
#ifdef LOG
_log_brew_params();
#endif
if (_state == PRE_INFUSING)
{
// First let's fill up the portafilter
if (_flow_sensor.read() <= PORTAFILTER_VOLUME && !_stop_preinfuse)
if (_flow_sensor.get_volume() <= PORTAFILTER_VOLUME && !_stop_preinfuse)
return;
// It's full, let's stop the pump for set pre-infuse time
......@@ -322,22 +342,26 @@ void BrewControl::_brew_worker()
else if(error > 0.25)
pressure_up();
if(_flow_sensor.read() >= _target_shot_volume)
if(_flow_sensor.get_volume() >= _target_shot_volume)
soft_stop();
}
else if(_mode == MODE_TIME_YIELD)
{
// Re-calculate target flowrate
_target_flow_rate = (_target_shot_volume - _flow_sensor.read())
// Re-calculate target flowrate =
// remaining volume / remaining time
_target_flow_rate = (_target_shot_volume - _flow_sensor.get_volume())
/ (_target_shot_time - _shot_clock);
// Auto-adjust flow-rate
if(_target_flow_rate - _flow_sensor.get_flow_rate() < 0)
if(_target_flow_rate < 0)
// oops! we have run out of time! go full power!
_pump_control.set_level(100);
else 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)
if(_flow_sensor.get_volume() >= _target_shot_volume)
soft_stop();
}
else if(_mode == MODE_MANUAL)
......
......@@ -37,12 +37,12 @@ void FHKSC::increment()
}
// return in ml
float FHKSC::read()
float FHKSC::get_volume()
{
return float(_flow_ul)/1000;
}
uint32_t FHKSC::read_ul()
uint32_t FHKSC::get_volume_ul()
{
return _flow_ul;
}
......
......@@ -29,8 +29,8 @@ public:
FHKSC(PinName pin);
void increment();
float read();
uint32_t read_ul();
float get_volume();
uint32_t get_volume_ul();
void reset_count();
float get_flow_rate();
......@@ -43,4 +43,4 @@ private:
int _interval_between_increments_us;
};
#endif// fhksc_h
\ No newline at end of file
#endif// fhksc_h
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