优化
This commit is contained in:
@@ -28,6 +28,7 @@ typedef struct {
|
||||
|
||||
void image_generation_result_reset(image_generation_result_t *result);
|
||||
void image_generation_result_free(image_generation_result_t *result);
|
||||
void image_generation_schedule_prewarm(void);
|
||||
|
||||
esp_err_t image_generation_generate_png(const image_generation_request_t *req,
|
||||
image_generation_result_t *out_result,
|
||||
|
||||
@@ -53,6 +53,7 @@ esp_err_t printer_protocol_connect(const char *target_name, uint32_t timeout_ms)
|
||||
void printer_protocol_disconnect(void);
|
||||
|
||||
void printer_protocol_get_runtime_status(printer_runtime_status_t *out_status);
|
||||
void printer_protocol_set_status_poll_paused(bool paused);
|
||||
|
||||
esp_err_t printer_protocol_submit_raster_job(const uint8_t *raster,
|
||||
size_t raster_len,
|
||||
|
||||
@@ -15,6 +15,7 @@ QueueHandle_t s_job_queue;
|
||||
EventGroupHandle_t s_evt;
|
||||
|
||||
uint32_t s_busy_refcnt;
|
||||
static bool s_status_poll_paused;
|
||||
|
||||
parsed_status_t s_status = {
|
||||
.has_paper = true,
|
||||
@@ -32,6 +33,23 @@ job_slot_t s_jobs[JOB_SLOT_MAX];
|
||||
|
||||
static const char *TAG = "printer_protocol";
|
||||
|
||||
#if CONFIG_FREERTOS_UNICORE
|
||||
#define PRINT_WORKER_CORE_ID 0
|
||||
#else
|
||||
#define PRINT_WORKER_CORE_ID 1
|
||||
#endif
|
||||
|
||||
void printer_protocol_set_status_poll_paused(bool paused) {
|
||||
if (s_mutex == NULL) {
|
||||
return;
|
||||
}
|
||||
if (xSemaphoreTake(s_mutex, pdMS_TO_TICKS(200)) != pdTRUE) {
|
||||
return;
|
||||
}
|
||||
s_status_poll_paused = paused;
|
||||
xSemaphoreGive(s_mutex);
|
||||
}
|
||||
|
||||
bool printer_protocol_acquire_control_lane(uint32_t timeout_ms, char *err, size_t err_len) {
|
||||
if (xSemaphoreTake(s_mutex, pdMS_TO_TICKS(timeout_ms)) != pdTRUE) {
|
||||
if (err != NULL && err_len > 0) {
|
||||
@@ -232,7 +250,7 @@ static void status_poll_task(void *arg) {
|
||||
while (true) {
|
||||
bool can_poll = false;
|
||||
if (xSemaphoreTake(s_mutex, pdMS_TO_TICKS(50)) == pdTRUE) {
|
||||
can_poll = (s_busy_refcnt == 0);
|
||||
can_poll = (s_busy_refcnt == 0) && !s_status_poll_paused;
|
||||
xSemaphoreGive(s_mutex);
|
||||
}
|
||||
|
||||
@@ -314,12 +332,24 @@ esp_err_t printer_protocol_init(void) {
|
||||
return err;
|
||||
}
|
||||
|
||||
BaseType_t ok = xTaskCreate(printer_protocol_worker_task, "print_worker", 6144, NULL, 6, NULL);
|
||||
BaseType_t ok = xTaskCreatePinnedToCore(printer_protocol_worker_task,
|
||||
"print_worker",
|
||||
6144,
|
||||
NULL,
|
||||
6,
|
||||
NULL,
|
||||
PRINT_WORKER_CORE_ID);
|
||||
if (ok != pdPASS) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
ok = xTaskCreate(status_poll_task, "status_poll", 4096, NULL, 4, NULL);
|
||||
ok = xTaskCreatePinnedToCore(status_poll_task,
|
||||
"status_poll",
|
||||
4096,
|
||||
NULL,
|
||||
4,
|
||||
NULL,
|
||||
PRINT_WORKER_CORE_ID);
|
||||
if (ok != pdPASS) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user