Hi -
I am trying to add custom tick labels to a meter in v8.4 for a tide clock. The meter scale range goes from 0-600. There are 60 minor ticks, 12 major ticks and 12 labels. So it’s a regular clock.
Based on some other posts I have seen, I am using the following code:
static void smeter_event_cb(lv_event_t * e)
{
lv_event_code_t code = lv_event_get_code(e);
lv_obj_draw_part_dsc_t * dsc = (lv_obj_draw_part_dsc_t *)lv_event_get_param(e);
static char * custom_labels[] = {"High", "5", "4", "3", "2", "1", "Low", "5", "4", "3", "2", "1", "High", NULL};
switch (code)
{
case LV_EVENT_DRAW_PART_BEGIN:
int value = dsc->value;
if (value % 50 == 0) {
value = value / 50;
if (value < sizeof(custom_labels) / sizeof (char *) - 1) {
ESP_LOGI("LVGL", "code: %d, label: %s", value, custom_labels[value]);
lv_snprintf(dsc->text, sizeof(dsc->text), "%s", custom_labels[value]);
}
}
break;
default:
break;
}
}
From the documentation and the other code samples I’ve seen, copying the new label to dsc->text should change the displayed label, but I am still seeing 1-12, not my desired labels.
Can anyone help me out?
Thanks.