Implement basic gui for profile selection. Still doesn't do anything
This commit is contained in:
parent
666353e3b7
commit
5deac33949
1
stm-firmware/.gitignore
vendored
1
stm-firmware/.gitignore
vendored
@ -15,3 +15,4 @@ reflow-controller.includes
|
||||
*.config
|
||||
*.files
|
||||
*.user.*
|
||||
*.user
|
||||
|
@ -942,7 +942,7 @@ static shellmatta_cmd_t cmd[21] = {
|
||||
.cmd = "execute",
|
||||
.cmdAlias = NULL,
|
||||
.helpText = "Execute Temp Profile",
|
||||
.usageText = "",
|
||||
.usageText = "execute /path/to/script.tpr",
|
||||
.cmdFct = shell_cmd_execute,
|
||||
.next = NULL,
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ struct pid_controller IN_SECTION(.ccm.bss) pid;
|
||||
|
||||
static struct pl_command IN_SECTION(.ccm.bss) cmd_list[MAX_PROFILE_LENGTH];
|
||||
|
||||
static void abort(void)
|
||||
static void tpe_abort(void)
|
||||
{
|
||||
temp_profile_executer_stop();
|
||||
state.status = TPE_ABORT;
|
||||
@ -54,6 +54,8 @@ enum pl_ret_val temp_profile_executer_start(const char *filename)
|
||||
|
||||
oven_pid_stop();
|
||||
pid_should_run = false;
|
||||
state.status = TPE_OFF;
|
||||
state.profile_steps = 0;
|
||||
|
||||
res = temp_profile_parse_from_file(filename, cmd_list, MAX_PROFILE_LENGTH, &parsed_count);
|
||||
if (res == PL_RET_SUCCESS) {
|
||||
@ -74,7 +76,7 @@ static bool cmd_wait_temp(struct pl_command *cmd, bool cmd_continue)
|
||||
|
||||
res = adc_pt1000_get_current_resistance(&resistance);
|
||||
if (res < 0) {
|
||||
abort();
|
||||
tpe_abort();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -158,15 +160,21 @@ int temp_profile_executer_handle(void)
|
||||
uint32_t next_step;
|
||||
|
||||
|
||||
/* Return if no profile is currently executed */
|
||||
if (state.status != TPE_RUNNING)
|
||||
return -1;
|
||||
|
||||
/* Abort profile execution if oven PID is aborted. This is most likely due to some error flags */
|
||||
if (oven_pid_get_status() == OVEN_PID_ABORTED && pid_should_run) {
|
||||
abort();
|
||||
tpe_abort();
|
||||
oven_pid_stop();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (systick_ticks_have_passed(last_tick, 100)) {
|
||||
/* Execute Temp Profile every 100 ms. If not yet due, return */
|
||||
if (!systick_ticks_have_passed(last_tick, 100))
|
||||
return 0;
|
||||
|
||||
current_cmd = &cmd_list[state.step];
|
||||
next_step = state.step;
|
||||
|
||||
@ -205,7 +213,7 @@ int temp_profile_executer_handle(void)
|
||||
advance = cmd_ramp(current_cmd, cmd_continue);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
tpe_abort();
|
||||
advance = true;
|
||||
break;
|
||||
}
|
||||
@ -224,7 +232,6 @@ int temp_profile_executer_handle(void)
|
||||
cmd_continue = true;
|
||||
}
|
||||
last_tick = systick_get_global_tick();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <reflow-controller/oven-driver.h>
|
||||
#include <fatfs/ff.h>
|
||||
#include <reflow-controller/temp-profile-executer.h>
|
||||
|
||||
static char IN_SECTION(.ccm.bss) display_buffer[4][21] = {0};
|
||||
static struct lcd_menu IN_SECTION(.ccm.bss) reflow_menu;
|
||||
@ -417,9 +418,12 @@ static void gui_menu_temp_profile_select(struct lcd_menu *menu, enum menu_entry_
|
||||
static void *my_parent;
|
||||
static char profile_list[10][17];
|
||||
static bool file_error = false;
|
||||
static enum pl_ret_val profile_ret_val = PL_RET_SUCCESS;
|
||||
static uint8_t currently_selected = 0U;
|
||||
static uint8_t current_scroll_offset = 0U;
|
||||
static uint8_t loaded;
|
||||
int16_t delta;
|
||||
enum button_state button;
|
||||
|
||||
int res;
|
||||
|
||||
if (entry_type == MENU_ENTRY_FIRST_ENTER) {
|
||||
@ -431,7 +435,7 @@ static void gui_menu_temp_profile_select(struct lcd_menu *menu, enum menu_entry_
|
||||
if (res < 0) {
|
||||
file_error = true;
|
||||
}
|
||||
current_scroll_offset = 0u;
|
||||
|
||||
currently_selected = 0u;
|
||||
loaded = (uint32_t)res;
|
||||
menu_lcd_outputf(menu, 0, "Select:");
|
||||
@ -441,28 +445,49 @@ static void gui_menu_temp_profile_select(struct lcd_menu *menu, enum menu_entry_
|
||||
}
|
||||
|
||||
if (menu_get_button_ready_state(menu)) {
|
||||
if (menu_get_button_state(menu) == BUTTON_LONG) {
|
||||
delta = menu_get_rotary_delta(menu);
|
||||
button = menu_get_button_state(menu);
|
||||
|
||||
if (button == 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)
|
||||
if (button == BUTTON_SHORT_RELEASED)
|
||||
menu_entry_dropback(menu, my_parent);
|
||||
return;
|
||||
}
|
||||
|
||||
if (loaded == 0) {
|
||||
} else 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)
|
||||
if (button == BUTTON_SHORT_RELEASED)
|
||||
menu_entry_dropback(menu, my_parent);
|
||||
return;
|
||||
}
|
||||
} else if (profile_ret_val != PL_RET_SUCCESS) {
|
||||
menu_lcd_outputf(menu, 0, "Profile Error");
|
||||
if (button == BUTTON_SHORT_RELEASED)
|
||||
menu_entry_dropback(menu, my_parent);
|
||||
return;
|
||||
} else if (currently_selected < loaded) {
|
||||
/* Show currently selected profile */
|
||||
menu_lcd_outputf(menu, 1, "%s", &profile_list[currently_selected][0]);
|
||||
|
||||
if (button == BUTTON_SHORT_RELEASED) {
|
||||
/* Execute selected profile */
|
||||
}
|
||||
|
||||
|
||||
if (delta >= 4) {
|
||||
menu_ack_rotary_delta(menu);
|
||||
if (currently_selected < (loaded - 1))
|
||||
currently_selected++;
|
||||
} else if (delta <= -4) {
|
||||
menu_ack_rotary_delta(menu);
|
||||
if (currently_selected > 0)
|
||||
currently_selected--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void gui_menu_constant_temperature_driver_setup(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void *parent)
|
||||
|
Loading…
Reference in New Issue
Block a user