Skip to content

Commit

Permalink
feat(led) send LV_EVENT_DRAW_PART_BEGIN/END
Browse files Browse the repository at this point in the history
  • Loading branch information
kisvegabor committed Jun 28, 2021
1 parent a38fcf2 commit fcd4aa3
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/extra/widgets/led/lv_led.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,12 @@ static void lv_led_event(const lv_obj_class_t * class_p, lv_event_t * e)
lv_res_t res;

/* Call the ancestor's event handler */
res = lv_obj_event_base(MY_CLASS, e);
if(res != LV_RES_OK) return;

lv_event_code_t code = lv_event_get_code(e);
if(code != LV_EVENT_DRAW_MAIN && code != LV_EVENT_DRAW_MAIN_END) {
res = lv_obj_event_base(MY_CLASS, e);
if(res != LV_RES_OK) return;
}

lv_obj_t * obj = lv_event_get_target(e);
if(code == LV_EVENT_DRAW_MAIN) {
/*Make darker colors in a temporary style according to the brightness*/
Expand Down Expand Up @@ -200,7 +202,16 @@ static void lv_led_event(const lv_obj_class_t * class_p, lv_event_t * e)
(LV_LED_BRIGHT_MAX - LV_LED_BRIGHT_MIN);

const lv_area_t * clip_area = lv_event_get_param(e);

lv_obj_draw_part_dsc_t part_dsc;
lv_obj_draw_dsc_init(&part_dsc, clip_area);
part_dsc.draw_area = &obj->coords;
part_dsc.rect_dsc = &rect_dsc;
part_dsc.part = LV_PART_MAIN;

lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_dsc);
lv_draw_rect(&obj->coords, clip_area, &rect_dsc);
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_dsc);
}
}

Expand Down

0 comments on commit fcd4aa3

Please sign in to comment.