Commit d7cd6ca8 authored by Philippe Kalaf's avatar Philippe Kalaf

More menu work

parent 140cca41
......@@ -226,7 +226,7 @@ void BrewControl::brew_worker()
_shot_clock = 0;
}
// Once pre-infuse time runs out restart everything
// Once pre-infuse time runs out, set brew mode
if (_shot_clock >= _preinfuse_time)
{
_mode = _prev_mode;
......@@ -279,11 +279,12 @@ uint8_t BrewControl::start()
else
_mode = MODE_MANUAL;
// Let's save settings before we go into pre-infuse mode
// Let's save settings before we set pre-infuse mode
if (_preinfuse_time && _mode != MODE_MANUAL)
{
_prev_mode = _mode;
_prev_pressure = get_pump_level();
// set pre-infuse mode
_mode = MODE_PRE_INFUSE;
_pump_control.set_level(45);
}
......@@ -292,7 +293,9 @@ uint8_t BrewControl::start()
_brew_switch = 1;
// Run worker at defined period
_brew_ticker.attach(callback(this, &BrewControl::brew_worker), BREW_WORKER_PERIOD);
if(_mode != MODE_MANUAL)
_brew_ticker.attach(callback(this, &BrewControl::brew_worker),
BREW_WORKER_PERIOD);
return _mode;
}
......@@ -302,6 +305,8 @@ void BrewControl::stop()
_state = 0;
_brew_switch = 0;
_shot_clock = 0;
set_shot_volume(0);
set_shot_time(0);
_flow_sensor.reset_count();
_brew_ticker.detach();
}
......
......@@ -92,6 +92,12 @@ BrewControl brew_control(p10, p15, p12, p13, p20, p14, p26);
#define L_MENU_SUB 2
#define L_BREW 3
#define M_BREW_SETTINGS 0
#define M_BREW_TIME 1
#define M_BREW_YIELD 2
#define M_BREW_TIME_YIELD 3
#define M_BREW_MANUAL 4
// brew menus - 1 because we start at 0
#define NUM_BREW_MENUS 4
......@@ -138,6 +144,38 @@ const uint8_t conversion_table[9][2] = {
{0, 2}, {1, 2}, {2, 2}
};
// takes the params from given menu and give thems to brew control
void set_params(uint8_t menu_id)
{
if (menu_id == M_BREW_MANUAL)
{
brew_control.set_shot_volume(0);
brew_control.set_shot_time(0);
return;
}
uint8_t i;
for(i = 0; i < MENU_ITEMS[1][menu_id]; i++) {
switch (MENU_ITEMS[i+2][menu_id])
{
case PRE_INFUSE_TIME:
brew_control.set_preinfuse_time(
brew_params[menu_id][0][i]);
break;
case YIELD: brew_control.set_shot_volume(
brew_params[menu_id][0][i]);
break;
case SHOT_TIME: brew_control.set_shot_time(
brew_params[menu_id][0][i]);
break;
case TEMPERATURE: brew_control.set_shot_temperature(
brew_params[menu_id][0][i]);
break;
case FLOW_RATE: break;
case PRESSURE: break;
}
}
}
// Draw menu
void draw_menu()
{
......@@ -150,23 +188,45 @@ void draw_menu()
// Standby screen -> Temperature, Pressure, Yield, Shot Clock, Flow Rate
if (menu_level == L_STANDBY || menu_level == L_BREW) {
LCD.set_font((unsigned char*) Small_6);
if (menu_level == L_BREW)
LCD.invert(1);
LCD.locate(1,4);
{
// Invert screen while brewing
if (brew_control.get_state())
LCD.invert(1);
if (cycle_menu == M_BREW_MANUAL)
{
LCD.locate(5,16);
LCD.printf("MANUAL");
LCD.locate(9,23);
LCD.printf("BREW");
}
else
{
LCD.locate(5,20);
LCD.printf("BREW");
}
}
else
{
LCD.locate(5,20);
LCD.printf("STANDBY");
}
LCD.locate(4,4);
LCD.set_font((unsigned char*) Arial12x12);
LCD.printf(" %.1f C %1.f bar %.1f ml/s",
LCD.printf("%.1f C %1.f bar %.1f ml/s",
brew_control.get_current_temperature(),
brew_control.get_current_pressure(),
brew_control.get_current_flow_rate());
LCD.locate(1,17);
LCD.printf(" %d ml %d s",
LCD.locate(55,17);
LCD.printf("%d ml %d s",
brew_control.get_current_volume(),
brew_control.get_current_time());
}
// Show first level menu items (brew modes)
else if (menu_level == L_MENU) {
LCD.locate(0,12);
LCD.set_font((unsigned char*) Arial_9);
LCD.set_font((unsigned char*) Arial12x12);
LCD.printf("%s ", MENU_TITLES[cycle_menu]);
}
// Show second level menu items (brew parameters)
......@@ -196,11 +256,11 @@ void draw_menu()
if (MENU_ITEMS[cycle_menu][1] == 1)
{
LCD.set_font((unsigned char*) Arial12x12);
LCD.locate(0,10);
LCD.locate(0,12);
}
else if (MENU_ITEMS[cycle_menu][1] == 2)
{
LCD.set_font((unsigned char*) Arial_9);
LCD.set_font((unsigned char*) Arial12x12);
LCD.locate(0,6);
}
else
......@@ -232,7 +292,11 @@ void menu_handler()
// exit edit mode
edit_mode = 0;
break;
case L_BREW: menu_level = L_STANDBY; break;
case L_BREW: // send params to brew control b4 brewing
if(!brew_control.get_state())
set_params(cycle_menu);
brew_control.toggle();
break;
}
}
// left
......@@ -242,13 +306,18 @@ void menu_handler()
case L_STANDBY: break;
case L_MENU: menu_level = L_STANDBY; break;
case L_MENU_SUB: if(!edit_mode)
{
menu_level = L_MENU;
// if we exiting settings, let's set them
if(cycle_menu == M_BREW_SETTINGS)
set_params(cycle_menu);
}
else
brew_params[cycle_menu]
[conversion_table[edit_mode-1][0]]
[conversion_table[edit_mode-1][1]]--;
break;
case L_BREW: menu_level = L_STANDBY; break;
case L_BREW: menu_level = L_MENU_SUB; break;
}
}
// up
......@@ -256,13 +325,13 @@ void menu_handler()
switch (menu_level)
{
case L_STANDBY: menu_level = L_MENU; break;
case L_MENU: cycle_menu = (!cycle_menu)?NUM_BREW_MENUS:cycle_menu-1;
case L_MENU: cycle_menu = (!cycle_menu)?cycle_menu:cycle_menu-1;
break;
case L_MENU_SUB: if(edit_mode > 1)
// sub 1 or 3 based on number of phases
edit_mode -= (MENU_ITEMS[cycle_menu][0] == 1)?3:1;
break;
case L_BREW: menu_level = L_STANDBY; break;
case L_BREW: break;
}
}
// right
......@@ -271,28 +340,31 @@ void menu_handler()
{
case L_STANDBY: menu_level = L_MENU; break;
case L_MENU: menu_level = L_MENU_SUB; break;
case L_MENU_SUB: if(!edit_mode)
case L_MENU_SUB: if(!edit_mode && cycle_menu != M_BREW_SETTINGS)
{
menu_level = L_BREW;
}
else
brew_params[cycle_menu]
[conversion_table[edit_mode-1][0]]
[conversion_table[edit_mode-1][1]]++;
break;
case L_BREW: menu_level = L_STANDBY; break;
}
case L_BREW: break;
}
}
// down
else if (event.value.signals == 0x04) {
switch (menu_level)
{
case L_STANDBY: menu_level = L_MENU; break;
case L_MENU: cycle_menu = (cycle_menu < NUM_BREW_MENUS)?cycle_menu+1:0;
case L_MENU: cycle_menu = (cycle_menu < NUM_BREW_MENUS)?cycle_menu+1:cycle_menu;
break;
case L_MENU_SUB: if(edit_mode < (MENU_ITEMS[cycle_menu][1]-1)*3 && edit_mode > 0)
case L_MENU_SUB: if(edit_mode < (MENU_ITEMS[cycle_menu][1]-1)*3
&& edit_mode > 0)
// move fwd by 1 or 3 based on number of phases
edit_mode += (MENU_ITEMS[cycle_menu][0] == 1)?3:1;
break;
case L_BREW: menu_level = L_STANDBY; break;
case L_BREW: 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