From c67298118e8473396053b5b050acef5addbfed69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Mon, 7 Dec 2020 00:19:42 +0100 Subject: [PATCH] Improve GUI --- .../include/reflow-controller/ui/gui-config.h | 7 +++++++ stm-firmware/ui/gui.c | 20 +++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 stm-firmware/include/reflow-controller/ui/gui-config.h diff --git a/stm-firmware/include/reflow-controller/ui/gui-config.h b/stm-firmware/include/reflow-controller/ui/gui-config.h new file mode 100644 index 0000000..6ce0722 --- /dev/null +++ b/stm-firmware/include/reflow-controller/ui/gui-config.h @@ -0,0 +1,7 @@ +#ifndef _GUI_CONFIG_H_ +#define _GUI_CONFIG_H_ + +#define GUI_MONITORING_INTERVAL_MS 500U +#define GUI_TEMP_DRIVER_REFRESH_MS 750U + +#endif /* _GUI_CONFIG_H_ */ diff --git a/stm-firmware/ui/gui.c b/stm-firmware/ui/gui.c index dddedbc..e9cbc36 100644 --- a/stm-firmware/ui/gui.c +++ b/stm-firmware/ui/gui.c @@ -19,6 +19,7 @@ */ #include +#include #include #include #include @@ -70,7 +71,7 @@ static void gui_menu_monitor(struct lcd_menu *menu, enum menu_entry_func_entry e menu_display_clear(menu); } - if (systick_ticks_have_passed(my_timestamp, 250)) { + if (systick_ticks_have_passed(my_timestamp, GUI_MONITORING_INTERVAL_MS)) { my_timestamp = systick_get_global_tick(); adc_pt1000_get_current_resistance(&tmp); snprintf(line, sizeof(line), "Res: %.1f " LCD_OHM_SYMBOL_STRING, tmp); @@ -304,12 +305,17 @@ static void gui_menu_constant_temperature_driver(struct lcd_menu *menu, enum men static void IN_SECTION(.ccm.bss) *my_parent; static int16_t IN_SECTION(.ccm.bss) temperature; static bool IN_SECTION(.ccm.bss) fine; + static uint64_t IN_SECTION(.ccm.bss) last_temp_refresh; + static float IN_SECTION(.ccm.bss) last_temp; enum button_state button; + float current_temp; + int status; int16_t rot; int16_t temp_old; if (entry_type == MENU_ENTRY_FIRST_ENTER) { my_parent = parent; + last_temp = -2000.0f; temperature = 30; menu_display_clear(menu); menu_lcd_outputf(menu, 0, "Temp Controller"); @@ -350,7 +356,17 @@ static void gui_menu_constant_temperature_driver(struct lcd_menu *menu, enum men } else { if (temperature != temp_old) { oven_pid_set_target_temperature((float)temperature); - menu_lcd_outputf(menu, 1, "Temp: %d " LCD_DEGREE_SYMBOL_STRING "C", (int)temperature); + menu_lcd_outputf(menu, 1, "Target: %d " LCD_DEGREE_SYMBOL_STRING "C", (int)temperature); + } + + if (entry_type == MENU_ENTRY_FIRST_ENTER || systick_ticks_have_passed(last_temp_refresh, GUI_TEMP_DRIVER_REFRESH_MS)) { + (void)adc_pt1000_get_current_resistance(¤t_temp); + status = temp_converter_convert_resistance_to_temp(current_temp, ¤t_temp); + if (current_temp != last_temp) { + last_temp = current_temp; + menu_lcd_outputf(menu, 2, "Current: %s%.1f", current_temp, (status < 0 ? "<" : status > 0 ? ">" : "")); + } + last_temp_refresh = systick_get_global_tick(); } }