增加单击SW2抽签功能

This commit is contained in:
CSBOOK\44744
2026-06-28 18:14:21 +08:00
parent 4cc2089192
commit 984787d736
7 changed files with 301 additions and 8 deletions
+57
View File
@@ -50,6 +50,8 @@ typedef struct {
uint16_t repeat_count;
uint32_t frame_ms;
uint32_t duration_ms;
platform_lcd_presentation_step_t steps[PLATFORM_LCD_PRESENTATION_STEP_MAX];
size_t step_count;
} lcd_direct_request_t;
typedef struct {
@@ -644,6 +646,43 @@ static esp_err_t lcd_direct_play_asset_sequence(const lcd_direct_request_t *requ
return ESP_OK;
}
static esp_err_t lcd_direct_play_step_sequence(const lcd_direct_request_t *request)
{
ESP_RETURN_ON_FALSE(request != NULL,
ESP_ERR_INVALID_ARG,
TAG,
"invalid step sequence");
for (size_t i = 0; i < request->step_count; ++i) {
bool stop = false;
portENTER_CRITICAL(&s_state_lock);
stop = s_stop_requested || s_pending_valid;
portEXIT_CRITICAL(&s_state_lock);
if (stop) {
return ESP_ERR_INVALID_STATE;
}
const platform_lcd_presentation_step_t *step = &request->steps[i];
const lcd_direct_image_t *frame = lcd_direct_asset_frame(step->asset_dir, step->frame_index);
ESP_RETURN_ON_FALSE(frame != NULL,
ESP_ERR_NOT_FOUND,
TAG,
"LCD step frame not found asset=%s frame=%u",
step->asset_dir != NULL ? step->asset_dir : "<null>",
(unsigned)step->frame_index);
ESP_RETURN_ON_ERROR(lcd_direct_draw_rle_image(frame, NULL, 0),
TAG,
"draw step frame failed");
uint32_t delay_ms = step->delay_ms > 0U ? step->delay_ms : 100U;
vTaskDelay(pdMS_TO_TICKS(delay_ms));
}
lcd_direct_signal_completion();
return ESP_OK;
}
static esp_err_t lcd_direct_play_basic_face_until_pending(void)
{
const lcd_direct_request_t request = {
@@ -768,6 +807,17 @@ void lcd_direct_start_render_loop(void)
s_pending_valid = true;
portEXIT_CRITICAL(&s_state_lock);
}
} else if (request.kind == PLATFORM_LCD_PRESENTATION_STEP_SEQUENCE) {
draw_err = lcd_direct_play_step_sequence(&request);
if (draw_err == ESP_OK && request.return_to_idle) {
lcd_direct_request_t idle = {
.kind = PLATFORM_LCD_PRESENTATION_IDLE,
};
portENTER_CRITICAL(&s_state_lock);
s_pending = idle;
s_pending_valid = true;
portEXIT_CRITICAL(&s_state_lock);
}
} else {
draw_err = lcd_direct_draw_test_pattern(&request);
}
@@ -872,6 +922,13 @@ esp_err_t lcd_direct_request_presentation(const platform_lcd_presentation_reques
}
memcpy(copied.frame_order, request->frame_order, copied.frame_order_count);
}
if (request->steps != NULL && request->step_count > 0U) {
copied.step_count = request->step_count;
if (copied.step_count > PLATFORM_LCD_PRESENTATION_STEP_MAX) {
copied.step_count = PLATFORM_LCD_PRESENTATION_STEP_MAX;
}
memcpy(copied.steps, request->steps, copied.step_count * sizeof(copied.steps[0]));
}
TaskHandle_t task = NULL;
portENTER_CRITICAL(&s_state_lock);