8000 Merge pull request #27 from emfcamp/ugfx-clear · drrk/micropython@edc8798 · GitHub
[go: up one dir, main page]

Skip to content

Commit edc8798

Browse files
authored
Merge pull request micropython#27 from emfcamp/ugfx-clear
Add ugfx.clear
2 parents 6d72197 + fca00bf commit edc8798

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

stmhal/modugfx.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,17 @@ STATIC mp_obj_t ugfx_area(mp_uint_t n_args, const mp_obj_t *args) {
750750
}
751751
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ugfx_area_obj, 5, 5, ugfx_area);
752752

753+
/// \method clear(color=ugfx.WHITE)
754+
///
755+
/// Clear screen
756+
///
757+
STATIC mp_obj_t ugfx_clear(mp_uint_t n_args, const mp_obj_t *args) {
758+
int color = n_args == 0 ? White : mp_obj_get_int(args[0]);
759+
gdispFillArea(0, 0, gdispGetWidth(), gdispGetHeight(), color);
760+
return mp_const_none;
761+
}
762+
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ugfx_clear_obj, 0, 1, ugfx_clear);
763+
753764
/// \method box(x1, y1, a, b, colour)
754765
///
755766
/// Draw a box from (x,y), with lengths x1,y1, using the given colour.
@@ -874,6 +885,7 @@ STATIC const mp_map_elem_t ugfx_module_dict_table[] = {
874885
{ MP_OBJ_NEW_QSTR(MP_QSTR_line), (mp_obj_t)&ugfx_line_obj },
875886
{ MP_OBJ_NEW_QSTR(MP_QSTR_box), (mp_obj_t)&ugfx_box_obj },
876887
{ MP_OBJ_NEW_QSTR(MP_QSTR_area), (mp_obj_t)&ugfx_area_obj },
888+
{ MP_OBJ_NEW_QSTR(MP_QSTR_clear), (mp_obj_t)&ugfx_clear_obj },
877889
{ MP_OBJ_NEW_QSTR(MP_QSTR_thickline), (mp_obj_t)&ugfx_thickline_obj },
878890
{ MP_OBJ_NEW_QSTR(MP_QSTR_circle), (mp_obj_t)&ugfx_circle_obj },
879891
{ MP_OBJ_NEW_QSTR(MP_QSTR_fill_circle), (mp_obj_t)&ugfx_fill_circle_obj },

0 commit comments

Comments
 (0)
0