Issue #28: Start GUI for Temp Profile execution
This commit is contained in:
parent
a25b249d77
commit
78b63c853f
@ -33,7 +33,7 @@
|
|||||||
/ 2: Enable with LF-CRLF conversion. */
|
/ 2: Enable with LF-CRLF conversion. */
|
||||||
|
|
||||||
|
|
||||||
#define FF_USE_FIND 0
|
#define FF_USE_FIND 1
|
||||||
/* This option switches filtered directory read functions, f_findfirst() and
|
/* This option switches filtered directory read functions, f_findfirst() and
|
||||||
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
|
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
|
||||||
|
|
||||||
|
@ -87,4 +87,6 @@ void menu_list_scroll_up(struct menu_list *list);
|
|||||||
|
|
||||||
void menu_list_enter_selected_entry(struct menu_list *list, struct lcd_menu *menu);
|
void menu_list_enter_selected_entry(struct menu_list *list, struct lcd_menu *menu);
|
||||||
|
|
||||||
|
uint32_t menu_list_get_currently_selected(struct menu_list *list);
|
||||||
|
|
||||||
#endif /* __MENU_H__ */
|
#endif /* __MENU_H__ */
|
||||||
|
@ -695,11 +695,37 @@ shellmatta_retCode_t shell_cmd_execute(const shellmatta_handle_t handle, const c
|
|||||||
uint32_t dlen;
|
uint32_t dlen;
|
||||||
(void)args;
|
(void)args;
|
||||||
(void)len;
|
(void)len;
|
||||||
|
int opt_stat;
|
||||||
|
char option;
|
||||||
|
char *argument;
|
||||||
|
uint32_t arg_len;
|
||||||
|
const char *script_name = NULL;
|
||||||
|
const shellmatta_opt_long_t options[] = {
|
||||||
|
{NULL, '\0', SHELLMATTA_OPT_ARG_NONE},
|
||||||
|
};
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
opt_stat = shellmatta_opt_long(handle, options, &option, &argument, &arg_len);
|
||||||
|
if (opt_stat != SHELLMATTA_OK)
|
||||||
|
break;
|
||||||
|
switch (option) {
|
||||||
|
case '\0':
|
||||||
|
script_name = argument;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!script_name) {
|
||||||
|
shellmatta_printf(handle, "No script name specified!\r\n");
|
||||||
|
return SHELLMATTA_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
shellmatta_read(handle, &data, &dlen);
|
shellmatta_read(handle, &data, &dlen);
|
||||||
|
|
||||||
if (!running) {
|
if (!running) {
|
||||||
res = temp_profile_executer_start("profile.tpr");
|
res = temp_profile_executer_start(script_name);
|
||||||
|
|
||||||
if (res != PL_RET_SUCCESS) {
|
if (res != PL_RET_SUCCESS) {
|
||||||
switch (res) {
|
switch (res) {
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <reflow-controller/oven-driver.h>
|
#include <reflow-controller/oven-driver.h>
|
||||||
|
#include <fatfs/ff.h>
|
||||||
|
|
||||||
static char IN_SECTION(.ccm.bss) display_buffer[4][21] = {0};
|
static char IN_SECTION(.ccm.bss) display_buffer[4][21] = {0};
|
||||||
static struct lcd_menu IN_SECTION(.ccm.bss) reflow_menu;
|
static struct lcd_menu IN_SECTION(.ccm.bss) reflow_menu;
|
||||||
@ -198,7 +199,7 @@ static void gui_menu_about(struct lcd_menu *menu, enum menu_entry_func_entry ent
|
|||||||
uptime_secs = new_uptime_secs;
|
uptime_secs = new_uptime_secs;
|
||||||
menu_lcd_output(menu, 0, "Uptime:");
|
menu_lcd_output(menu, 0, "Uptime:");
|
||||||
menu_lcd_outputf(menu, 1, "%lu day%s %02lu:%02lu:%02lu",
|
menu_lcd_outputf(menu, 1, "%lu day%s %02lu:%02lu:%02lu",
|
||||||
uptime_days, (uptime_days == 1 ? "" : "s"), uptime_hours, uptime_mins, uptime_secs);
|
uptime_days, (uptime_days == 1 ? "" : "s"), uptime_hours, uptime_mins, uptime_secs);
|
||||||
menu_lcd_output(menu, 3, "Page 5/5");
|
menu_lcd_output(menu, 3, "Page 5/5");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -215,7 +216,7 @@ static void gui_menu_about(struct lcd_menu *menu, enum menu_entry_func_entry ent
|
|||||||
button_ready = true;
|
button_ready = true;
|
||||||
|
|
||||||
if (button_ready &&
|
if (button_ready &&
|
||||||
(push_button == BUTTON_SHORT_RELEASED || push_button == BUTTON_LONG)) {
|
(push_button == BUTTON_SHORT_RELEASED || push_button == BUTTON_LONG)) {
|
||||||
menu_entry_dropback(menu, my_parent);
|
menu_entry_dropback(menu, my_parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -372,6 +373,98 @@ static void gui_menu_constant_temperature_driver(struct lcd_menu *menu, enum men
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief load_temperature_file_list_from_sdcard
|
||||||
|
* @return -1 File error, 0 successful
|
||||||
|
*/
|
||||||
|
static int load_temperature_file_list_from_sdcard(char (*list)[17], uint32_t len)
|
||||||
|
{
|
||||||
|
uint32_t i, j;
|
||||||
|
DIR directory;
|
||||||
|
FILINFO finfo;
|
||||||
|
FRESULT fres;
|
||||||
|
|
||||||
|
if (!list)
|
||||||
|
return -1001;
|
||||||
|
|
||||||
|
/* Zero out the list */
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
for (j = 0; j < sizeof(*list); j++) {
|
||||||
|
list[i][j] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* find the frist file */
|
||||||
|
fres = f_findfirst(&directory, &finfo, "/", "*.tpr");
|
||||||
|
i = 0;
|
||||||
|
while (fres == FR_OK && finfo.fname[0]) {
|
||||||
|
strncpy(list[i], finfo.fname, sizeof(*list));
|
||||||
|
fres = f_findnext(&directory, &finfo);
|
||||||
|
i++;
|
||||||
|
if (i >= len)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fres != FR_OK) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int)i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gui_menu_temp_profile_select(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void *parent)
|
||||||
|
{
|
||||||
|
static void *my_parent;
|
||||||
|
static char profile_list[10][17];
|
||||||
|
static bool file_error = false;
|
||||||
|
static uint8_t currently_selected = 0U;
|
||||||
|
static uint8_t current_scroll_offset = 0U;
|
||||||
|
static uint8_t loaded;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
if (entry_type == MENU_ENTRY_FIRST_ENTER) {
|
||||||
|
menu_display_clear(menu);
|
||||||
|
my_parent = parent;
|
||||||
|
res = load_temperature_file_list_from_sdcard(profile_list, 10);
|
||||||
|
file_error = false;
|
||||||
|
loaded = 0;
|
||||||
|
if (res < 0) {
|
||||||
|
file_error = true;
|
||||||
|
}
|
||||||
|
current_scroll_offset = 0u;
|
||||||
|
currently_selected = 0u;
|
||||||
|
loaded = (uint32_t)res;
|
||||||
|
menu_lcd_outputf(menu, 0, "Select:");
|
||||||
|
} else if (entry_type == MENU_ENTRY_DROPBACK) {
|
||||||
|
menu_entry_dropback(menu, my_parent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (menu_get_button_ready_state(menu)) {
|
||||||
|
if (menu_get_button_state(menu) == BUTTON_LONG) {
|
||||||
|
menu_entry_dropback(menu, my_parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file_error) {
|
||||||
|
menu_lcd_outputf(menu, 0, "Disk Error");
|
||||||
|
menu_lcd_outputf(menu, 1, "SD inserted?");
|
||||||
|
if (menu_get_button_state(menu) == BUTTON_SHORT_RELEASED)
|
||||||
|
menu_entry_dropback(menu, my_parent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loaded == 0) {
|
||||||
|
menu_lcd_outputf(menu, 0, "No profiles");
|
||||||
|
menu_lcd_outputf(menu, 1, "found");
|
||||||
|
if (menu_get_button_state(menu) == BUTTON_SHORT_RELEASED)
|
||||||
|
menu_entry_dropback(menu, my_parent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static void gui_menu_constant_temperature_driver_setup(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void *parent)
|
static void gui_menu_constant_temperature_driver_setup(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void *parent)
|
||||||
{
|
{
|
||||||
static void IN_SECTION(.ccm.bss) *my_parent;
|
static void IN_SECTION(.ccm.bss) *my_parent;
|
||||||
@ -412,6 +505,7 @@ static void gui_menu_root_entry(struct lcd_menu *menu, enum menu_entry_func_entr
|
|||||||
bool menu_changed = false;
|
bool menu_changed = false;
|
||||||
static const char * const root_entry_names[] = {
|
static const char * const root_entry_names[] = {
|
||||||
"Constant Temp",
|
"Constant Temp",
|
||||||
|
"Temp Profile",
|
||||||
"Monitoring",
|
"Monitoring",
|
||||||
"Error Flags",
|
"Error Flags",
|
||||||
"About",
|
"About",
|
||||||
@ -419,6 +513,7 @@ static void gui_menu_root_entry(struct lcd_menu *menu, enum menu_entry_func_entr
|
|||||||
};
|
};
|
||||||
static const menu_func_t root_entry_funcs[] = {
|
static const menu_func_t root_entry_funcs[] = {
|
||||||
gui_menu_constant_temperature_driver_setup,
|
gui_menu_constant_temperature_driver_setup,
|
||||||
|
gui_menu_temp_profile_select,
|
||||||
gui_menu_monitor,
|
gui_menu_monitor,
|
||||||
gui_menu_err_flags,
|
gui_menu_err_flags,
|
||||||
gui_menu_about,
|
gui_menu_about,
|
||||||
|
@ -273,3 +273,10 @@ void menu_display_clear(struct lcd_menu *menu)
|
|||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
menu->update_display(i, "");
|
menu->update_display(i, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t menu_list_get_currently_selected(struct menu_list *list)
|
||||||
|
{
|
||||||
|
if (!list)
|
||||||
|
return 0;
|
||||||
|
return list->currently_selected;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user