|
|
@ -30,6 +30,17 @@ enum Phase { |
|
|
|
PH_DONE, |
|
|
|
PH_DONE, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void stop_heater() { |
|
|
|
|
|
|
|
app_heater_set_target(0); |
|
|
|
|
|
|
|
app_heater_enable(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void calib_abort() { |
|
|
|
|
|
|
|
app_temp_restore_calib(); |
|
|
|
|
|
|
|
stop_heater(); |
|
|
|
|
|
|
|
switch_screen(screen_home, true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void next_phase() { |
|
|
|
static void next_phase() { |
|
|
|
PUTS("Phase++\r\n"); |
|
|
|
PUTS("Phase++\r\n"); |
|
|
|
s_calib.phase++; |
|
|
|
s_calib.phase++; |
|
|
@ -47,11 +58,12 @@ static void hello_menu_cb(int opt) { |
|
|
|
// Continue
|
|
|
|
// Continue
|
|
|
|
next_phase(); |
|
|
|
next_phase(); |
|
|
|
request_paint(); |
|
|
|
request_paint(); |
|
|
|
app_heater_manual_override(100); |
|
|
|
app_heater_set_target(100); |
|
|
|
|
|
|
|
app_heater_enable(true); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
switch_screen(screen_home, true); |
|
|
|
calib_abort(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -70,12 +82,11 @@ static void sample1_menu_cb(int opt) { |
|
|
|
next_phase(); |
|
|
|
next_phase(); |
|
|
|
request_paint(); |
|
|
|
request_paint(); |
|
|
|
s_calib.sample1 = app_temp_read_oven_raw(); |
|
|
|
s_calib.sample1 = app_temp_read_oven_raw(); |
|
|
|
app_heater_manual_override(0); |
|
|
|
app_heater_enable(false); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
app_heater_manual_override(-1); |
|
|
|
calib_abort(); |
|
|
|
switch_screen(screen_home, true); |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -94,12 +105,11 @@ static void sample2_menu_cb(int opt) { |
|
|
|
next_phase(); |
|
|
|
next_phase(); |
|
|
|
request_paint(); |
|
|
|
request_paint(); |
|
|
|
s_calib.sample2 = app_temp_read_oven_raw(); |
|
|
|
s_calib.sample2 = app_temp_read_oven_raw(); |
|
|
|
app_heater_manual_override(0); |
|
|
|
app_heater_enable(false); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
app_heater_manual_override(-1); |
|
|
|
calib_abort(); |
|
|
|
switch_screen(screen_home, true); |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -107,6 +117,8 @@ static void sample2_menu_cb(int opt) { |
|
|
|
void screen_calibration(GuiEvent event) |
|
|
|
void screen_calibration(GuiEvent event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (event == GUI_EVENT_SCREEN_INIT) { |
|
|
|
if (event == GUI_EVENT_SCREEN_INIT) { |
|
|
|
|
|
|
|
app_temp_backup_calib(); |
|
|
|
|
|
|
|
app_temp_set_calib_temporary(1, 0); |
|
|
|
memset(&s_calib, 0, sizeof(s_calib)); |
|
|
|
memset(&s_calib, 0, sizeof(s_calib)); |
|
|
|
// continue to the rest - so the menu can be inited
|
|
|
|
// continue to the rest - so the menu can be inited
|
|
|
|
} |
|
|
|
} |
|
|
@ -121,17 +133,20 @@ void screen_calibration(GuiEvent event) |
|
|
|
screen_menu_offset(event, hello_menu_opts, hello_menu_cb, 30); |
|
|
|
screen_menu_offset(event, hello_menu_opts, hello_menu_cb, 30); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case PH_SAMPLE1: // Heater is active, waiting for mark
|
|
|
|
case PH_SAMPLE1: |
|
|
|
case PH_SAMPLE2: |
|
|
|
|
|
|
|
if (event == GUI_EVENT_PAINT) { |
|
|
|
if (event == GUI_EVENT_PAINT) { |
|
|
|
fb_text(FBW/2, 16, "Zapiš", TEXT_CENTER, 1); |
|
|
|
fb_text(FBW/2, 16, "Vyčkej", TEXT_CENTER, 1); |
|
|
|
fb_text(FBW/2, 26, "teplotu", TEXT_CENTER, 1); |
|
|
|
fb_text(FBW/2, 26, "ustálení", TEXT_CENTER, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
if (s_calib.phase == PH_SAMPLE1) { |
|
|
|
screen_menu_offset(event, sample1_menu_opts, sample1_menu_cb, 30); |
|
|
|
screen_menu_offset(event, sample1_menu_opts, sample1_menu_cb, 30); |
|
|
|
break; |
|
|
|
} else { |
|
|
|
|
|
|
|
screen_menu_offset(event, sample2_menu_opts, sample2_menu_cb, 30); |
|
|
|
case PH_SAMPLE2: |
|
|
|
|
|
|
|
if (event == GUI_EVENT_PAINT) { |
|
|
|
|
|
|
|
fb_text(FBW/2, 16, "Vyčkej", TEXT_CENTER, 1); |
|
|
|
|
|
|
|
fb_text(FBW/2, 26, "ustálení", TEXT_CENTER, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
screen_menu_offset(event, sample2_menu_opts, sample2_menu_cb, 30); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case PH_TEMP1: |
|
|
|
case PH_TEMP1: |
|
|
@ -144,8 +159,7 @@ void screen_calibration(GuiEvent event) |
|
|
|
|
|
|
|
|
|
|
|
if (push_time() > pdMS_TO_TICKS(500)) { |
|
|
|
if (push_time() > pdMS_TO_TICKS(500)) { |
|
|
|
input_sound_effect(); |
|
|
|
input_sound_effect(); |
|
|
|
app_heater_manual_override_clear(); |
|
|
|
calib_abort(); |
|
|
|
switch_screen(screen_home, true); |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -184,7 +198,9 @@ void screen_calibration(GuiEvent event) |
|
|
|
request_paint(); |
|
|
|
request_paint(); |
|
|
|
|
|
|
|
|
|
|
|
if (s_calib.phase == PH_DONE) { |
|
|
|
if (s_calib.phase == PH_DONE) { |
|
|
|
app_heater_manual_override(-1); |
|
|
|
app_heater_set_target(0); |
|
|
|
|
|
|
|
app_heater_enable(false); |
|
|
|
|
|
|
|
|
|
|
|
// TODO do the math
|
|
|
|
// TODO do the math
|
|
|
|
PRINTF("Sample 1 %f, T1 %d\r\n", s_calib.sample1, s_calib.temp1); |
|
|
|
PRINTF("Sample 1 %f, T1 %d\r\n", s_calib.sample1, s_calib.temp1); |
|
|
|
PRINTF("Sample 2 %f, T2 %d\r\n", s_calib.sample2, s_calib.temp2); |
|
|
|
PRINTF("Sample 2 %f, T2 %d\r\n", s_calib.sample2, s_calib.temp2); |
|
|
@ -195,10 +211,13 @@ void screen_calibration(GuiEvent event) |
|
|
|
float a = (corrected1 - corrected2) / (s_calib.sample1 - s_calib.sample2); |
|
|
|
float a = (corrected1 - corrected2) / (s_calib.sample1 - s_calib.sample2); |
|
|
|
float b = corrected1 - a * s_calib.sample1; |
|
|
|
float b = corrected1 - a * s_calib.sample1; |
|
|
|
|
|
|
|
|
|
|
|
app_temp_set_calib(a, b); |
|
|
|
app_temp_set_persistent_calib(a, b); |
|
|
|
} else { |
|
|
|
} else if (s_calib.phase == PH_SAMPLE1) { |
|
|
|
// for the next phase
|
|
|
|
app_heater_set_target(100); |
|
|
|
app_heater_manual_override(100); |
|
|
|
app_heater_enable(true); |
|
|
|
|
|
|
|
} else if (s_calib.phase == PH_SAMPLE2) { |
|
|
|
|
|
|
|
app_heater_set_target(200); |
|
|
|
|
|
|
|
app_heater_enable(true); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -211,6 +230,7 @@ void screen_calibration(GuiEvent event) |
|
|
|
fb_text(FBW/2, 36, "→Hlavní menu", TEXT_CENTER, 1); |
|
|
|
fb_text(FBW/2, 36, "→Hlavní menu", TEXT_CENTER, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
if (event == GUI_EVENT_KNOB_RELEASE) { |
|
|
|
if (event == GUI_EVENT_KNOB_RELEASE) { |
|
|
|
|
|
|
|
stop_heater(); |
|
|
|
switch_screen(screen_home, 1); |
|
|
|
switch_screen(screen_home, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|