Commit 74ecc5be authored by Philippe Kalaf's avatar Philippe Kalaf

Improved UI with in-brew state display (pre-infuse, brew, soft-stop)

A few small UI bugfixes
parent 9f0a7977
......@@ -19,7 +19,7 @@
// brew worker to run 10 times per second
#define BREW_WORKER_PERIOD 0.1
// PID worker to run 1 times per second
// Boiler PID worker to run 1 times per second
#define PID_WORKER_PERIOD 1
// PWM period
......@@ -114,7 +114,7 @@ void BrewControl::boiler_pid_worker()
// take temperature measurement
float latestTemp = get_current_temperature();
double power = 0.0;
float power = 0.0;
// if the temperature is near zero, we assume there's an error
if ( latestTemp > 0.5 ) {
......@@ -133,7 +133,7 @@ void BrewControl::boiler_pid_worker()
_boiler_pwm = power;
// store the latest temperature reading
_latest_temp = latestTemp;
_latest_temp = latestTemp;
}
void BrewControl::enable_boiler()
......@@ -222,7 +222,7 @@ float BrewControl::get_current_flow_rate()
}
// read brew on/off state
bool BrewControl::get_state()
uint8_t BrewControl::get_state()
{
return _state;
}
......@@ -238,9 +238,9 @@ void BrewControl::brew_worker()
return;
// It's full, let's stop the pump for set pre-infuse time
if (_pump_control.get_level() != 1)
if (_pump_control.get_level() != 0)
{
_pump_control.set_level(1);
_pump_control.set_level(0);
_shot_clock = 0;
}
......@@ -275,7 +275,7 @@ uint8_t BrewControl::start()
{
if(_state) return _mode;
_state = 1;
_state = BREWING;
// reset shot clock and flow sensor
_flow_sensor.reset_count();
......@@ -307,6 +307,9 @@ uint8_t BrewControl::start()
_prev_pressure = get_pump_level();
// set pre-infuse mode
_mode = MODE_PRE_INFUSE;
_state = PRE_INFUSING;
// we pre-infuse at low pressure
_pump_control.set_level(45);
}
......@@ -331,26 +334,28 @@ void BrewControl::toggle_solenoid()
void BrewControl::stop()
{
_state = 0;
_state = STOPPED;
_brew_switch = 0;
_shot_clock = 0;
set_shot_volume(0);
set_shot_time(0);
_flow_sensor.reset_count();
_brew_ticker.detach();
_shot_clock = 0;
}
void BrewControl::soft_stop()
{
_pump_control.set_level(0);
_soft_stop_timer.attach(callback(this, &BrewControl::stop), SOFT_STOP_TIME_S);
_brew_ticker.detach();
_soft_stop_timer.attach(callback(this, &BrewControl::stop),
SOFT_STOP_TIME_S);
_state = SOFT_STOPPING;
}
bool BrewControl::toggle()
uint8_t BrewControl::toggle()
{
if(_state)
if(_state == BREWING || _state == PRE_INFUSING)
soft_stop();
else
else if(_state == STOPPED)
start();
return _state;
......
......@@ -28,10 +28,17 @@
#define MODE_TIME 1
#define MODE_VOLUME 2
#define MODE_PRESSURE 3
#define MODE_FLOW_RATE 3
#define MODE_MANUAL 4
#define MODE_PRE_INFUSE 5
// Brew states
#define STOPPED 0
#define BREWING 1
#define PRE_INFUSING 2
#define SOFT_STOPPING 3
#define PORTAFILTER_VOLUME 30
/// This is the main class where all brew functions and sensors are handled
......@@ -91,9 +98,9 @@ public:
uint8_t get_pump_level();
/// Return 1 if currently brewing, 0 if not
bool get_state();
uint8_t get_state();
/// Toggle brewing
bool toggle();
uint8_t toggle();
/// Start brewing, this resets all live variables and based on set targets initiates the right brew mode, returns set mode
uint8_t start();
/// Stop brewing
......@@ -146,7 +153,7 @@ private:
float _target_shot_temperature;
// Operating modes
bool _state;
uint8_t _state;
int _mode;
// These are used for pre-infuse mode to go back to initial settings after
......
......@@ -133,7 +133,7 @@ const char* ITEM_STRINGS[7]= {
};
uint8_t brew_params[NUM_BREW_MENUS][3][3]= {
{ {92, 10, 20}, {0, 0, 0}, {0, 0, 0} },
{ {92, 3, 9}, {0, 0, 0}, {0, 0, 0} },
{ {28, 0, 0}, {0, 0, 0}, {0, 0, 0} },
{ {55, 0, 0}, {0, 0, 0}, {0, 0, 0} },
{ {55, 28, 0}, {55, 28, 0}, {55, 28, 0} }
......@@ -187,6 +187,7 @@ void set_params(uint8_t menu_id)
void draw_menu()
{
uint16_t i, j;
uint8_t state;
string out_s;
lcd_mutex.lock();
// clear screen if required & set
......@@ -198,8 +199,9 @@ void draw_menu()
LCD.set_font((unsigned char*) Small_6);
if (menu_level == L_BREW)
{
state = brew_control.get_state();
// Invert screen while brewing
if (brew_control.get_state())
if (state)
LCD.invert(1);
if (active_menu == M_BREW_MANUAL)
{
......@@ -208,11 +210,36 @@ void draw_menu()
LCD.locate(9,23);
LCD.printf("BREW");
}
else
else if (active_menu == M_BREW_TIME)
{
LCD.locate(5,20);
LCD.locate(5,16);
LCD.printf("TIME");
}
else if (active_menu == M_BREW_YIELD)
{
LCD.locate(4,16);
LCD.printf("YIELD");
}
else if (active_menu == M_BREW_TIME_YIELD)
{
LCD.locate(2,16);
LCD.printf("FLOWRATE");
}
if (state == BREWING)
{
LCD.locate(5,23);
LCD.printf("BREW");
}
else if (state == PRE_INFUSING)
{
LCD.locate(2,23);
LCD.printf("PRE-INFUSE");
}
else if (state == SOFT_STOPPING)
{
LCD.locate(2,23);
LCD.printf("SOFT-STOP");
}
}
else
{
......@@ -221,7 +248,7 @@ void draw_menu()
}
LCD.locate(4,4);
LCD.set_font((unsigned char*) Arial12x12);
LCD.printf("%.1f C %1.f bar %.1f ml/s",
LCD.printf("%.1f C %.1f bar %.1f ml/s",
brew_control.get_current_temperature(),
brew_control.get_current_pressure(),
brew_control.get_current_flow_rate());
......@@ -307,7 +334,12 @@ void menu_handler()
break;
case L_BREW: // send params to brew control b4 brewing
if(!brew_control.get_state())
{
// set general settings
set_params(M_BREW_SETTINGS);
// set brew mode settings
set_params(active_menu);
}
brew_control.toggle();
break;
}
......
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