From 027f06710e83ee3daa7b706fb8a9bf23b1ab14e4 Mon Sep 17 00:00:00 2001 From: lyon Date: Mon, 22 Aug 2022 18:44:14 +0800 Subject: [PATCH] add_files --- package/pika_lvgl/README.md | 138 ---------------------------- package/pika_lvgl/pika_lv_timer_t.c | 37 ++++++++ package/pika_lvgl/pika_lvgl.c | 9 ++ package/pika_lvgl/pika_lvgl.pyi | 56 ++++------- 4 files changed, 63 insertions(+), 177 deletions(-) delete mode 100644 package/pika_lvgl/README.md create mode 100644 package/pika_lvgl/pika_lv_timer_t.c diff --git a/package/pika_lvgl/README.md b/package/pika_lvgl/README.md deleted file mode 100644 index 963bde09c..000000000 --- a/package/pika_lvgl/README.md +++ /dev/null @@ -1,138 +0,0 @@ -# Visual Studio simulator project for LVGL embedded GUI Library - -![Screenshot](Screenshot.png) - -## Introduction - -This is a pre-configured Visual Studio project to try LVGL on a Windows PC. The -project only depend on Win32 API, C Runtime and C++ STL, so you can compile it -without any extra dependencies. - -The project is currently maintained using Visual Studio 2019. It may well work -without modification in Visual Studio 2017 but it is not actively supported -with that version, so please install and test with Visual Studio 2019 before -reporting any bugs. - -Some one will notice that this repository had been renamed from -`lv_sim_visual_studio_sdl` to `lv_sim_visual_studio`. You can read -[here](https://github.com/lvgl/lvgl/issues/2043) and know why. - -**This project is not for Visual Studio Code, it is for Visual Studio 2019.** - -Instructions for cloning, building and running the application are found below. - -## Known Issues - -- The LV_MEM_SIZE macro in lv_conf.h should be 128KiB or larger because you may - meet the out of memory issue when you are using the 64-bit simulator. - - Note: In this project, the size is set to 1024KiB. -- Users need to check the target selected in Visual Studio, because the - simulator project support ARM64 and Visual Studio will choose ARM64 in the - first time because of the alphabetical order. - -## Supported Features - -This repo is designed for keeping the simulator behavior. If you wonder to -adapt your LVGL application to Windows, please visit -[lvgl/lv_port_windows](https://github.com/lvgl/lv_port_windows). - -- [x] Only depends on Win32 API, C Runtime and C++ STL. -- [x] Native support for x86, x64 and ARM64 Windows. -- [x] Support compiling with [VC-LTL](https://github.com/Chuyu-Team/VC-LTL) - toolchain to make the binary size as smaller as using MinGW. -- [x] Support Per-monitor DPI Aware. -- [x] Support Windows keyboard and mouse wheel event in the HAL level. -- [x] FreeType integration. - -## Drop the ARM32 Windows support - -For my deliberate consideration, The lv_port_windows project will drop the ARM32 -support on the Windows platform. Here are the reasons: - -- The latest version of ARM32 version for Windows desktop is Redstone 2 Insider - Build 15035. I know Windows RT 8.1 and Windows 10 IoT Core aren't in the - stage of end of support, but most of daily users are drop their devices - (Windows RT 8.x tablets) or have a better solution (Windows 10 IoT Core users - on Raspberry Pi devices should migrate to Linux or ARM64 version for Windows - 10 desktop). -- Future ARM processors are deprecating ARM32 ISA support, and Apple Silicon M1 - had dropped the ARM32 support at all. So we can't run ARM32 version of Windows - desktop applications on these devices. -- Reduce the size of release package and make the continuous integration faster. - -## How to Clone - -This repository contains other, necessary LVGL software repositories as -[git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules). Those -submodules are not pulled in with the normal git clone command and they will be -needed. There are a couple of techniques to pull in the submodules. - -### Everything at Once - -This command will clone the lv_sim_visual_studio repository and all submodules -in a single step. - -``` -git clone --recurse-submodules https://github.com/lvgl/lv_sim_visual_studio.git -``` - -### Main Repository First, Submodules Second - -If you've already cloned the main repository you can pull in the submodules -with a second command. Both commands are shown below. - -``` -git clone https://github.com/lvgl/lv_sim_visual_studio.git -cd lv_sim_visual_studio -git submodule update --init --recursive -``` - -### Keeping Your Clone Up-To-Date - -If you have cloned this repository and would like to pull in the latest -changes, you will have to do this in two steps. The first step will pull in -updates to the main repo, including updated _references_ to the submodules. The -second step will update the code in the submodules to match those references. -The two commands needed to accomplish this are shown below, run these commands -from inside the main repository's directory (top level `lv_sim_visual_studio` -directory works fine). - -``` -git pull -git submodule update --init --recursive -``` - -If you have chosen to fork this repository then updating the fork from upstream -will require a different, more involved procedure. - -## How To Build & Run - -Open the `LVGL.Simulator.sln` solution file in Visual Studio. Set the -`LVGL.Simulator` project as the startup project. Click on the `Local Windows -Debugger` button in the top toolbar. The included project will be built and -run, launching from a cmd window. - -## Trying Things Out - -There are a list of possible test applications in the -[LVGL.Simulator.cpp](LVGL.Simulator/LVGL.Simulator.cpp) file. Each test or demo -is launched via a single function call. By default the `lv_demo_widgets` -function is the one that runs, but you can comment that one out and choose any -of the others to compile and run. - -Use these examples to start building your own application test code inside the -simulator. - -## A Note About Versions - -This repository has its submodule references updated shortly afk with minor -version updates. When submodule updates take place a matching version tag is -added tter the release of new, major releases of LittlevGL's core -[lvgl](https://github.com/lvgl/lvgl) project. Occasionally it is updated to -woro this repository. - -If you need to pull in bug fixes in more recent changes to the submodules you -will have to update the references on your own. If source files are added or -removed in the submodules then the visual studio project will likely need -adjusting. See the commit log for examples of submodule updates and associated -visual studio file changes to guide you. diff --git a/package/pika_lvgl/pika_lv_timer_t.c b/package/pika_lvgl/pika_lv_timer_t.c new file mode 100644 index 000000000..be65a7a96 --- /dev/null +++ b/package/pika_lvgl/pika_lv_timer_t.c @@ -0,0 +1,37 @@ +#include "lvgl.h" +#include "pika_lvgl_lv_timer_t.h" + +PikaEventListener* g_pika_lv_timer_event_listener; + +#define LV_TIMER_EVENT_ID 0 + +void __pika_timer_cb(lv_timer_t* timer) { + PikaObj* eventHandleObj = pks_eventLisener_getEventHandleObj( + g_pika_lv_timer_event_listener, LV_TIMER_EVENT_ID); + obj_newDirectObj(eventHandleObj, "timer", New_pika_lvgl_lv_timer_t); + obj_setPtr(obj_getPtr(eventHandleObj, "timer"), "lv_timer", timer); + obj_run(eventHandleObj, "eventCallBack(timer)"); +} + +void pika_lvgl_lv_timer_t_set_period(PikaObj* self, int period) { + lv_timer_t* lv_timer = obj_getPtr(self, "lv_timer"); + lv_timer_set_period(lv_timer, period); +} + +void pika_lvgl_lv_timer_t_set_cb(PikaObj* self, Arg* cb) { + obj_setArg(self, "eventCallBack", cb); + /* init event_listener for the first time */ + if (NULL == g_pika_lv_timer_event_listener) { + pks_eventLisener_init(&g_pika_lv_timer_event_listener); + } + pks_eventLicener_registEvent(g_pika_lv_timer_event_listener, + LV_TIMER_EVENT_ID, self); + + lv_timer_t* lv_timer = obj_getPtr(self, "lv_timer"); + lv_timer_set_cb(lv_timer, __pika_timer_cb); +} + +void pika_lvgl_lv_timer_t__del(PikaObj *self){ + lv_timer_t* lv_timer = obj_getPtr(self, "lv_timer"); + lv_timer_del(lv_timer); +} diff --git a/package/pika_lvgl/pika_lvgl.c b/package/pika_lvgl/pika_lvgl.c index 65f05e058..55ff93eea 100644 --- a/package/pika_lvgl/pika_lvgl.c +++ b/package/pika_lvgl/pika_lvgl.c @@ -11,6 +11,7 @@ #include "pika_lvgl_lv_color_t.h" #include "pika_lvgl_lv_obj.h" #include "pika_lvgl_indev_t.h" +#include "pika_lvgl_lv_timer_t.h" PikaObj* pika_lv_event_listener_g; @@ -182,3 +183,11 @@ PikaObj* pika_lvgl_indev_get_act(PikaObj *self){ obj_setPtr(new_obj,"lv_indev", lv_indev); return new_obj; } + +PikaObj* pika_lvgl_timer_create_basic(PikaObj *self){ + PikaObj* new_obj = newNormalObj(New_pika_lvgl_lv_timer_t); + lv_timer_t *lv_timer = lv_timer_create_basic(); + obj_setPtr(new_obj,"lv_timer", lv_timer); + return new_obj; +} + diff --git a/package/pika_lvgl/pika_lvgl.pyi b/package/pika_lvgl/pika_lvgl.pyi index 6283c5902..6c4848462 100644 --- a/package/pika_lvgl/pika_lvgl.pyi +++ b/package/pika_lvgl/pika_lvgl.pyi @@ -1,10 +1,8 @@ from PikaObj import * - def __init__(): ... - -class EVENT(TinyObj): +class EVENT: ALL: int PRESSED: int PRESSING: int @@ -53,8 +51,7 @@ class EVENT(TinyObj): PREPROCESS: int def __init__(self): ... - -class ALIGN(TinyObj): +class ALIGN: DEFAULT: int TOP_LEFT: int TOP_MID: int @@ -79,8 +76,7 @@ class ALIGN(TinyObj): OUT_RIGHT_BOTTOM: int def __init__(self): ... - -class PALETTE(TinyObj): +class PALETTE: RED: int PINK: int PURPLE: int @@ -103,37 +99,34 @@ class PALETTE(TinyObj): NONE: int def __init__(self): ... - -class OPA(TinyObj): +class OPA: TRANSP: int COVER: int def __init__(self): ... - -class ANIM(TinyObj): +class ANIM: OFF: int ON: int def __init__(self): ... - -class STATE(TinyObj): +class STATE: def __init__(self): ... - -class lv_event(TinyObj): +class lv_event: def get_code(self) -> int: ... def get_target(self) -> lv_obj: ... +class lv_color_t: ... -class lv_color_t(TinyObj): - ... - +class lv_timer_t: + def set_period(period: int): ... + def set_cb(cb: any): ... + def _del(self): ... def palette_lighten(p: int, lvl: int) -> lv_color_t: ... def palette_main(p: int) -> lv_color_t: ... - -class style_t(TinyObj): +class style_t: def __init__(self): ... def init(self): ... def set_radius(self, radius: int): ... @@ -146,8 +139,7 @@ class style_t(TinyObj): def set_shadow_spread(self, s: int): ... def set_shadow_color(self, color: lv_color_t): ... - -class lv_obj(TinyObj): +class lv_obj: def center(self): ... def set_size(self, size_x: int, size_y: int): ... def align(self, align: int, x_ofs: int, y_ofs: int): ... @@ -161,45 +153,36 @@ class lv_obj(TinyObj): def get_y(self) -> int: ... def set_pos(self, x: int, y: int): ... - -class indev_t(TinyObj): +class indev_t: def get_vect(self, point: point_t): ... - def obj(parent: lv_obj) -> lv_obj: ... def indev_get_act() -> indev_t: ... - -class point_t(TinyObj): +class point_t: def __init__(self): ... - class arc(lv_obj): def __init__(self, parent: lv_obj): ... def set_end_angle(self, angle: int): ... def set_bg_angles(self, start: int, end: int): ... def set_angles(self, start: int, end: int): ... - class bar(lv_obj): def __init__(self, parent: lv_obj): ... def set_value(self, value: int, anim: int): ... - class btn(lv_obj): def __init__(self, parent: lv_obj): ... - class checkbox(lv_obj): def __init__(self, parent: lv_obj): ... def set_text(self, txt: str): ... - class dropdown(lv_obj): def __init__(self, parent: lv_obj): ... def set_options(self, options: str): ... - class label(lv_obj): def __init__(self, parent: lv_obj): ... def set_text(self, txt: str): ... @@ -207,29 +190,24 @@ class label(lv_obj): def set_recolor(self, en: int): ... def set_style_text_align(self, value: int, selector: int): ... - class roller(lv_obj): def __init__(self, parent: lv_obj): ... def set_options(self, options: str, mode: int): ... def set_visible_row_count(self, row_cnt: int): ... - class slider(lv_obj): def __init__(self, parent: lv_obj): ... - class switch(lv_obj): def __init__(self, parent: lv_obj): ... - class table(lv_obj): def __init__(self, parent: lv_obj): ... def set_cell_value(self, row: int, col: int, txt: str): ... - class textarea(lv_obj): def __init__(self, parent: lv_obj): ... def set_one_line(en: int): ... - def scr_act() -> lv_obj: ... +def timer_create_basic() -> lv_timer_t: ...