From b6ccfd701979a1ccf33e15a8b4c6038131b76063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sun, 9 Apr 2023 20:09:34 +0200 Subject: [PATCH] fix manual override. --- Core/Src/Gui/screen_calibration.c | 22 ++++++++++------------ Core/Src/app_heater.c | 2 +- Core/Src/app_temp.c | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Core/Src/Gui/screen_calibration.c b/Core/Src/Gui/screen_calibration.c index 765595e..71a4be1 100644 --- a/Core/Src/Gui/screen_calibration.c +++ b/Core/Src/Gui/screen_calibration.c @@ -35,13 +35,13 @@ static void next_phase() { s_calib.phase++; } -static const char* calib0_opts[] = { +static const char* hello_menu_opts[] = { "Pokračovat", "Zrušit", NULL }; -static void calib0_cb(int opt) { +static void hello_menu_cb(int opt) { switch (opt) { case 0: // Continue @@ -57,16 +57,13 @@ static void calib0_cb(int opt) { } -static const char* calib1_opts[] = { +static const char* sample1_menu_opts[] = { "Vzorek 1", "Zrušit", NULL }; - - - -static void calib1_cb(int opt) { +static void sample1_menu_cb(int opt) { switch (opt) { case 0: // Continue @@ -83,14 +80,14 @@ static void calib1_cb(int opt) { } } -static const char* calib3_opts[] = { +static const char* sample2_menu_opts[] = { "Vzorek 2", "Zrušit", NULL }; -static void calib3_cb(int opt) { +static void sample2_menu_cb(int opt) { switch (opt) { case 0: // Continue @@ -121,7 +118,7 @@ void screen_calibration(GuiEvent event) fb_text(FBW/2, 16, "Vychlaď", TEXT_CENTER, 1); fb_text(FBW/2, 26, "troubu", TEXT_CENTER, 1); } - screen_menu_offset(event, calib0_opts, calib0_cb, 30); + screen_menu_offset(event, hello_menu_opts, hello_menu_cb, 30); break; case PH_SAMPLE1: // Heater is active, waiting for mark @@ -131,9 +128,9 @@ void screen_calibration(GuiEvent event) fb_text(FBW/2, 26, "teplotu", TEXT_CENTER, 1); } if (s_calib.phase == PH_SAMPLE1) { - screen_menu_offset(event, calib1_opts, calib1_cb, 30); + screen_menu_offset(event, sample1_menu_opts, sample1_menu_cb, 30); } else { - screen_menu_offset(event, calib3_opts, calib3_cb, 30); + screen_menu_offset(event, sample2_menu_opts, sample2_menu_cb, 30); } break; @@ -200,6 +197,7 @@ void screen_calibration(GuiEvent event) app_temp_set_calib(a, b); } else { + // for the next phase app_heater_manual_override(100); } break; diff --git a/Core/Src/app_heater.c b/Core/Src/app_heater.c index 9449330..64b81a3 100644 --- a/Core/Src/app_heater.c +++ b/Core/Src/app_heater.c @@ -146,7 +146,7 @@ void app_task_heater(void *argument) if (state.manual_override >= 0 && state.manual_override <= 100) { PRINTF("manual override %d%%\r\n", state.manual_override); - heater_pwm_set_perc(state.pid.Output); + heater_pwm_set_perc(state.manual_override); } else { PID_Compute(&state.pid, state.oven_temp); if (state.pid.ctlMode == PID_AUTOMATIC) { diff --git a/Core/Src/app_temp.c b/Core/Src/app_temp.c index 1519709..431fa73 100644 --- a/Core/Src/app_temp.c +++ b/Core/Src/app_temp.c @@ -313,7 +313,7 @@ void app_temp_sample() float y = s_analog.cal_a * sum + s_analog.cal_b; float actual_temp = val_to_c(y); -// PRINTF("Compensated x %f -> y %f, temp %f C\r\n", sum, y, actual_temp); + PRINTF("T raw %f %f -> comp %f, temp %f°C\r\n", sum, y, actual_temp); s_analog.oven_temp = actual_temp; s_analog.oven_temp_raw = sum;