增加了语音抽签控制屏幕显示
增加了校准和财位控制电机旋转
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
/* Liveness safety bound for the fixed two-cycle wealth spin intro (not the
|
||||
* animation length). On timeout the worker proceeds to reveal + rotate anyway. */
|
||||
#define CONTROL_PLANE_SPIN_INTRO_TIMEOUT_MS 6000
|
||||
#define CONTROL_PLANE_COMMAND_ROTATION_DEG 45.0f
|
||||
|
||||
#if (configSUPPORT_STATIC_ALLOCATION == 1) && \
|
||||
((defined(CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM) && CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM) || \
|
||||
@@ -128,6 +129,8 @@ typedef struct {
|
||||
control_plane_model_command_type_t command_type;
|
||||
bool stop_requested;
|
||||
char value[32];
|
||||
size_t value_index;
|
||||
bool value_index_valid;
|
||||
} control_plane_model_command_t;
|
||||
|
||||
typedef enum {
|
||||
@@ -654,6 +657,8 @@ static void control_plane_task_start_gate(void *arg)
|
||||
|
||||
static void control_plane_on_model_command(control_plane_model_command_type_t command_type,
|
||||
const char *value,
|
||||
size_t value_index,
|
||||
bool value_index_valid,
|
||||
void *user_data)
|
||||
{
|
||||
(void)user_data;
|
||||
@@ -667,6 +672,8 @@ static void control_plane_on_model_command(control_plane_model_command_type_t co
|
||||
.command_type = command_type,
|
||||
.stop_requested = false,
|
||||
.value = {0},
|
||||
.value_index = value_index,
|
||||
.value_index_valid = value_index_valid,
|
||||
};
|
||||
if (value != NULL) {
|
||||
strlcpy(cmd.value, value, sizeof(cmd.value));
|
||||
@@ -707,7 +714,33 @@ static esp_err_t control_plane_apply_wealth_direction(size_t direction_index,
|
||||
ESP_LOGW(TAG, "Wealth reveal request failed: %s", esp_err_to_name(reveal_err));
|
||||
}
|
||||
|
||||
return control_plane_rotate_to_direction(direction_index);
|
||||
(void)direction_index;
|
||||
|
||||
float current_angle = domain_get_current_angle();
|
||||
return control_plane_rotate_to_angle(current_angle + CONTROL_PLANE_COMMAND_ROTATION_DEG);
|
||||
}
|
||||
|
||||
static esp_err_t control_plane_run_model_calibration_motion(void)
|
||||
{
|
||||
float start_angle = domain_get_current_angle();
|
||||
|
||||
esp_err_t err = control_plane_rotate_to_angle(start_angle + CONTROL_PLANE_COMMAND_ROTATION_DEG);
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return control_plane_rotate_to_angle(start_angle);
|
||||
}
|
||||
|
||||
static esp_err_t control_plane_show_chouqian_expression(size_t result_index, bool result_index_valid)
|
||||
{
|
||||
const domain_expression_request_t request = {
|
||||
.id = DOMAIN_EXPRESSION_CHOUQIAN,
|
||||
.trigger = DOMAIN_EXPRESSION_TRIGGER_MODEL_DIRECTION,
|
||||
.chouqian_result_index = result_index,
|
||||
.chouqian_result_index_valid = result_index_valid,
|
||||
};
|
||||
return domain_runtime_request_expression(&request);
|
||||
}
|
||||
|
||||
static void control_plane_model_command_task(void *arg)
|
||||
@@ -750,15 +783,22 @@ static void control_plane_model_command_task(void *arg)
|
||||
ESP_LOGW(TAG, "Unknown model direction: %s", cmd.value);
|
||||
}
|
||||
} else if (cmd.command_type == CONTROL_PLANE_MODEL_COMMAND_CALIBRATE) {
|
||||
ESP_LOGI(TAG, "Calibration triggered by model command");
|
||||
esp_err_t err = control_plane_calibrate();
|
||||
ESP_LOGI(TAG, "Calibration motion triggered by model command");
|
||||
esp_err_t err = control_plane_run_model_calibration_motion();
|
||||
if (err != ESP_OK) {
|
||||
if (err == ESP_ERR_TIMEOUT || err == ESP_ERR_INVALID_STATE) {
|
||||
ESP_LOGI(TAG, "Calibrate not completed: %s", esp_err_to_name(err));
|
||||
ESP_LOGI(TAG, "Calibration motion not completed: %s", esp_err_to_name(err));
|
||||
} else {
|
||||
ESP_LOGW(TAG, "Calibrate failed: %s", esp_err_to_name(err));
|
||||
ESP_LOGW(TAG, "Calibration motion failed: %s", esp_err_to_name(err));
|
||||
}
|
||||
}
|
||||
} else if (cmd.command_type == CONTROL_PLANE_MODEL_COMMAND_CHOUQIAN) {
|
||||
ESP_LOGI(TAG, "Chouqian triggered by model command: %s", cmd.value);
|
||||
esp_err_t err = control_plane_show_chouqian_expression(cmd.value_index,
|
||||
cmd.value_index_valid);
|
||||
if (err != ESP_OK && err != ESP_ERR_INVALID_STATE) {
|
||||
ESP_LOGW(TAG, "Chouqian expression failed: %s", esp_err_to_name(err));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user