This commit is contained in:
admin
2026-02-25 16:23:21 +08:00
parent 528f901fb5
commit 1328c708ae
7 changed files with 66 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
#include "controller_lifecycle.h"
#include "esp_log.h"
#include "image_generation.h"
#include "printer_protocol.h"
#include "rest_server.h"
#include "system_runtime.h"
@@ -18,6 +19,9 @@ esp_err_t controller_lifecycle_start(void) {
ESP_LOGI(TAG, "Starting voice interaction");
ESP_ERROR_CHECK(voice_interaction_init());
ESP_LOGI(TAG, "Scheduling HTTPS prewarm");
image_generation_schedule_prewarm();
ESP_LOGI(TAG, "Starting REST server");
ESP_ERROR_CHECK(rest_server_start());

View File

@@ -69,8 +69,9 @@ static const char *s_web_index =
" <textarea id='imagePrompt'>一只可爱橘猫正脸特写,黑白线稿风格,白色背景,主体居中,边缘清晰,细节简洁。</textarea>\n"
" <div class='row'>\n"
" <select id='imgSize' style='max-width:180px'>\n"
" <option value='512*768' selected>512*768</option>\n"
" <option value='1024*1024'>1024*1024</option>\n"
" <option value='1120*1440' selected>1120*1440</option>\n"
" <option value='1120*1440'>1120*1440</option>\n"
" <option value='1536*864'>1536*864</option>\n"
" <option value='1536*1536'>1536*1536</option>\n"
" </select>\n"
@@ -262,7 +263,7 @@ static const char *s_web_index =
"\n"
" return {\n"
" prompt: mergedPrompt,\n"
" size: imgSizeEl.value || '1120*1440',\n"
" size: imgSizeEl.value || '512*768',\n"
" prompt_extend: imgPromptExtendEl.checked,\n"
" threshold: toInt(imgThresholdEl.value, 160, 0, 255),\n"
" max_height: toInt(imgMaxHeightEl.value, 2200, 64, 3000),\n"
@@ -369,6 +370,11 @@ esp_err_t rest_server_start(void) {
config.uri_match_fn = httpd_uri_match_wildcard;
config.max_uri_handlers = 32;
config.stack_size = 10240;
#if CONFIG_FREERTOS_UNICORE
config.core_id = 0;
#else
config.core_id = 1;
#endif
esp_err_t err = httpd_start(&s_server, &config);
if (err != ESP_OK) {

View File

@@ -7,6 +7,7 @@
#include "esp_log.h"
#include "image_generation.h"
#include "printer_protocol.h"
#include "raster_tools.h"
static const char *TAG = "rest_print";
@@ -410,6 +411,7 @@ static esp_err_t rest_server_print_image_generate(httpd_req_t *req) {
image_generation_result_t *gen_result = NULL;
uint8_t *raster = NULL;
char request_id[80] = {0};
bool status_poll_paused = false;
esp_err_t ret = ESP_FAIL;
esp_err_t body_err = rest_server_read_body(req, &body);
@@ -473,10 +475,14 @@ static esp_err_t rest_server_print_image_generate(httpd_req_t *req) {
image_generation_result_reset(gen_result);
char model_err[160] = {0};
printer_protocol_set_status_poll_paused(true);
status_poll_paused = true;
esp_err_t gen_rc = image_generation_generate_png(&gen_req,
gen_result,
model_err,
sizeof(model_err));
printer_protocol_set_status_poll_paused(false);
status_poll_paused = false;
if (gen_rc != ESP_OK) {
ESP_LOGW(TAG,
"image generate failed, rc=0x%x, msg=%s",
@@ -545,6 +551,9 @@ static esp_err_t rest_server_print_image_generate(httpd_req_t *req) {
request_id);
cleanup:
if (status_poll_paused) {
printer_protocol_set_status_poll_paused(false);
}
if (body != NULL) {
free(body);
}
@@ -558,6 +567,11 @@ cleanup:
image_generation_result_free(gen_result);
free(gen_result);
}
printer_runtime_status_t runtime = {0};
printer_protocol_get_runtime_status(&runtime);
if (!runtime.busy) {
image_generation_schedule_prewarm();
}
return ret;
}