Fix #17: Merge branch 'issue/17-rotary-emulation-cmd' into dev
This commit is contained in:
commit
3dfe59482e
@ -58,3 +58,31 @@ Calibration is most likely not necessary! See the :ref:`usage_calibration` page.
|
|||||||
|
|
||||||
The command will guide you through the calibration process and will ask for two reference resistors with ``1000 Ohm`` and ``2000 Ohm`` values.
|
The command will guide you through the calibration process and will ask for two reference resistors with ``1000 Ohm`` and ``2000 Ohm`` values.
|
||||||
Calibration can be aborted using ``CTRL + C``.
|
Calibration can be aborted using ``CTRL + C``.
|
||||||
|
|
||||||
|
|
||||||
|
.. _shell_command_hang:
|
||||||
|
|
||||||
|
hang
|
||||||
|
~~~~
|
||||||
|
|
||||||
|
The ``hang`` command hangs the main-loop in an infinite loop. This function tests, whether the controller is correctly rescued by the watchdog.
|
||||||
|
|
||||||
|
|
||||||
|
.. _shell_command_ui_emulate:
|
||||||
|
|
||||||
|
ui-emulate
|
||||||
|
~~~~~~~~~~
|
||||||
|
|
||||||
|
The ``ui-emulate`` command emulates the rotary encoder and button from the shell. The following keys are available:
|
||||||
|
|
||||||
|
========== ================================
|
||||||
|
Key Emulation
|
||||||
|
========== ================================
|
||||||
|
``CTRL+C`` Exit the command
|
||||||
|
``ENTER`` Button press: short released
|
||||||
|
``s`` Rotary Encoder: anti-clockwise
|
||||||
|
``w`` Rotary Encoder: clockwise
|
||||||
|
``l`` Button press: long
|
||||||
|
``k`` Button press: short
|
||||||
|
``r`` Button press: long released
|
||||||
|
========== ================================
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
static volatile uint64_t IN_SECTION(.ccm.bss) to_active_timestamp;
|
static volatile uint64_t IN_SECTION(.ccm.bss) to_active_timestamp;
|
||||||
static volatile enum button_state IN_SECTION(.ccm.bss) int_state;
|
static volatile enum button_state IN_SECTION(.ccm.bss) int_state;
|
||||||
|
static volatile enum button_state IN_SECTION(.ccm.bss) override_state;
|
||||||
|
|
||||||
void button_init()
|
void button_init()
|
||||||
{
|
{
|
||||||
@ -40,6 +41,7 @@ void button_init()
|
|||||||
|
|
||||||
to_active_timestamp = 0ULL;
|
to_active_timestamp = 0ULL;
|
||||||
int_state = BUTTON_IDLE;
|
int_state = BUTTON_IDLE;
|
||||||
|
override_state = BUTTON_IDLE;
|
||||||
|
|
||||||
SYSCFG->EXTICR[1] |= 0x3;
|
SYSCFG->EXTICR[1] |= 0x3;
|
||||||
EXTI->IMR |= (1U<<4);
|
EXTI->IMR |= (1U<<4);
|
||||||
@ -53,6 +55,12 @@ enum button_state button_read_event()
|
|||||||
uint64_t time_delta;
|
uint64_t time_delta;
|
||||||
enum button_state temp_state;
|
enum button_state temp_state;
|
||||||
|
|
||||||
|
if (override_state != BUTTON_IDLE) {
|
||||||
|
temp_state = override_state;
|
||||||
|
override_state = BUTTON_IDLE;
|
||||||
|
return temp_state;
|
||||||
|
}
|
||||||
|
|
||||||
if (BUTTON_PORT->IDR & (1U<<BUTTON_PIN)) {
|
if (BUTTON_PORT->IDR & (1U<<BUTTON_PIN)) {
|
||||||
temp_state = int_state;
|
temp_state = int_state;
|
||||||
int_state = BUTTON_IDLE;
|
int_state = BUTTON_IDLE;
|
||||||
@ -96,3 +104,8 @@ void EXTI4_IRQHandler(void)
|
|||||||
to_active_timestamp = systick_get_global_tick();
|
to_active_timestamp = systick_get_global_tick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void button_override_event(enum button_state state)
|
||||||
|
{
|
||||||
|
override_state = state;
|
||||||
|
}
|
||||||
|
@ -72,5 +72,10 @@ enum button_state button_read_event();
|
|||||||
*/
|
*/
|
||||||
void button_deinit();
|
void button_deinit();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function overrides the button event.
|
||||||
|
* @param state State to set
|
||||||
|
*/
|
||||||
|
void button_override_event(enum button_state state);
|
||||||
|
|
||||||
#endif /* __BUTTON_H__ */
|
#endif /* __BUTTON_H__ */
|
||||||
|
@ -41,4 +41,6 @@ void rotary_encoder_stop(void);
|
|||||||
|
|
||||||
void rotary_encoder_zero(void);
|
void rotary_encoder_zero(void);
|
||||||
|
|
||||||
|
void rotary_encoder_override_delta(int16_t delta);
|
||||||
|
|
||||||
#endif /* __ROTARY_ENCODER_H__ */
|
#endif /* __ROTARY_ENCODER_H__ */
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include <stm-periph/stm32-gpio-macros.h>
|
#include <stm-periph/stm32-gpio-macros.h>
|
||||||
#include <helper-macros/helper-macros.h>
|
#include <helper-macros/helper-macros.h>
|
||||||
|
|
||||||
|
static int16_t IN_SECTION(.ccm.bss) override_delta;
|
||||||
|
|
||||||
static inline void rotary_encoder_setup_pins(void)
|
static inline void rotary_encoder_setup_pins(void)
|
||||||
{
|
{
|
||||||
rcc_manager_enable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(ROTARY_ENCODER_RCC_MASK));
|
rcc_manager_enable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(ROTARY_ENCODER_RCC_MASK));
|
||||||
@ -45,6 +47,8 @@ void rotary_encoder_setup(void)
|
|||||||
ROTARY_ENCODER_TIMER->CCER = TIM_CCER_CC1P | TIM_CCER_CC2P;
|
ROTARY_ENCODER_TIMER->CCER = TIM_CCER_CC1P | TIM_CCER_CC2P;
|
||||||
ROTARY_ENCODER_TIMER->PSC = 0;
|
ROTARY_ENCODER_TIMER->PSC = 0;
|
||||||
ROTARY_ENCODER_TIMER->CR1 = TIM_CR1_CEN;
|
ROTARY_ENCODER_TIMER->CR1 = TIM_CR1_CEN;
|
||||||
|
|
||||||
|
override_delta = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t rotary_encoder_get_abs_val(void)
|
uint32_t rotary_encoder_get_abs_val(void)
|
||||||
@ -72,6 +76,9 @@ int32_t rotary_encoder_get_change_val(void)
|
|||||||
|
|
||||||
last_val = val;
|
last_val = val;
|
||||||
|
|
||||||
|
diff += override_delta;
|
||||||
|
override_delta = 0;
|
||||||
|
|
||||||
return diff;
|
return diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,3 +95,8 @@ void rotary_encoder_zero(void)
|
|||||||
{
|
{
|
||||||
ROTARY_ENCODER_TIMER->CNT = 0UL;
|
ROTARY_ENCODER_TIMER->CNT = 0UL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rotary_encoder_override_delta(int16_t delta)
|
||||||
|
{
|
||||||
|
override_delta = delta;
|
||||||
|
}
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include <reflow-controller/rotary-encoder.h>
|
#include <reflow-controller/rotary-encoder.h>
|
||||||
#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/button.h>
|
||||||
|
|
||||||
#ifndef GIT_VER
|
#ifndef GIT_VER
|
||||||
#define GIT_VER "VERSION NOT SET"
|
#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);
|
unique_id_get(&high_id, &mid_id, &low_id);
|
||||||
|
|
||||||
shellmatta_printf(handle, "Reflow Oven Controller Firmware " xstr(GIT_VER) "\r\n"
|
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);
|
shellmatta_printf(handle, "Serial: %08X-%08X-%08X", high_id, mid_id, low_id);
|
||||||
|
|
||||||
return SHELLMATTA_OK;
|
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);
|
systick_get_uptime_from_tick(&days, &hours, &mins, &secs);
|
||||||
|
|
||||||
shellmatta_printf(handle, "Uptime: %u day%s %02u:%02u:%02u",
|
shellmatta_printf(handle, "Uptime: %u day%s %02u:%02u:%02u",
|
||||||
days, (days == 1 ? "" : "s"),
|
days, (days == 1 ? "" : "s"),
|
||||||
hours,
|
hours,
|
||||||
mins,
|
mins,
|
||||||
secs);
|
secs);
|
||||||
return SHELLMATTA_OK;
|
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,
|
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)length;
|
||||||
(void)arguments;
|
(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;
|
struct timing_monitor_info timing_info;
|
||||||
|
|
||||||
shellmatta_printf(handle, "Error flags\r\n"
|
shellmatta_printf(handle, "Error flags\r\n"
|
||||||
"-----------\r\n");
|
"-----------\r\n");
|
||||||
|
|
||||||
count = safety_controller_get_flag_count();
|
count = safety_controller_get_flag_count();
|
||||||
for (i = 0; i < count; i++) {
|
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"
|
shellmatta_printf(handle, "\r\nTiming Monitors\r\n"
|
||||||
"--------------\r\n");
|
"--------------\r\n");
|
||||||
|
|
||||||
|
|
||||||
count = safety_controller_get_timing_monitor_count();
|
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,
|
static shellmatta_retCode_t shell_cmd_save_cal(const shellmatta_handle_t handle, const char *arguments,
|
||||||
uint32_t length)
|
uint32_t length)
|
||||||
|
|
||||||
{
|
{
|
||||||
(void)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,
|
static shellmatta_retCode_t shell_cmd_hang(const shellmatta_handle_t handle, const char *arguments,
|
||||||
uint32_t length)
|
uint32_t length)
|
||||||
{
|
{
|
||||||
(void)handle;
|
(void)handle;
|
||||||
(void)arguments;
|
(void)arguments;
|
||||||
@ -458,6 +459,48 @@ static shellmatta_retCode_t shell_cmd_hang(const shellmatta_handle_t handle, con
|
|||||||
return SHELLMATTA_OK;
|
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
|
//typedef struct shellmatta_cmd
|
||||||
//{
|
//{
|
||||||
// char *cmd; /**< command name */
|
// 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 */
|
// shellmatta_cmdFct_t cmdFct; /**< pointer to the cmd callack function */
|
||||||
// struct shellmatta_cmd *next; /**< pointer to next command or NULL */
|
// struct shellmatta_cmd *next; /**< pointer to next command or NULL */
|
||||||
//} shellmatta_cmd_t;
|
//} shellmatta_cmd_t;
|
||||||
static shellmatta_cmd_t cmd[15] = {
|
static shellmatta_cmd_t cmd[16] = {
|
||||||
{
|
{
|
||||||
.cmd = "version",
|
.cmd = "version",
|
||||||
.cmdAlias = "ver",
|
.cmdAlias = "ver",
|
||||||
@ -586,8 +629,16 @@ static shellmatta_cmd_t cmd[15] = {
|
|||||||
.helpText = "",
|
.helpText = "",
|
||||||
.usageText = "",
|
.usageText = "",
|
||||||
.cmdFct = shell_cmd_hang,
|
.cmdFct = shell_cmd_hang,
|
||||||
|
.next = &cmd[15],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.cmd = "ui-emulate",
|
||||||
|
.cmdAlias = NULL,
|
||||||
|
.helpText = "",
|
||||||
|
.usageText = "",
|
||||||
|
.cmdFct = shell_cmd_ui_emulation,
|
||||||
.next = NULL,
|
.next = NULL,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
shellmatta_handle_t shell_init(shellmatta_write_t write_func)
|
shellmatta_handle_t shell_init(shellmatta_write_t write_func)
|
||||||
|
Loading…
Reference in New Issue
Block a user