summaryrefslogtreecommitdiff
path: root/lib/luavgl/src/disp.c
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-06-12 16:29:31 +1000
committerjacqueline <me@jacqueline.id.au>2024-06-12 16:29:31 +1000
commitbd01bf3845fd67dc4e03f56d044b3bc53245eeed (patch)
tree782f38292005dd84da267f4f06c7c66f994ca0ad /lib/luavgl/src/disp.c
parentb02d13f5a584c9b0a747b0cefdf92dc867181a50 (diff)
downloadtangara-fw-bd01bf3845fd67dc4e03f56d044b3bc53245eeed.tar.gz
WIP bump luavgl to latest
Diffstat (limited to 'lib/luavgl/src/disp.c')
-rw-r--r--lib/luavgl/src/disp.c120
1 files changed, 41 insertions, 79 deletions
diff --git a/lib/luavgl/src/disp.c b/lib/luavgl/src/disp.c
index 75233a81..ba68491a 100644
--- a/lib/luavgl/src/disp.c
+++ b/lib/luavgl/src/disp.c
@@ -48,7 +48,10 @@ static int luavgl_disp_get_default(lua_State *L)
static int luavgl_disp_get_scr_act(lua_State *L)
{
- lv_disp_t *disp = luavgl_to_disp(L, 1);
+ lv_disp_t *disp = NULL;
+ if (!lua_isnoneornil(L, 1))
+ disp = luavgl_to_disp(L, 1);
+
lv_obj_t *obj = lv_disp_get_scr_act(disp);
if (obj == NULL) {
lua_pushnil(L);
@@ -102,8 +105,7 @@ static int luavgl_disp_load_scr(lua_State *L)
}
/* has parameter table */
-
- lv_scr_load_anim_t anim = LV_SCR_LOAD_ANIM_NONE;
+ lv_screen_load_anim_t anim = LV_SCR_LOAD_ANIM_NONE;
uint32_t time = 0;
uint32_t delay = 0;
bool auto_del = false;
@@ -111,38 +113,40 @@ static int luavgl_disp_load_scr(lua_State *L)
const char *str;
lua_getfield(L, 2, "anim");
str = lua_tostring(L, -1);
- if (str == NULL || strcmp(str, "none") == 0) {
+ if (str == NULL || lv_strcmp(str, "none") == 0) {
; /* use default */
- } else if (strcmp(str, "over_left") == 0) {
+ } else if (lv_strcmp(str, "over_left") == 0) {
anim = LV_SCR_LOAD_ANIM_OVER_LEFT;
- } else if (strcmp(str, "over_right") == 0) {
+ } else if (lv_strcmp(str, "over_right") == 0) {
anim = LV_SCR_LOAD_ANIM_OVER_RIGHT;
- } else if (strcmp(str, "over_top") == 0) {
+ } else if (lv_strcmp(str, "over_top") == 0) {
anim = LV_SCR_LOAD_ANIM_OVER_TOP;
- } else if (strcmp(str, "over_botto") == 0) {
+ } else if (lv_strcmp(str, "over_botto") == 0) {
anim = LV_SCR_LOAD_ANIM_OVER_BOTTOM;
- } else if (strcmp(str, "move_left") == 0) {
+ } else if (lv_strcmp(str, "move_left") == 0) {
anim = LV_SCR_LOAD_ANIM_MOVE_LEFT;
- } else if (strcmp(str, "move_right") == 0) {
+ } else if (lv_strcmp(str, "move_right") == 0) {
anim = LV_SCR_LOAD_ANIM_MOVE_RIGHT;
- } else if (strcmp(str, "move_top") == 0) {
+ } else if (lv_strcmp(str, "move_top") == 0) {
anim = LV_SCR_LOAD_ANIM_MOVE_TOP;
- } else if (strcmp(str, "move_botto") == 0) {
+ } else if (lv_strcmp(str, "move_botto") == 0) {
anim = LV_SCR_LOAD_ANIM_MOVE_BOTTOM;
- } else if (strcmp(str, "fade_in") == 0) {
- anim = LV_SCR_LOAD_ANIM_FADE_IN;
- } else if (strcmp(str, "fade_on") == 0) {
+ } else if (lv_strcmp(str, "fade_on") == 0) {
anim = LV_SCR_LOAD_ANIM_FADE_ON;
- } else if (strcmp(str, "fade_out") == 0) {
+#if LV_VERSION_CHECK(8, 3, 0)
+ } else if (lv_strcmp(str, "fade_in") == 0) {
+ anim = LV_SCR_LOAD_ANIM_FADE_IN;
+ } else if (lv_strcmp(str, "fade_out") == 0) {
anim = LV_SCR_LOAD_ANIM_FADE_OUT;
- } else if (strcmp(str, "out_left") == 0) {
+ } else if (lv_strcmp(str, "out_left") == 0) {
anim = LV_SCR_LOAD_ANIM_OUT_LEFT;
- } else if (strcmp(str, "out_right") == 0) {
+ } else if (lv_strcmp(str, "out_right") == 0) {
anim = LV_SCR_LOAD_ANIM_OUT_RIGHT;
- } else if (strcmp(str, "out_top") == 0) {
+ } else if (lv_strcmp(str, "out_top") == 0) {
anim = LV_SCR_LOAD_ANIM_OUT_TOP;
- } else if (strcmp(str, "out_bottom") == 0) {
+ } else if (lv_strcmp(str, "out_bottom") == 0) {
anim = LV_SCR_LOAD_ANIM_OUT_BOTTOM;
+#endif
}
lua_pop(L, 1);
@@ -158,7 +162,7 @@ static int luavgl_disp_load_scr(lua_State *L)
auto_del = luavgl_tointeger(L, -1);
lua_pop(L, 1);
- lv_scr_load_anim(obj, anim, time, delay, auto_del);
+ lv_screen_load_anim(obj, anim, time, delay, auto_del);
return 0;
}
@@ -202,47 +206,6 @@ static int luavgl_disp_get_layer_sys(lua_State *L)
return 1;
}
-static int luavgl_disp_set_bg_color(lua_State *L)
-{
- luavgl_disp_t *d = luavgl_check_disp(L, 1);
- lv_color_t c = luavgl_tocolor(L, 2);
-
- lv_disp_set_bg_color(d->disp, c);
-
- return 0;
-}
-
-static int luavgl_disp_set_bg_image(lua_State *L)
-{
- luavgl_disp_t *d = luavgl_check_disp(L, 1);
- const char *img = luavgl_toimgsrc(L, 2);
-
- lv_disp_set_bg_image(d->disp, img);
-
- return 0;
-}
-
-static int luavgl_disp_set_bg_opa(lua_State *L)
-{
- luavgl_disp_t *d = luavgl_check_disp(L, 1);
- lv_opa_t opa = luavgl_tointeger(L, 2);
- lv_disp_set_bg_opa(d->disp, opa);
-
- return 0;
-}
-
-static int luavgl_disp_get_chroma_key_color(lua_State *L)
-{
-#if LVGL_VERSION_MAJOR >= 9
- luavgl_disp_t *d = luavgl_check_disp(L, 1);
- lv_color_t c = lv_disp_get_chroma_key_color(d->disp);
- lua_pushinteger(L, c.full);
-#else
- lua_pushinteger(L, 0);
-#endif
- return 1;
-}
-
static int luavgl_disp_get_next(lua_State *L)
{
lv_disp_t *disp = NULL;
@@ -272,20 +235,20 @@ static int luavgl_disp_set_rotation(lua_State *L)
luavgl_disp_t *d = luavgl_check_disp(L, 1);
uint32_t r = lua_tointeger(L, 2);
- lv_disp_rot_t rot;
+ lv_display_rotation_t rot;
if (r == 0)
- rot = LV_DISP_ROT_NONE;
+ rot = LV_DISPLAY_ROTATION_0;
else if (r == 90)
- rot = LV_DISP_ROT_90;
+ rot = LV_DISPLAY_ROTATION_90;
else if (r == 180)
- rot = LV_DISP_ROT_180;
+ rot = LV_DISPLAY_ROTATION_180;
else if (r == 270)
- rot = LV_DISP_ROT_270;
+ rot = LV_DISPLAY_ROTATION_270;
else {
return luaL_argerror(L, 2, "invalid rotation value");
}
- lv_disp_set_rotation(d->disp, rot);
+ lv_display_set_rotation(d->disp, rot);
return 0;
}
@@ -306,17 +269,16 @@ static const luaL_Reg disp_lib[] = {
** methods for disp handles
*/
static const luaL_Reg disp_methods[] = {
- {"get_layer_top", luavgl_disp_get_layer_top },
- {"get_layer_sys", luavgl_disp_get_layer_sys },
- {"set_bg_color", luavgl_disp_set_bg_color },
- {"set_bg_image", luavgl_disp_set_bg_image },
- {"set_bg_opa", luavgl_disp_set_bg_opa },
- {"get_chroma_key_color", luavgl_disp_get_chroma_key_color},
- {"get_next", luavgl_disp_get_next },
- {"set_rotation", luavgl_disp_set_rotation },
- {"get_res", luavgl_disp_get_res },
-
- {NULL, NULL },
+ {"get_layer_top", luavgl_disp_get_layer_top},
+ {"get_layer_sys", luavgl_disp_get_layer_sys},
+ {"get_next", luavgl_disp_get_next },
+ {"set_rotation", luavgl_disp_set_rotation },
+ {"get_res", luavgl_disp_get_res },
+
+ {"get_scr_act", luavgl_disp_get_scr_act },
+ {"get_scr_prev", luavgl_disp_get_scr_prev },
+
+ {NULL, NULL },
};
static const luaL_Reg disp_meta[] = {