Merge branch 'issue/25-add-update-to-gui' of mhu/reflow-oven-control-sw into dev
This commit is contained in:
commit
1b2dac21f2
@ -28,6 +28,7 @@
|
|||||||
#include <reflow-controller/safety/safety-controller.h>
|
#include <reflow-controller/safety/safety-controller.h>
|
||||||
#include <reflow-controller/settings/settings.h>
|
#include <reflow-controller/settings/settings.h>
|
||||||
#include <reflow-controller/temp-converter.h>
|
#include <reflow-controller/temp-converter.h>
|
||||||
|
#include <reflow-controller/updater/updater.h>
|
||||||
#include <helper-macros/helper-macros.h>
|
#include <helper-macros/helper-macros.h>
|
||||||
#include <stm-periph/unique-id.h>
|
#include <stm-periph/unique-id.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@ -382,7 +383,7 @@ static void delete_file_list_entry(void *obj)
|
|||||||
free(obj);
|
free(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SlList *load_temp_profile_list_from_sdcard(int *error)
|
static SlList *load_file_list_from_sdcard(int *error, const char *file_pattern)
|
||||||
{
|
{
|
||||||
DIR directory;
|
DIR directory;
|
||||||
FILINFO finfo;
|
FILINFO finfo;
|
||||||
@ -392,7 +393,7 @@ static SlList *load_temp_profile_list_from_sdcard(int *error)
|
|||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
/* find the frist file */
|
/* find the frist file */
|
||||||
fres = f_findfirst(&directory, &finfo, "/", "*.tpr");
|
fres = f_findfirst(&directory, &finfo, "/", file_pattern);
|
||||||
while (fres == FR_OK && finfo.fname[0]) {
|
while (fres == FR_OK && finfo.fname[0]) {
|
||||||
name = malloc(strlen(finfo.fname) + 1);
|
name = malloc(strlen(finfo.fname) + 1);
|
||||||
strcpy(name, finfo.fname);
|
strcpy(name, finfo.fname);
|
||||||
@ -485,7 +486,7 @@ static void gui_menu_temp_profile_select(struct lcd_menu *menu, enum menu_entry_
|
|||||||
sl_list_free_full(file_list, delete_file_list_entry);
|
sl_list_free_full(file_list, delete_file_list_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
file_list = load_temp_profile_list_from_sdcard(&file_error);
|
file_list = load_file_list_from_sdcard(&file_error, "*.tpr");
|
||||||
|
|
||||||
currently_selected = 0u;
|
currently_selected = 0u;
|
||||||
profile_ret_val = PL_RET_SUCCESS;
|
profile_ret_val = PL_RET_SUCCESS;
|
||||||
@ -607,6 +608,84 @@ static void gui_menu_constant_temperature_driver_setup(struct lcd_menu *menu, en
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gui_update_firmware(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void *parent)
|
||||||
|
{
|
||||||
|
static void *my_parent;
|
||||||
|
static SlList *file_list = NULL;
|
||||||
|
static int error;
|
||||||
|
enum button_state button;
|
||||||
|
static uint32_t currently_selected_file;
|
||||||
|
uint32_t previously_selected_file;
|
||||||
|
static uint32_t list_length;
|
||||||
|
const char *fname;
|
||||||
|
int16_t rotary;
|
||||||
|
|
||||||
|
if (entry_type == MENU_ENTRY_FIRST_ENTER) {
|
||||||
|
my_parent = parent;
|
||||||
|
error = 0;
|
||||||
|
list_length = 0;
|
||||||
|
if (file_list)
|
||||||
|
sl_list_free_full(file_list, delete_file_list_entry);
|
||||||
|
file_list = load_file_list_from_sdcard(&error, "*.hex");
|
||||||
|
if (error) {
|
||||||
|
if (file_list)
|
||||||
|
sl_list_free_full(file_list, delete_file_list_entry);
|
||||||
|
file_list = NULL;
|
||||||
|
} else {
|
||||||
|
list_length = sl_list_length(file_list);
|
||||||
|
}
|
||||||
|
currently_selected_file = 0;
|
||||||
|
menu_display_clear(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (menu_get_button_ready_state(menu)) {
|
||||||
|
button = menu_get_button_state(menu);
|
||||||
|
rotary = menu_get_rotary_delta(menu);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
menu_lcd_output(menu, 0, "Error reading");
|
||||||
|
menu_lcd_output(menu, 1, "file list");
|
||||||
|
if (button == BUTTON_LONG || button == BUTTON_SHORT_RELEASED)
|
||||||
|
menu_entry_dropback(menu, my_parent);
|
||||||
|
} else {
|
||||||
|
previously_selected_file = currently_selected_file;
|
||||||
|
|
||||||
|
/* Display the list */
|
||||||
|
if (rotary <= -4) {
|
||||||
|
menu_ack_rotary_delta(menu);
|
||||||
|
if (currently_selected_file > 0) {
|
||||||
|
currently_selected_file--;
|
||||||
|
}
|
||||||
|
} else if (rotary >= 4) {
|
||||||
|
menu_ack_rotary_delta(menu);
|
||||||
|
if (currently_selected_file < (list_length - 1)) {
|
||||||
|
currently_selected_file++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry_type == MENU_ENTRY_FIRST_ENTER ||
|
||||||
|
previously_selected_file != currently_selected_file) {
|
||||||
|
fname = sl_list_nth(file_list, currently_selected_file)->data;
|
||||||
|
menu_lcd_output(menu, 0, "Select File:");
|
||||||
|
if (fname)
|
||||||
|
menu_lcd_output(menu, 1, fname);
|
||||||
|
}
|
||||||
|
if (button == BUTTON_SHORT_RELEASED) {
|
||||||
|
fname = sl_list_nth(file_list, currently_selected_file)->data;
|
||||||
|
menu_display_clear(menu);
|
||||||
|
sl_list_free_full(file_list, delete_file_list_entry);
|
||||||
|
file_list = NULL;
|
||||||
|
|
||||||
|
updater_update_from_file(fname);
|
||||||
|
} else if (button == BUTTON_LONG) {
|
||||||
|
sl_list_free_full(file_list, delete_file_list_entry);
|
||||||
|
file_list = NULL;
|
||||||
|
menu_entry_dropback(menu, my_parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void gui_menu_root_entry(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void *parent)
|
static void gui_menu_root_entry(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void *parent)
|
||||||
{
|
{
|
||||||
(void)parent;
|
(void)parent;
|
||||||
@ -618,6 +697,7 @@ static void gui_menu_root_entry(struct lcd_menu *menu, enum menu_entry_func_entr
|
|||||||
"Monitoring",
|
"Monitoring",
|
||||||
"Error Flags",
|
"Error Flags",
|
||||||
"About",
|
"About",
|
||||||
|
"Update",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
static const menu_func_t root_entry_funcs[] = {
|
static const menu_func_t root_entry_funcs[] = {
|
||||||
@ -626,6 +706,7 @@ static void gui_menu_root_entry(struct lcd_menu *menu, enum menu_entry_func_entr
|
|||||||
gui_menu_monitor,
|
gui_menu_monitor,
|
||||||
gui_menu_err_flags,
|
gui_menu_err_flags,
|
||||||
gui_menu_about,
|
gui_menu_about,
|
||||||
|
gui_update_firmware,
|
||||||
};
|
};
|
||||||
enum button_state push_button;
|
enum button_state push_button;
|
||||||
int16_t rot_delta;
|
int16_t rot_delta;
|
||||||
|
Loading…
Reference in New Issue
Block a user