LVGL使用记 - 数据更新显示

介绍一下界面数据显示方法

  • 关键API:
/**
 * Set a an event handler function for an object.
 * Used by the user to react on event which happens with the object.
 * @param obj pointer to an object
 * @param event_cb the new event function
 */
void lv_obj_set_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb)/*对象事件回调设置函数*/
{
    LV_ASSERT_OBJ(obj, LV_OBJX_NAME);

    obj->event_cb = event_cb;
}

/**
 * Send an event to the object
 * @param obj pointer to an object
 * @param event the type of the event from `lv_event_t`
 * @param data arbitrary data depending on the object type and the event. (Usually `NULL`)
 * @return LV_RES_OK: `obj` was not deleted in the event; LV_RES_INV: `obj` was deleted in the event
 */
lv_res_t lv_event_send(lv_obj_t * obj, lv_event_t event, const void * data)/*对象事件发送函数*/
{
    if(obj == NULL) return LV_RES_OK;
    LV_ASSERT_OBJ(obj, LV_OBJX_NAME);

    lv_res_t res;
    
    res = lv_event_send_func(obj->event_cb, obj, event, data);
    
    return res;
}

-事件对象初始化绑定事件对象

LVGL使用记 - 数据更新显示_第1张图片

-更新回调函数编写
LVGL使用记 - 数据更新显示_第2张图片

  • 在其他任务中,数据更新送
    LVGL使用记 - 数据更新显示_第3张图片

你可能感兴趣的:(嵌入式开发笔记,LVGL,单片机,GUI,gui_guider)