Commit e3902ef9 authored by Stefan Haun's avatar Stefan Haun
Browse files

Expose fullscreen handling to Python API

parent cfeeb7a1
......@@ -42,6 +42,19 @@ class Display:
"""
return cls()
def set_fullscreen(self, enable):
"""
Enable/disable fullscreen, so that overlays are not shown.
Will fail the display can't be locked
"""
sys_display.set_fullscreen(enable)
def is_fullscreen(self):
"""
Check if application is in fullscreen.
"""
return sys_display.is_fullscreen()
@staticmethod
def close():
"""
......
......@@ -93,6 +93,8 @@ Q(read_thermistor_voltage)
/* display */
Q(sys_display)
Q(set_fullscreen)
Q(is_fullscreen)
Q(display)
Q(print)
Q(print_adv)
......
......@@ -242,6 +242,26 @@ static mp_obj_t mp_display_open()
}
static MP_DEFINE_CONST_FUN_OBJ_0(display_open_obj, mp_display_open);
static mp_obj_t mp_display_set_fullscreen(mp_obj_t enable_obj)
{
int res = epic_disp_set_fullscreen(mp_obj_is_true(enable_obj));
if (res < 0) {
mp_raise_OSError(-res);
}
return mp_const_none;
}
static MP_DEFINE_CONST_FUN_OBJ_1(display_set_fullscreen_obj, mp_display_set_fullscreen);
static mp_obj_t mp_display_is_fullscreen()
{
bool res = epic_disp_is_fullscreen();
return mp_obj_new_bool(res);
}
static MP_DEFINE_CONST_FUN_OBJ_0(display_is_fullscreen_obj, mp_display_is_fullscreen);
/* Overlay mode is not exposed to Python apps*/
static mp_obj_t mp_display_close()
{
int res = epic_disp_close();
......@@ -256,6 +276,8 @@ static MP_DEFINE_CONST_FUN_OBJ_0(display_close_obj, mp_display_close);
static const mp_rom_map_elem_t display_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_sys_display) },
{ MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&display_open_obj) },
{ MP_ROM_QSTR(MP_QSTR_set_fullscreen), MP_ROM_PTR(&display_set_fullscreen_obj) },
{ MP_ROM_QSTR(MP_QSTR_is_fullscreen), MP_ROM_PTR(&display_is_fullscreen_obj) },
{ MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&display_close_obj) },
{ MP_ROM_QSTR(MP_QSTR_print), MP_ROM_PTR(&display_print_obj) },
{ MP_ROM_QSTR(MP_QSTR_print_adv), MP_ROM_PTR(&display_print_adv_obj) },
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment