Issue #17: Add ui-emulate command to shell

This commit is contained in:
Mario Hüttel 2020-08-30 18:44:36 +02:00
parent 0da6925119
commit f32d1afde5
1 changed files with 63 additions and 12 deletions

View File

@ -37,6 +37,7 @@
#include <reflow-controller/rotary-encoder.h>
#include <reflow-controller/safety/safety-controller.h>
#include <reflow-controller/settings/settings.h>
#include <reflow-controller/button.h>
#ifndef GIT_VER
#define GIT_VER "VERSION NOT SET"
@ -60,7 +61,7 @@ static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle,
unique_id_get(&high_id, &mid_id, &low_id);
shellmatta_printf(handle, "Reflow Oven Controller Firmware " xstr(GIT_VER) "\r\n"
"Compiled: " __DATE__ " at " __TIME__ "\r\n");
"Compiled: " __DATE__ " at " __TIME__ "\r\n");
shellmatta_printf(handle, "Serial: %08X-%08X-%08X", high_id, mid_id, low_id);
return SHELLMATTA_OK;
@ -180,10 +181,10 @@ static shellmatta_retCode_t shell_cmd_uptime(const shellmatta_handle_t handle,
systick_get_uptime_from_tick(&days, &hours, &mins, &secs);
shellmatta_printf(handle, "Uptime: %u day%s %02u:%02u:%02u",
days, (days == 1 ? "" : "s"),
hours,
mins,
secs);
days, (days == 1 ? "" : "s"),
hours,
mins,
secs);
return SHELLMATTA_OK;
}
@ -344,7 +345,7 @@ static shellmatta_retCode_t shell_cmd_cat(const shellmatta_handle_t handle, cons
}
static shellmatta_retCode_t shell_cmd_read_flags(const shellmatta_handle_t handle, const char *arguments,
uint32_t length)
uint32_t length)
{
(void)length;
(void)arguments;
@ -357,7 +358,7 @@ static shellmatta_retCode_t shell_cmd_read_flags(const shellmatta_handle_t handl
struct timing_monitor_info timing_info;
shellmatta_printf(handle, "Error flags\r\n"
"-----------\r\n");
"-----------\r\n");
count = safety_controller_get_flag_count();
for (i = 0; i < count; i++) {
@ -406,7 +407,7 @@ static shellmatta_retCode_t shell_cmd_read_flags(const shellmatta_handle_t handl
}
shellmatta_printf(handle, "\r\nTiming Monitors\r\n"
"--------------\r\n");
"--------------\r\n");
count = safety_controller_get_timing_monitor_count();
@ -425,7 +426,7 @@ static shellmatta_retCode_t shell_cmd_read_flags(const shellmatta_handle_t handl
}
static shellmatta_retCode_t shell_cmd_save_cal(const shellmatta_handle_t handle, const char *arguments,
uint32_t length)
uint32_t length)
{
(void)length;
@ -447,7 +448,7 @@ static shellmatta_retCode_t shell_cmd_save_cal(const shellmatta_handle_t handle,
}
static shellmatta_retCode_t shell_cmd_hang(const shellmatta_handle_t handle, const char *arguments,
uint32_t length)
uint32_t length)
{
(void)handle;
(void)arguments;
@ -458,6 +459,48 @@ static shellmatta_retCode_t shell_cmd_hang(const shellmatta_handle_t handle, con
return SHELLMATTA_OK;
}
static shellmatta_retCode_t shell_cmd_ui_emulation(const shellmatta_handle_t handle, const char *arguments,
uint32_t length)
{
(void)length;
(void)arguments;
uint32_t i;
uint32_t len;
char *buff;
shellmatta_read(handle, &buff, &len);
for (i = 0; i < len; i++) {
switch (buff[i]) {
case 'W':
case 'w':
rotary_encoder_override_delta(4);
break;
case 's':
case 'S':
rotary_encoder_override_delta(-4);
break;
case '\r':
button_override_event(BUTTON_SHORT_RELEASED);
break;
case 'l':
case 'L':
button_override_event(BUTTON_LONG);
break;
case 'k':
case 'K':
button_override_event(BUTTON_SHORT);
break;
case 'r':
case 'R':
button_override_event(BUTTON_LONG_RELEASED);
break;
}
}
return SHELLMATTA_CONTINUE;
}
//typedef struct shellmatta_cmd
//{
// char *cmd; /**< command name */
@ -467,7 +510,7 @@ static shellmatta_retCode_t shell_cmd_hang(const shellmatta_handle_t handle, con
// shellmatta_cmdFct_t cmdFct; /**< pointer to the cmd callack function */
// struct shellmatta_cmd *next; /**< pointer to next command or NULL */
//} shellmatta_cmd_t;
static shellmatta_cmd_t cmd[15] = {
static shellmatta_cmd_t cmd[16] = {
{
.cmd = "version",
.cmdAlias = "ver",
@ -586,8 +629,16 @@ static shellmatta_cmd_t cmd[15] = {
.helpText = "",
.usageText = "",
.cmdFct = shell_cmd_hang,
.next = &cmd[15],
},
{
.cmd = "ui-emulate",
.cmdAlias = NULL,
.helpText = "",
.usageText = "",
.cmdFct = shell_cmd_ui_emulation,
.next = NULL,
}
},
};
shellmatta_handle_t shell_init(shellmatta_write_t write_func)