refactor(printer): remove controller legacy and unify printer naming

This commit is contained in:
admin
2026-03-01 14:06:38 +08:00
parent e694a85997
commit 57adabaa3f
16 changed files with 111 additions and 445 deletions

View File

@@ -167,10 +167,7 @@ uint16_t runtime_policy_direct_printer_battery_divider_ratio_x1000(void);
uint32_t runtime_policy_direct_printer_ntc_pullup_ohms(void);
uint32_t runtime_policy_direct_printer_ntc_r25_ohms(void);
uint32_t runtime_policy_direct_printer_ntc_beta(void);
uint32_t runtime_policy_rest_printer_connect_timeout_ms(void);
uint32_t runtime_policy_rest_label_timeout_ms(void);
uint32_t runtime_policy_rest_ota_timeout_ms(void);
uint32_t runtime_policy_printer_connect_timeout_ms(void);
uint32_t runtime_policy_image_generation_timeout_default_ms(void);
uint32_t runtime_policy_image_generation_timeout_min_ms(void);
@@ -200,8 +197,6 @@ typedef enum {
RUNTIME_DIAG_COUNTER_IMAGE_GENERATE_SUCCESS,
RUNTIME_DIAG_COUNTER_IMAGE_GENERATE_FAILED,
RUNTIME_DIAG_COUNTER_IMAGE_GENERATE_TIMEOUT,
RUNTIME_DIAG_COUNTER_REST_RESPONSES_TOTAL,
RUNTIME_DIAG_COUNTER_REST_ERRORS_TOTAL,
RUNTIME_DIAG_COUNTER_MAX,
} runtime_diag_counter_t;

View File

@@ -39,7 +39,7 @@ static const uint16_t k_default_shift_clock_low_us = 5;
static const uint16_t k_default_latch_pulse_us = 1;
static const bool k_default_strobe_active_high = true;
static const char *TAG = "direct_printer";
static const char *TAG = "printer_driver";
static const uint8_t k_print_yield_lines = 8;
static const uint16_t k_gap_yield_steps = 32;
@@ -554,7 +554,7 @@ esp_err_t platform_direct_printer_init(void) {
s_state.motor_phase = 0;
s_state.connected = false;
s_state.initialized = true;
ESP_LOGI(TAG, "direct printer initialized");
ESP_LOGI(TAG, "printer initialized");
return ESP_OK;
#endif
}
@@ -732,7 +732,7 @@ esp_err_t platform_direct_printer_set_debug_config(bool has_config,
(void)override_motor_step_us;
(void)override_steps_per_line;
(void)reset_defaults;
write_err(err, err_len, "direct backend disabled");
write_err(err, err_len, "printer driver disabled");
return ESP_ERR_NOT_SUPPORTED;
#else
if (!has_config && !reset_defaults) {
@@ -742,11 +742,11 @@ esp_err_t platform_direct_printer_set_debug_config(bool has_config,
esp_err_t init_rc = platform_direct_printer_init();
if (init_rc != ESP_OK) {
write_err(err, err_len, "direct backend not initialized");
write_err(err, err_len, "printer driver not initialized");
return init_rc;
}
if (xSemaphoreTake(s_state.lock, pdMS_TO_TICKS(1000)) != pdTRUE) {
write_err(err, err_len, "direct printer lock timeout");
write_err(err, err_len, "printer lock timeout");
return ESP_ERR_TIMEOUT;
}
@@ -808,7 +808,7 @@ esp_err_t platform_direct_printer_print(const platform_direct_print_request_t *r
char *err,
size_t err_len) {
#if !CONFIG_TQ_DIRECT_PRINTER_ENABLE
write_err(err, err_len, "direct backend disabled");
write_err(err, err_len, "printer driver disabled");
return ESP_ERR_NOT_SUPPORTED;
#else
if (request == NULL || request->raster == NULL || request->width == 0 || request->height == 0) {
@@ -828,7 +828,7 @@ esp_err_t platform_direct_printer_print(const platform_direct_print_request_t *r
}
if (!s_state.initialized || s_state.lock == NULL) {
write_err(err, err_len, "direct backend not initialized");
write_err(err, err_len, "printer driver not initialized");
return ESP_ERR_INVALID_STATE;
}
@@ -838,13 +838,13 @@ esp_err_t platform_direct_printer_print(const platform_direct_print_request_t *r
}
if (xSemaphoreTake(s_state.lock, pdMS_TO_TICKS(1000)) != pdTRUE) {
write_err(err, err_len, "direct printer lock timeout");
write_err(err, err_len, "printer lock timeout");
return ESP_ERR_TIMEOUT;
}
if (!s_state.connected) {
xSemaphoreGive(s_state.lock);
write_err(err, err_len, "direct printer not connected");
write_err(err, err_len, "printer not connected");
return ESP_ERR_INVALID_STATE;
}
@@ -852,7 +852,7 @@ esp_err_t platform_direct_printer_print(const platform_direct_print_request_t *r
if (rc != ESP_OK) {
safe_drive_off_locked(true);
xSemaphoreGive(s_state.lock);
write_err(err, err_len, "direct printer gpio setup failed");
write_err(err, err_len, "printer gpio setup failed");
return rc;
}
@@ -949,11 +949,11 @@ esp_err_t platform_direct_printer_print(const platform_direct_print_request_t *r
esp_err_t platform_direct_printer_gap_move(uint32_t timeout_ms, char *err, size_t err_len) {
#if !CONFIG_TQ_DIRECT_PRINTER_ENABLE
write_err(err, err_len, "direct backend disabled");
write_err(err, err_len, "printer driver disabled");
return ESP_ERR_NOT_SUPPORTED;
#else
if (!s_state.initialized || s_state.lock == NULL) {
write_err(err, err_len, "direct backend not initialized");
write_err(err, err_len, "printer driver not initialized");
return ESP_ERR_INVALID_STATE;
}
if (timeout_ms == 0) {
@@ -961,12 +961,12 @@ esp_err_t platform_direct_printer_gap_move(uint32_t timeout_ms, char *err, size_
}
if (xSemaphoreTake(s_state.lock, pdMS_TO_TICKS(1000)) != pdTRUE) {
write_err(err, err_len, "direct printer lock timeout");
write_err(err, err_len, "printer lock timeout");
return ESP_ERR_TIMEOUT;
}
if (!s_state.connected) {
xSemaphoreGive(s_state.lock);
write_err(err, err_len, "direct printer not connected");
write_err(err, err_len, "printer not connected");
return ESP_ERR_INVALID_STATE;
}

View File

@@ -29,8 +29,6 @@ static const char *const s_counter_names[RUNTIME_DIAG_COUNTER_MAX] = {
"image_generate_success",
"image_generate_failed",
"image_generate_timeout",
"rest_responses_total",
"rest_errors_total",
};
static const char *const s_gauge_names[RUNTIME_DIAG_GAUGE_MAX] = {

View File

@@ -106,16 +106,8 @@
#define CONFIG_TQ_DIRECT_PRINTER_NTC_BETA 3950
#endif
#ifndef CONFIG_TQ_REST_PRINTER_CONNECT_TIMEOUT_MS
#define CONFIG_TQ_REST_PRINTER_CONNECT_TIMEOUT_MS 15000
#endif
#ifndef CONFIG_TQ_REST_LABEL_TIMEOUT_MS
#define CONFIG_TQ_REST_LABEL_TIMEOUT_MS 5000
#endif
#ifndef CONFIG_TQ_REST_OTA_STEP_TIMEOUT_MS
#define CONFIG_TQ_REST_OTA_STEP_TIMEOUT_MS 5000
#ifndef CONFIG_TQ_PRINTER_CONNECT_TIMEOUT_MS
#define CONFIG_TQ_PRINTER_CONNECT_TIMEOUT_MS 15000
#endif
#ifndef CONFIG_TQ_Z_IMAGE_TIMEOUT_MS
@@ -274,16 +266,8 @@ uint32_t runtime_policy_direct_printer_ntc_beta(void) {
return clamp_u32(CONFIG_TQ_DIRECT_PRINTER_NTC_BETA, 1000, 10000);
}
uint32_t runtime_policy_rest_printer_connect_timeout_ms(void) {
return clamp_u32(CONFIG_TQ_REST_PRINTER_CONNECT_TIMEOUT_MS, 1000, 60000);
}
uint32_t runtime_policy_rest_label_timeout_ms(void) {
return clamp_u32(CONFIG_TQ_REST_LABEL_TIMEOUT_MS, 500, 30000);
}
uint32_t runtime_policy_rest_ota_timeout_ms(void) {
return clamp_u32(CONFIG_TQ_REST_OTA_STEP_TIMEOUT_MS, 500, 60000);
uint32_t runtime_policy_printer_connect_timeout_ms(void) {
return clamp_u32(CONFIG_TQ_PRINTER_CONNECT_TIMEOUT_MS, 1000, 60000);
}
uint32_t runtime_policy_image_generation_timeout_default_ms(void) {