update lvgl to v1.10.0

This commit is contained in:
pikastech 2022-08-07 13:09:27 +08:00
parent 63b3ef11d4
commit e1518e4b8f
19 changed files with 197 additions and 18 deletions

View File

@ -18,6 +18,15 @@
"pika_lvgl_textarea.h": "c",
"pika_lvgl_align_cls.h": "c",
"pika_lvgl_palette_cls.h": "c",
"pika_lvgl_lv_event.h": "c"
"pika_lvgl_lv_event.h": "c",
"pika_lvgl_style_t.h": "c",
"pika_lvgl_align.h": "c",
"pika_lvgl_event.h": "c",
"pika_lvgl_opa.h": "c",
"pika_lvgl_palette.h": "c",
"pika_lvgl_state.h": "c",
"pika_lvgl_anim.h": "c",
"pika_lvgl_indev_t.h": "c",
"pika_lvgl_point_t.h": "c"
}
}

View File

@ -54,8 +54,10 @@
<ClInclude Include="pikascript\pikascript-api\PikaStdData_ByteArray.h" />
<ClInclude Include="pikascript\pikascript-api\PikaStdData_Dict.h" />
<ClInclude Include="pikascript\pikascript-api\PikaStdData_dict_keys.h" />
<ClInclude Include="pikascript\pikascript-api\PikaStdData_FILEIO.h" />
<ClInclude Include="pikascript\pikascript-api\PikaStdData_List.h" />
<ClInclude Include="pikascript\pikascript-api\PikaStdData_String.h" />
<ClInclude Include="pikascript\pikascript-api\PikaStdData_Tuple.h" />
<ClInclude Include="pikascript\pikascript-api\PikaStdData_Utils.h" />
<ClInclude Include="pikascript\pikascript-api\PikaStdLib.h" />
<ClInclude Include="pikascript\pikascript-api\PikaStdLib_MemChecker.h" />
@ -74,12 +76,14 @@
<ClInclude Include="pikascript\pikascript-api\pika_lvgl_checkbox.h" />
<ClInclude Include="pikascript\pikascript-api\pika_lvgl_dropdown.h" />
<ClInclude Include="pikascript\pikascript-api\pika_lvgl_EVENT.h" />
<ClInclude Include="pikascript\pikascript-api\pika_lvgl_indev_t.h" />
<ClInclude Include="pikascript\pikascript-api\pika_lvgl_label.h" />
<ClInclude Include="pikascript\pikascript-api\pika_lvgl_lv_color_t.h" />
<ClInclude Include="pikascript\pikascript-api\pika_lvgl_lv_event.h" />
<ClInclude Include="pikascript\pikascript-api\pika_lvgl_lv_obj.h" />
<ClInclude Include="pikascript\pikascript-api\pika_lvgl_OPA.h" />
<ClInclude Include="pikascript\pikascript-api\pika_lvgl_PALETTE.h" />
<ClInclude Include="pikascript\pikascript-api\pika_lvgl_point_t.h" />
<ClInclude Include="pikascript\pikascript-api\pika_lvgl_roller.h" />
<ClInclude Include="pikascript\pikascript-api\pika_lvgl_slider.h" />
<ClInclude Include="pikascript\pikascript-api\pika_lvgl_STATE.h" />
@ -121,8 +125,10 @@
<ClCompile Include="pikascript\pikascript-api\PikaStdData_ByteArray-api.c" />
<ClCompile Include="pikascript\pikascript-api\PikaStdData_Dict-api.c" />
<ClCompile Include="pikascript\pikascript-api\PikaStdData_dict_keys-api.c" />
<ClCompile Include="pikascript\pikascript-api\PikaStdData_FILEIO-api.c" />
<ClCompile Include="pikascript\pikascript-api\PikaStdData_List-api.c" />
<ClCompile Include="pikascript\pikascript-api\PikaStdData_String-api.c" />
<ClCompile Include="pikascript\pikascript-api\PikaStdData_Tuple-api.c" />
<ClCompile Include="pikascript\pikascript-api\PikaStdData_Utils-api.c" />
<ClCompile Include="pikascript\pikascript-api\PikaStdLib-api.c" />
<ClCompile Include="pikascript\pikascript-api\PikaStdLib_MemChecker-api.c" />
@ -141,12 +147,14 @@
<ClCompile Include="pikascript\pikascript-api\pika_lvgl_checkbox-api.c" />
<ClCompile Include="pikascript\pikascript-api\pika_lvgl_dropdown-api.c" />
<ClCompile Include="pikascript\pikascript-api\pika_lvgl_EVENT-api.c" />
<ClCompile Include="pikascript\pikascript-api\pika_lvgl_indev_t-api.c" />
<ClCompile Include="pikascript\pikascript-api\pika_lvgl_label-api.c" />
<ClCompile Include="pikascript\pikascript-api\pika_lvgl_lv_color_t-api.c" />
<ClCompile Include="pikascript\pikascript-api\pika_lvgl_lv_event-api.c" />
<ClCompile Include="pikascript\pikascript-api\pika_lvgl_lv_obj-api.c" />
<ClCompile Include="pikascript\pikascript-api\pika_lvgl_OPA-api.c" />
<ClCompile Include="pikascript\pikascript-api\pika_lvgl_PALETTE-api.c" />
<ClCompile Include="pikascript\pikascript-api\pika_lvgl_point_t-api.c" />
<ClCompile Include="pikascript\pikascript-api\pika_lvgl_roller-api.c" />
<ClCompile Include="pikascript\pikascript-api\pika_lvgl_slider-api.c" />
<ClCompile Include="pikascript\pikascript-api\pika_lvgl_STATE-api.c" />
@ -173,9 +181,12 @@
<ClCompile Include="pikascript\pikascript-core\PikaVM.c" />
<ClCompile Include="pikascript\pikascript-core\TinyObj.c" />
<ClCompile Include="pikascript\pikascript-lib\PikaStdLib\PikaDebuger_Debuger.c" />
<ClCompile Include="pikascript\pikascript-lib\PikaStdLib\PikaStdData_ByteArray.c" />
<ClCompile Include="pikascript\pikascript-lib\PikaStdLib\PikaStdData_Dict.c" />
<ClCompile Include="pikascript\pikascript-lib\PikaStdLib\PikaStdData_FILEIO.c" />
<ClCompile Include="pikascript\pikascript-lib\PikaStdLib\PikaStdData_List.c" />
<ClCompile Include="pikascript\pikascript-lib\PikaStdLib\PikaStdData_String.c" />
<ClCompile Include="pikascript\pikascript-lib\PikaStdLib\PikaStdData_Tuple.c" />
<ClCompile Include="pikascript\pikascript-lib\PikaStdLib\PikaStdData_Utils.c" />
<ClCompile Include="pikascript\pikascript-lib\PikaStdLib\PikaStdLib_MemChecker.c" />
<ClCompile Include="pikascript\pikascript-lib\PikaStdLib\PikaStdLib_RangeObj.c" />
@ -188,6 +199,7 @@
<ClCompile Include="pikascript\pikascript-lib\pika_lvgl\pika_lvgl_btn.c" />
<ClCompile Include="pikascript\pikascript-lib\pika_lvgl\pika_lvgl_checkbox.c" />
<ClCompile Include="pikascript\pikascript-lib\pika_lvgl\pika_lvgl_dropdown.c" />
<ClCompile Include="pikascript\pikascript-lib\pika_lvgl\pika_lvgl_indev_t.c" />
<ClCompile Include="pikascript\pikascript-lib\pika_lvgl\pika_lvgl_label.c" />
<ClCompile Include="pikascript\pikascript-lib\pika_lvgl\pika_lvgl_lv_event.c" />
<ClCompile Include="pikascript\pikascript-lib\pika_lvgl\pika_lvgl_lv_obj.c" />
@ -197,6 +209,7 @@
<ClCompile Include="pikascript\pikascript-lib\pika_lvgl\pika_lvgl_switch.c" />
<ClCompile Include="pikascript\pikascript-lib\pika_lvgl\pika_lvgl_table.c" />
<ClCompile Include="pikascript\pikascript-lib\pika_lvgl\pika_lvgl_textarea.c" />
<ClCompile Include="pikascript\pikascript-lib\pika_lvgl\pika_lv_point_t.c" />
<ClCompile Include="pikascript_entry.c" />
</ItemGroup>
<ItemGroup>

View File

@ -69,6 +69,10 @@
<ClInclude Include="pikascript\pikascript-api\pika_lvgl_PALETTE.h" />
<ClInclude Include="pikascript\pikascript-api\pika_lvgl_STATE.h" />
<ClInclude Include="pikascript\pikascript-api\PikaStdData_dict_keys.h" />
<ClInclude Include="pikascript\pikascript-api\pika_lvgl_indev_t.h" />
<ClInclude Include="pikascript\pikascript-api\pika_lvgl_point_t.h" />
<ClInclude Include="pikascript\pikascript-api\PikaStdData_FILEIO.h" />
<ClInclude Include="pikascript\pikascript-api\PikaStdData_Tuple.h" />
</ItemGroup>
<ItemGroup>
<Manifest Include="LVGL.Simulator.manifest" />
@ -164,6 +168,15 @@
<ClCompile Include="pikascript\pikascript-api\pika_lvgl_PALETTE-api.c" />
<ClCompile Include="pikascript\pikascript-api\pika_lvgl_STATE-api.c" />
<ClCompile Include="pikascript\pikascript-api\PikaStdData_dict_keys-api.c" />
<ClCompile Include="pikascript\pikascript-api\pika_lvgl_indev_t-api.c" />
<ClCompile Include="pikascript\pikascript-api\pika_lvgl_point_t-api.c" />
<ClCompile Include="pikascript\pikascript-lib\pika_lvgl\pika_lv_point_t.c" />
<ClCompile Include="pikascript\pikascript-lib\pika_lvgl\pika_lvgl_indev_t.c" />
<ClCompile Include="pikascript\pikascript-api\PikaStdData_FILEIO-api.c" />
<ClCompile Include="pikascript\pikascript-api\PikaStdData_Tuple-api.c" />
<ClCompile Include="pikascript\pikascript-lib\PikaStdLib\PikaStdData_ByteArray.c" />
<ClCompile Include="pikascript\pikascript-lib\PikaStdLib\PikaStdData_FILEIO.c" />
<ClCompile Include="pikascript\pikascript-lib\PikaStdLib\PikaStdData_Tuple.c" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="LVGL.Simulator.rc" />

View File

@ -2,11 +2,23 @@ import pika_lvgl as lv
import PikaStdLib
mem = PikaStdLib.MemChecker()
# Create an Arc
arc = lv.arc(lv.scr_act())
arc.set_end_angle(200)
arc.set_size(150, 150)
arc.center()
def event_cb_1(evt):
print('in evt1')
print('mem used now: %0.2f kB' % (mem.getNow()))
def event_cb_2(evt):
print('in evt2')
print('mem used now: %0.2f kB' % (mem.getNow()))
btn1 = lv.btn(lv.scr_act())
btn1.align(lv.ALIGN.TOP_MID, 0, 10)
btn2 = lv.btn(lv.scr_act())
btn2.align(lv.ALIGN.TOP_MID, 0, 50)
btn1.add_event_cb(event_cb_1, lv.EVENT.CLICKED, 0)
btn2.add_event_cb(event_cb_2, lv.EVENT.CLICKED, 0)
print('mem used max: %0.2f kB' % (mem.getMax()))
print('mem used now: %0.2f kB' % (mem.getNow()))

View File

@ -1,3 +1,2 @@
pikascript-core==v1.8.8
PikaStdLib==v1.8.8
pika_lvgl==latest
pikascript-core==v1.10.0
PikaStdLib==v1.10.0

30
examples/lvgl/lv_drag.py Normal file
View File

@ -0,0 +1,30 @@
import pika_lvgl as lv
from PikaStdLib import MemChecker
mem = MemChecker()
def drag_event_handler(e):
obj = e.get_target()
indev = lv.indev_get_act()
vect = lv.point_t()
indev.get_vect(vect)
x = obj.get_x() + vect.x
y = obj.get_y() + vect.y
obj.set_pos(x, y)
mem.now()
#
# Make an object dragable.
#
obj = lv.obj(lv.scr_act())
obj.set_size(150, 100)
obj.add_event_cb(drag_event_handler, lv.EVENT.PRESSING, None)
label = lv.label(obj)
label.set_text("Drag me")
label.center()

20
examples/lvgl/lv_obj3.py Normal file
View File

@ -0,0 +1,20 @@
import pika_lvgl as lv
import PikaStdLib
mem = PikaStdLib.MemChecker()
obj1 = lv.obj(lv.scr_act())
obj1.set_size(100, 50)
obj1.align(lv.ALIGN.CENTER, -60, -30)
style_shadow = lv.style_t()
style_shadow.init()
style_shadow.set_shadow_width(10)
style_shadow.set_shadow_spread(5)
style_shadow.set_shadow_color(lv.palette_main(lv.PALETTE.BLUE))
obj2 = lv.obj(lv.scr_act())
obj2.add_style(style_shadow, 0)
obj2.align(lv.ALIGN.CENTER, 60, 30)
print('mem used max: %0.2f kB' % (mem.getMax()))
print('mem used now: %0.2f kB' % (mem.getNow()))

View File

@ -0,0 +1,8 @@
#include "lvgl.h"
#include "pika_lvgl_point_t.h"
void pika_lvgl_point_t___init__(PikaObj* self) {
lv_point_t lv_point = {0};
args_setStruct(self->list, "lv_point_struct", lv_point);
obj_setPtr(self, "lv_point", args_getStruct(self->list, "lv_point_struct"));
}

View File

@ -10,6 +10,7 @@
#include "pika_lvgl_arc.h"
#include "pika_lvgl_lv_color_t.h"
#include "pika_lvgl_lv_obj.h"
#include "pika_lvgl_indev_t.h"
PikaObj* pika_lv_event_listener_g;
@ -157,7 +158,7 @@ PikaObj* pika_lvgl_obj(PikaObj* self, PikaObj* parent) {
return new_obj;
}
PikaObj* pika_lvgl_palette_lighten(PikaObj* self, int lvl, int p) {
PikaObj* pika_lvgl_palette_lighten(PikaObj *self, int p, int lvl){
PikaObj* new_obj = newNormalObj(New_pika_lvgl_lv_color_t);
lv_color_t lv_color = lv_palette_lighten(p, lvl);
args_setStruct(new_obj->list, "lv_color_struct", lv_color);
@ -174,3 +175,10 @@ PikaObj* pika_lvgl_palette_main(PikaObj* self, int p) {
args_getStruct(new_obj->list, "lv_color_struct"));
return new_obj;
}
PikaObj* pika_lvgl_indev_get_act(PikaObj *self){
PikaObj* new_obj = newNormalObj(New_pika_lvgl_indev_t);
lv_indev_t *lv_indev = lv_indev_get_act();
obj_setPtr(new_obj,"lv_indev", lv_indev);
return new_obj;
}

View File

@ -3,6 +3,7 @@ from PikaObj import *
def __init__(): ...
class EVENT(TinyObj):
ALL: int
PRESSED: int
@ -114,12 +115,14 @@ class ANIM(TinyObj):
ON: int
def __init__(self): ...
class STATE(TinyObj):
def __init__(self): ...
class lv_event(TinyObj):
def get_code(self) -> int: ...
def get_target(self) -> lv_obj: ...
class lv_color_t(TinyObj):
@ -139,6 +142,9 @@ class style_t(TinyObj):
def set_outline_width(self, w: int): ...
def set_outline_color(self, color: lv_color_t): ...
def set_outline_pad(self, pad: int): ...
def set_shadow_width(self, w: int): ...
def set_shadow_spread(self, s: int): ...
def set_shadow_color(self, color: lv_color_t): ...
class lv_obj(TinyObj):
@ -151,9 +157,21 @@ class lv_obj(TinyObj):
def add_state(self, state: int): ...
def add_event_cb(self, event_cb: any, filter: int, user_data: pointer): ...
def add_style(self, style: style_t, selector: int): ...
def get_x(self) -> int: ...
def get_y(self) -> int: ...
def set_pos(self, x: int, y: int): ...
class indev_t(TinyObj):
def get_vect(self, point: point_t): ...
def obj(parent: lv_obj) -> lv_obj: ...
def indev_get_act() -> indev_t: ...
class point_t(TinyObj):
def __init__(self): ...
class arc(lv_obj):

View File

@ -15,12 +15,12 @@ void pika_lvgl_arc_set_end_angle(PikaObj* self, int angle) {
lv_arc_set_end_angle(lv_obj, angle);
}
void pika_lvgl_arc_set_bg_angles(PikaObj* self, int end, int start) {
void pika_lvgl_arc_set_bg_angles(PikaObj *self, int start, int end){
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_arc_set_bg_angles(lv_obj, start, end);
}
void pika_lvgl_arc_set_angles(PikaObj* self, int end, int start) {
void pika_lvgl_arc_set_angles(PikaObj *self, int start, int end){
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_arc_set_angles(lv_obj, start, end);
}

View File

@ -7,7 +7,7 @@ void pika_lvgl_bar___init__(PikaObj* self, PikaObj* parent) {
obj_setPtr(self, "lv_obj", lv_obj);
}
void pika_lvgl_bar_set_value(PikaObj* self, int anim, int value) {
void pika_lvgl_bar_set_value(PikaObj *self, int value, int anim){
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_bar_set_value(lv_obj, value, value);
}

View File

@ -0,0 +1,10 @@
#include "pika_lvgl_indev_t.h"
#include "lvgl.h"
void pika_lvgl_indev_t_get_vect(PikaObj* self, PikaObj* point) {
lv_indev_t* lv_indev = obj_getPtr(self, "lv_indev");
lv_point_t* lv_point = obj_getPtr(point, "lv_point");
lv_indev_get_vect(lv_indev, lv_point);
obj_setInt(point, "x", lv_point->x);
obj_setInt(point, "y", lv_point->y);
}

View File

@ -23,8 +23,8 @@ void pika_lvgl_label_set_text(PikaObj* self, char* txt) {
}
void pika_lvgl_label_set_style_text_align(PikaObj* self,
int selector,
int value) {
int value,
int selector) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_obj_set_style_text_align(lv_obj, value, selector);
}

View File

@ -6,3 +6,11 @@ int pika_lvgl_lv_event_get_code(PikaObj *self){
return lv_event_get_code(lv_event);
}
PikaObj *New_pika_lvgl_lv_obj(Args *args);
PikaObj* pika_lvgl_lv_event_get_target(PikaObj *self){
lv_event_t *lv_event = obj_getPtr(self, "lv_event");
lv_obj_t* lv_obj = lv_event_get_target(lv_event);
PikaObj* new_obj = newNormalObj(New_pika_lvgl_lv_obj);
obj_setPtr(new_obj, "lv_obj", lv_obj);
return new_obj;
}

View File

@ -92,8 +92,23 @@ void pika_lvgl_lv_obj_add_event_cb(PikaObj* self,
eventLicener_registEvent(pika_lv_event_listener_g, (uintptr_t)lv_obj, self);
}
void pika_lvgl_lv_obj_add_style(PikaObj* self, int selector, PikaObj* style) {
void pika_lvgl_lv_obj_add_style(PikaObj *self, PikaObj* style, int selector){
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_state_t* lv_style = obj_getPtr(style, "lv_style");
lv_obj_add_style(lv_obj, lv_style, selector);
}
int pika_lvgl_lv_obj_get_x(PikaObj *self){
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
return lv_obj_get_x(lv_obj);
}
int pika_lvgl_lv_obj_get_y(PikaObj *self){
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
return lv_obj_get_y(lv_obj);
}
void pika_lvgl_lv_obj_set_pos(PikaObj *self, int x, int y){
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_obj_set_pos(lv_obj, x, y);
}

View File

@ -44,3 +44,19 @@ void pika_lvgl_style_t___init__(PikaObj* self) {
lv_style_t* lv_style = args_getStruct(self->list, "lv_style_struct");
obj_setPtr(self, "lv_style", lv_style);
}
void pika_lvgl_style_t_set_shadow_color(PikaObj *self, PikaObj* color){
lv_style_t* lv_style = obj_getPtr(self, "lv_style");
lv_color_t* lv_color = obj_getPtr(color, "lv_color");
lv_style_set_shadow_color(lv_style, *lv_color);
}
void pika_lvgl_style_t_set_shadow_spread(PikaObj *self, int s){
lv_style_t* lv_style = obj_getPtr(self, "lv_style");
lv_style_set_shadow_spread(lv_style, s);
}
void pika_lvgl_style_t_set_shadow_width(PikaObj *self, int w){
lv_style_t* lv_style = obj_getPtr(self, "lv_style");
lv_style_set_shadow_width(lv_style, w);
}

View File

@ -7,7 +7,7 @@ void pika_lvgl_roller___init__(PikaObj* self, PikaObj* parent) {
obj_setPtr(self, "lv_obj", lv_obj);
}
void pika_lvgl_roller_set_options(PikaObj* self, int mode, char* options) {
void pika_lvgl_roller_set_options(PikaObj *self, char* options, int mode){
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_roller_set_options(lv_obj, options, mode);
}

View File

@ -8,8 +8,8 @@ void pika_lvgl_table___init__(PikaObj* self, PikaObj* parent) {
}
void pika_lvgl_table_set_cell_value(PikaObj* self,
int col,
int row,
int col,
char* txt) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_table_set_cell_value(lv_obj, row, col, txt);