Fix CPU core type column position

This commit is contained in:
Codex 2026-06-23 21:37:26 +08:00
parent f7e00d303d
commit 16d3b53db1

View File

@ -30,7 +30,8 @@ static lv_obj_t *s_conn_label;
static lv_obj_t *s_env_label;
static lv_obj_t *s_cpu_value_label;
static lv_obj_t *s_cpu_freq_label;
static lv_obj_t *s_cpu_core_labels[CPU_TOP_CORE_COUNT];
static lv_obj_t *s_cpu_core_type_labels[CPU_TOP_CORE_COUNT];
static lv_obj_t *s_cpu_core_freq_labels[CPU_TOP_CORE_COUNT];
static lv_obj_t *s_cpu_value_halo[HALO_LABEL_COUNT];
static lv_obj_t *s_cpu_freq_halo[HALO_LABEL_COUNT];
static lv_obj_t *s_cpu_line;
@ -519,19 +520,23 @@ static void update_cpu_core_labels(const char *core_text)
char *cursor = buffer;
char *token = strtok(cursor, " ");
while (token != NULL && row < CPU_TOP_CORE_COUNT) {
for (char *p = token; *p != '\0'; p++) {
if (*p == ':') {
*p = ' ';
}
char *freq = "--";
char *sep = strchr(token, ':');
if (sep != NULL) {
*sep = '\0';
freq = sep + 1;
}
lv_label_set_text(s_cpu_core_labels[row], token);
lv_obj_clear_flag(s_cpu_core_labels[row], LV_OBJ_FLAG_HIDDEN);
lv_label_set_text(s_cpu_core_type_labels[row], token);
lv_label_set_text(s_cpu_core_freq_labels[row], freq);
lv_obj_clear_flag(s_cpu_core_type_labels[row], LV_OBJ_FLAG_HIDDEN);
lv_obj_clear_flag(s_cpu_core_freq_labels[row], LV_OBJ_FLAG_HIDDEN);
row++;
token = strtok(NULL, " ");
}
for (int i = row; i < CPU_TOP_CORE_COUNT; i++) {
lv_obj_add_flag(s_cpu_core_labels[i], LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(s_cpu_core_type_labels[i], LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(s_cpu_core_freq_labels[i], LV_OBJ_FLAG_HIDDEN);
}
}
@ -602,12 +607,20 @@ void ui_screen_create(void)
lv_obj_align(s_cpu_freq_label, LV_ALIGN_TOP_LEFT, 8, 72);
for (int i = 0; i < CPU_TOP_CORE_COUNT; i++) {
s_cpu_core_labels[i] = make_label(screen, "--", &lv_font_montserrat_14);
lv_label_set_long_mode(s_cpu_core_labels[i], LV_LABEL_LONG_CLIP);
lv_obj_set_width(s_cpu_core_labels[i], 58);
lv_obj_set_style_text_align(s_cpu_core_labels[i], LV_TEXT_ALIGN_RIGHT, 0);
lv_obj_align(s_cpu_core_labels[i], LV_ALIGN_TOP_LEFT, 138, 28 + i * 16);
lv_obj_add_flag(s_cpu_core_labels[i], LV_OBJ_FLAG_HIDDEN);
int y = 28 + i * 16;
s_cpu_core_type_labels[i] = make_label(screen, "-", &lv_font_montserrat_14);
lv_label_set_long_mode(s_cpu_core_type_labels[i], LV_LABEL_LONG_CLIP);
lv_obj_set_width(s_cpu_core_type_labels[i], 14);
lv_obj_set_style_text_align(s_cpu_core_type_labels[i], LV_TEXT_ALIGN_LEFT, 0);
lv_obj_align(s_cpu_core_type_labels[i], LV_ALIGN_TOP_LEFT, 138, y);
lv_obj_add_flag(s_cpu_core_type_labels[i], LV_OBJ_FLAG_HIDDEN);
s_cpu_core_freq_labels[i] = make_label(screen, "--", &lv_font_montserrat_14);
lv_label_set_long_mode(s_cpu_core_freq_labels[i], LV_LABEL_LONG_CLIP);
lv_obj_set_width(s_cpu_core_freq_labels[i], 42);
lv_obj_set_style_text_align(s_cpu_core_freq_labels[i], LV_TEXT_ALIGN_RIGHT, 0);
lv_obj_align(s_cpu_core_freq_labels[i], LV_ALIGN_TOP_LEFT, 154, y);
lv_obj_add_flag(s_cpu_core_freq_labels[i], LV_OBJ_FLAG_HIDDEN);
}
lv_obj_t *memory_title = make_label(screen, "MEM", &lv_font_montserrat_14);