A method and device for managing activities of applications based on LVGL
By defining the activity of an application as an object in LVGL and using the LVGL screen display linked list for management, the problem of lack of application activity management logic layer in mobile electronic devices is solved, and the effect of simplifying code and reducing development complexity is achieved.
Patent Information
- Application Number
- CN202111223928.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-18
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2041-10-18
AI Technical Summary
The lack of a logical layer for the activity management of applications in the graphical user interface of mobile electronic devices in the prior art leads to the need to add a dedicated management stack or linked list, increasing code complexity.
The application's activities are defined as objects in the light multi-purpose graphics library LVGL, and the LVGL screen display list is used for management, so that the activity life cycle management is achieved through the mechanism of creating and deleting objects.
Without adding a stack or linked list that specifically manages application activities, the management of application activities is implemented, simplifying the code and reducing development complexity.
Smart Images

Figure CN114119340B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to a method for managing application programs in a graphical user interface (GUI) of a mobile electronic device. Background Art
[0002] In mobile electronic devices such as mobile phones and smart watches, applications draw user interfaces (UI) through windows provided by activities. The windows provided by activities usually fill the screen, but may also be smaller than the screen and float above windows provided by other activities. Usually, an activity implements an interface in an application. An electronic device may contain multiple applications, each of which may be one interface or multiple interfaces, which means that the electronic device needs to switch between multiple activities. For example, the operation of a user making a call on a mobile electronic device involves switching between multiple activities. First, keep the activity displayed on the desktop and add an activity to open and browse the phone book (address book); after the user selects a phone number and clicks the connect button, close the activity to browse the phone book and open the activity to display the call; when the user clicks the hang up button, close the activity to call and return to the activity displayed on the desktop. Usually, an activity in the main application is designated as the main activity, which is the first interface that appears when the user starts the application. Each activity can start another activity to perform different operations. An activity can start other activities belonging to the same application or to other applications.
[0003] Existing mobile electronic devices (such as mobile phones) use a stack or linked list to manage application activities, that is, there is an independent space to manage the information of these activities. The stack and linked list technically realize the needs of activity insertion, activity deletion, activity exchange, and activity search.
[0004] LVGL (Light and Versatile Graphics Library) is a graphics library for creating graphical user interfaces that can be used in mobile electronic devices. LVGL provides a basic control library, such as buttons, text boxes, picture boxes, etc.; it also provides a control management mechanism, but there is no application logic layer, and does not provide a management solution for application activities required by mobile electronic devices. Strictly speaking, application activities are a concept in the Android operating system, and there is no concept of application activities in LVGL. However, in LVGL or other GUI development frameworks, there is still a situation where an application has multiple interfaces, and an application implements multiple interfaces respectively through multiple abstract logics. The abstract logic is similar to the concept of "application activities" in Android, so the technical term "application activities" is used to express it.
[0005] LVGL provides a multi-level linked list management mechanism to manage all graphical user interface objects. The highest level linked list is the screen display linked list used for rendering. It is an empty linked list when initialized, and the screen display linked list needs to be traversed for each rendering. The main thread of the graphical user interface renders the screen every 30 milliseconds, traversing the objects on each node from the screen display linked list, calculating the corresponding bitmap data on the screen according to the displayable area and display parameters of each object, and using this as the foreground layer to overlay the layer data on the background layer (the buffer area used for display output). The main thread of the graphical user interface also reads the linked list of each object and continues to access the child objects on the linked list node of the object. By analogy, all linked lists are traversed from the top to the bottom, and all objects in the linked lists at all levels participate in the overlay of the foreground layer to the background layer. Finally, the data in the buffer area of the display output is used to display the graphical user interface effect on the screen.
[0006] LVGL provides the function of creating a new object (obj). A new object needs to provide the parent object pointer of this object to determine which linked list of the multi-level linked list this object is added to. Each object has its own linked list to manage its child objects, so creating a new object means inserting this object as a node into the linked list of the parent object. The process of creating a new multi-layer graphical user interface is described from top to bottom as follows: If the graphical user interface needs to display a pattern, an object obj_1 and its new linked list ll_1 are dynamically created for this pattern, and this object obj_1 is inserted into the head node of the screen display linked list. If another icon pattern is added, an object obj_2 and its new linked list ll_2 are dynamically created for this pattern, and this object obj_2 is inserted into the head node of the screen display linked list. There are two nodes on the screen display linked list, and the objects of these two nodes have their own empty linked lists. If one of the objects obj_1 is used as the parent object, an object obj_1_1 of a picture resource and its empty linked list ll_1_1 are added to its linked list ll_1. This becomes a two-level linked list structure. The second-level linked list object obj_1_1 continues to create its new child object obj_1_1_1 and the child object's linked list ll_1_1_1, which expands to a three-level linked list structure. By analogy, a multi-level linked list structure can be expanded according to the actual graphical user interface effect on the picture.
[0007] LVGL creates an external storage space for each object to store data related only to this object. LVGL creates an animation subthread for each object. This subthread is bound to this object and can access this object and its external storage space through the object pointer as a parameter.
[0008] LVGL provides the function of deleting objects. When deleting an object, it starts by displaying a linked list on the screen, searching for each object, and the linked list of this object continues to match child objects. By traversing all objects in all multi-level linked lists, the pointer of the object to be deleted is matched. After determining the pointer of the object to be deleted, use this object as the parent object, traverse its linked list, delete all child objects below its level, and finally delete the matched object. The deletion here includes deleting the animation child thread of the object, deleting its external storage space, and deleting the object itself. Summary of the invention
[0009] The technical problem to be solved by the present application is to add a logic layer for managing application activities in the screen display linked list of LVGL itself without adding a stack or linked list for managing application activities. This saves the need to develop a new set of linked lists for managing application activities and simplifies the code.
[0010] To solve the above technical problems, the present application proposes a method for managing application activities based on LVGL, which includes the following steps. Step S10: define the application activity as an object in the lightweight multi-purpose graphics library LVGL, and use the application activity as the only object allowed to be added in the screen display linked list of LVGL. Step S20: when a new application activity needs to be created, call the function of creating a new object of LVGL, add a new node to the head of the screen display linked list as an object, and store the object; the object of the newly created application activity contains the basic attributes of the LVGL object - linked list, external storage space, i.e., node, and animation sub-thread. Step S30: when an application activity needs to be deleted, call the function of deleting an object of LVGL, delete the object of the activity, and LVGL automatically reclaims the deleted application activity object and the linked list, external storage space, and animation sub-thread of all its sub-objects. The order of steps S20 and S30 may be reversed or performed simultaneously. The above method expands and implements the function of managing application activities by modifying and restricting the existing screen display linked list mechanism of LVGL.
[0011] Furthermore, in step S10, multiple activities belonging to one application are treated as multiple LVGL objects, and multiple activities belonging to different applications are also treated as multiple LVGL objects. This application emphasizes treating each activity as an object in LVGL, regardless of whether these activities belong to the same application or different applications.
[0012] Furthermore, in step S20, the object of the newly created application activity also has one or more of the following newly added variables, and all newly added variables are stored in the external storage space of the object of the newly created application activity. The first newly added variable is the serial number of the application activity, which is used to uniquely identify each application activity. The second newly added variable is a pointer to a newly created function, which is used to call the newly created sub-object function. The third newly added variable is a pointer to a pre-deletion function, which is used to call the pre-deletion function. Each newly added variable is used to implement a different function.
[0013] Furthermore, in step S30, if the object of the activity of the deleted application has applied for special resources during the creation process, the pre-deletion function is first called through the pointer of the pre-deletion function to release all the special resources applied for during the creation process of the object of the activity; then the LVGL object deletion function is called to delete the object of the activity. The special resources refer to the resources applied for use in addition to the basic attributes of the LVGL object when the activity of the newly created application is an object; these special resources are not applied for by the LVGL object creation function, and therefore cannot be automatically released by the LVGL object deletion function. This is a specific description of the third newly added variable for handling special situations.
[0014] Furthermore, if a common control is needed in a graphical user interface, an object of an application activity is used as a parent object, and a function of a new child object is called through a pointer to a new function to add a common control child object to the object of the application activity; the common control child object includes any one or more of a picture box, a text box, and a slide box. This is the function of the second newly added variable.
[0015] Furthermore, each common control sub-object also contains the basic properties of the LVGL object after it is created - the linked list of the sub-object, the external storage space of the sub-object, and the animation sub-thread of the sub-object; when an active object of an application is deleted, its sub-objects, their animation sub-threads and external storage space are automatically cleared by LVGL. This makes full use of the existing mechanism of LVGL that automatically deletes the resources of all sub-objects of an object when it is deleted.
[0016] Furthermore, the first newly added variable is used as a basis for matching the object of the activity of the application in the screen display list. This is the function of the first newly added variable.
[0017] Furthermore, the topmost node in the screen display linked list is variable; each time a new application activity object is created, a new node is inserted into the topmost layer of the screen display linked list. The LVGL rendering program believes that the interface implemented by the application activity object corresponding to the topmost node in the screen display linked list is the interface displayed by the topmost layer, so the application activity object corresponding to the last inserted node in the screen display linked list is the interface displayed by the topmost layer. This is how to determine the application activity object corresponding to the currently displayed interface.
[0018] The present application also proposes a management device for application activities based on LVGL, comprising a preprocessing unit, an activity creation unit and an activity deletion unit. The preprocessing unit is used to define the application activity as an object in the lightweight multi-purpose graphics library LVGL, and to use the application activity as the only object allowed to be added in the screen display linked list of LVGL. The activity creation unit is used to call the LVGL's new object creation function when it is necessary to create a new application activity, add a new node to the head of the screen display linked list as an object and store the object; the object of the newly created application activity contains the basic attributes of the LVGL object - linked list, external storage space, i.e., node, animation sub-thread. The activity deletion unit is used to call the LVGL's object deletion function when it is necessary to delete an application activity, delete the object of the activity, and at this time LVGL automatically reclaims the deleted application activity object and the linked list, external storage space and animation sub-thread of all its sub-objects. The above device expands and implements the function of managing application activities by modifying and restricting the existing screen display linked list mechanism of LVGL.
[0019] Furthermore, the activity creation unit also sets one or more of the newly added variables for the object of the newly created application activity, and all the newly added variables are stored in the external storage space of the object of the newly created application activity. The first newly added variable is the serial number of the application activity, which is used to uniquely identify each application activity. The second newly added variable is a pointer to a newly created function, which is used to call the newly created sub-object function. The third newly added variable is a pointer to a pre-deletion function, which is used to call the pre-deletion function. Each newly added variable is used to implement a different function.
[0020] The technical effect achieved by the present application is that no new stack or linked list is added to manage application activities. Modifications and supplements are made based on the existing screen display linked list in LVGL, and the application activities are managed using the LVGL screen display linked list, which greatly simplifies the development of program code. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 It is a flowchart of the method for managing activities of LVGL-based applications proposed in this application.
[0022] Figure 2 It is a schematic diagram of the structure of the LVGL-based application activity management device proposed in this application.
[0023] Explanation of the reference numerals in the figure: 10 is a pre-processing unit, 20 is an activity creation unit, and 30 is an activity deletion unit. DETAILED DESCRIPTION
[0024] In mobile electronic devices, the easiest way to manage application activities is to learn from the Android solution, add a stack, and manage multi-level application activities by stack push and pop. Or, add a linked list to manage multi-level application activities.
[0025] The overall idea of the present application is not to add a new stack or a new linked list, but to reuse the existing screen display linked list in LVGL. By analyzing the existing multi-level linked list management mechanism of LVGL, it can be known that when an object is deleted, all sub-objects of the object can be deleted together, and the memory space (external storage space) and animation sub-threads allocated for this object and all its sub-objects can be cleared. The activities of the application also require a set of automatic recycling mechanisms. If the existing multi-level linked list management mechanism provided by LVGL is used to manage the activities of the application, the automatic recycling of the activities of the application can be achieved by deleting only one object. Therefore, the present application breaks through the conventional thinking of the general technicians in this field and uses the screen display linked list in LVGL for design. However, this solution of the present application also needs to modify or supplement some existing mechanisms in the screen display linked list in LVGL.
[0026] See also Figure 1 The method for managing activities of LVGL-based applications proposed in this application includes the following steps.
[0027] Step S10: define each activity as an object in LVGL, and define the application activity as the only object allowed to be added to the screen display list of LVGL. Each activity belonging to one application is treated as multiple objects, and each activity belonging to different applications is also treated as multiple objects.
[0028] The objects allowed to be added in the existing LVGL screen display linked list are some common control objects, such as buttons, text boxes, picture boxes, etc. This application makes some modifications to this. On the one hand, the application activity is also allowed to be added as an object in the LVGL screen display linked list. On the other hand, the screen display linked list is limited to the only linked list for managing application activities. Only objects of application activities can be added to the screen display linked list, and other common control objects cannot be added.
[0029] Step S20: When a new application activity needs to be created, the LVGL new object function is called, and the activity is treated as an object and a new node is added to the head of the screen display linked list and the object is stored. The newly added node contains the basic properties of the LVGL object - it has a linked list of the object to manage sub-objects, has an external storage space to save parameters or variables, and has an animation sub-thread management mechanism bound to the object.
[0030] Preferably, the present application also adds three variables to the active object of the application. Each object in LVGL has its own external storage space (ie, node), and the three newly added variables are stored in the external storage space of the active object of each application.
[0031] The first newly added variable is the serial number of the applied activity, which is a number used to uniquely identify the activity.
[0032] The second newly added variable is a pointer to a new function, through which a new sub-object function can be called to create a new sub-object for the activity.
[0033] The third newly added variable is a pointer to the pre-deletion function, through which the pre-deletion function can be called to release all the special resources applied for by the application activity in the new creation process before deleting the object of the application activity. The special resources refer to the resources applied for and used in addition to the basic attributes of the LVGL object (linked list, external storage space, animation sub-thread; applied by the existing new object creation mechanism of LVGL) when the new application activity is an object, including cache space, tasks, etc. These special resources are not applied by the existing new object creation mechanism of LVGL, so they cannot be automatically released by the existing recycling (deletion object) mechanism of LVGL. When the object of the application activity is deleted, these special resources are no longer needed and can be released by the pre-deletion function to avoid memory leaks. For example, when the present application creates an application activity as an object in the screen display linked list of LVGL, the activity opens multiple image files, and these image files will be cached in a memory space after the first decompression. The application of this memory space is not in the LVGL default code, but belongs to a special customized requirement, and the existing LVGL mechanism for deleting objects will not release this memory space. This memory space is released by the user calling the pre-deletion function.
[0034] Step S30: When an application activity needs to be deleted, the LVGL object deletion function is called to delete the object of the activity. At this time, LVGL will automatically recycle the object of the deleted application activity and its linked lists, external storage space and animation sub-threads of all sub-objects, eliminating the need to develop a set of code to recycle sub-objects and resources, and reducing the code overhead for managing these resources. This is applicable to the case where the object of the deleted application activity has not applied for special resources during the creation process.
[0035] If the active object of the deleted application applied for special resources during the creation process, the pre-deletion function is first called through the pointer of the pre-deletion function (the third newly added variable) to release all the special resources applied for during the creation of the active object; then the LVGL object deletion function is called to delete the active object.
[0036] There is no strict restriction on the order of step S20 and step S30, and either one may come first.
[0037] From the above method, it can be seen that the innovation of this application is not to propose a linked list mechanism, but to fully inherit the functions of the existing screen display linked list in LVGL and make appropriate supplements and modifications, so as to use the existing screen display linked list in LVGL to realize the switching management between activities of multiple applications without adding too much code.
[0038] In this application, the screen display linked list no longer allows the addition of ordinary control objects, and only the objects of application activities can be added. In response to the need to use ordinary controls in a certain graphical user interface, this application performs the following processing. Take the object of an application activity as the parent object, call the function of the newly created child object through the pointer of the newly created function (the second newly added variable), and add ordinary control sub-objects to the object of the application activity. The ordinary control sub-objects include picture boxes, text boxes, sliding boxes, etc. In this way, the activity of the application independently creates and manages the ordinary control sub-objects of the graphical user interface belonging to the activity. When the activity of this application is deleted, all its sub-objects will be cleared, including the animation sub-threads and external storage space of these sub-objects. After being newly created, each ordinary control sub-object also contains the basic properties of the LVGL object-the linked list of the sub-object, the external storage space of the sub-object, and the animation sub-thread of the sub-object.
[0039] This application can match the application activities in the screen display list according to the serial number of the application activities (the first newly added variable), so as to facilitate the application to find the external storage space of the application activities and further modify the application activities. For example, find the activity of an application in the background state and adjust it to the activity of the application visible in the foreground. For example, when the one-second timing time is up, find the activity of a certain application and modify its recording time parameters. For example, carry out targeted destruction according to the serial number of the application activities.
[0040] The present application can also query the activities of the top-level application in the screen display list, which is used to query the activities of the visible application, so as to facilitate the application to find the external storage space of the application's activities and further modify the application's activities. For example, exit the activities of the currently displayed application. The top-level (head) node in the screen display list is variable, and the object of the application's activity corresponding to this top-level node is the one that implements the interface currently being displayed. Each time a new object of an application's activity is created, a new node is inserted at the top level of the screen display list. The LVGL rendering program believes that the interface implemented by the application's activity corresponding to the top-level node in the screen display list is the interface that the top-level (top) layer needs to display, so the object of the application's activity corresponding to the last node inserted in the screen display list is the interface that the top-level layer needs to display.
[0041] See also Figure 2 The LVGL-based application activity management device proposed in the present application includes a pre-processing unit 10 , an activity creation unit 20 , and an activity deletion unit 30 .
[0042] The pre-processing unit 10 is used to define each activity as an object in LVGL, and to use the application activity as the only object allowed to be added to the screen display list of LVGL.
[0043] The activity creation unit 20 is used to call the LVGL object creation function when a new application activity needs to be created, and add a node to the head of the screen display linked list as an object to store the object. The newly added node contains the basic attributes of the LVGL object - the linked list of the object, the external storage space of the object, and the animation subthread of the object, and preferably three variables are added.
[0044] The first newly added variable is the serial number of the applied activity, which is a number used to uniquely identify the activity.
[0045] The second newly added variable is a pointer to a new function, through which a new sub-object function can be called to create a new sub-object for the activity.
[0046] The third newly added variable is a pointer to the pre-deletion function, through which the pre-deletion function can be called to release all special resources applied for by the application's activities during the creation process before deleting the objects of the application's activities.
[0047] The activity deletion unit 30 is used to call the LVGL object deletion function to delete the object of the activity when an application activity needs to be deleted. At this time, LVGL will automatically recycle the deleted application activity object and its linked lists, external storage space and animation sub-threads of all its sub-objects.
[0048] If the active object of the deleted application applied for special resources during the creation process, the pre-deletion function is first called through the pointer of the pre-deletion function (the third newly added variable) to release all the special resources applied for during the creation of the active object; then the LVGL object deletion function is called to delete the active object.
[0049] This application uses LVGL's ready-made screen display linked list and multi-level linked list management mechanism to develop an application activity management mechanism. Due to the reuse of LVGL's ready-made linked list mechanism, it not only saves code overhead but also inherits many existing functions, while also making necessary modifications and innovations. After creating many sub-objects for an application's activities, when you finally want to close the application's activities, you only need to call LVGL's existing object deletion method to destroy the application's activity objects. At this time, the resources related to the object and the resources related to all sub-objects of the object will all be destroyed and recycled through the LVGL mechanism and the pre-deletion function newly added by this application, which saves the need to develop another set of code to recycle sub-objects and resources. This application's modification of the LVGL code is simple and achieves the expected function; the activities of multiple applications can be switched at will.
[0050] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should all be included in the protection scope of the present application.
Claims
1. A method for managing activities of an application based on LVGL, characterized in that: The method comprises the following steps: Step S10: define the application activity as an object in the lightweight general-purpose graphics library LVGL, and use the application activity as the only object allowed to be added to the screen display list of LVGL; Step S20: when a new application activity needs to be created, the function of creating a new object of LVGL is called, and a new node is added to the head of the screen display linked list as an object to store the object; the object of the newly created application activity includes the basic attributes of the LVGL object - linked list, external storage space, i.e., node, animation subthread; In the step S20, the newly created object of the application activity further has one or more of the following newly added variables, and all the newly added variables are stored in the external storage space of the newly created object of the application activity; The first newly added variable is the serial number of the application's activity, which is used to uniquely identify each application's activity; The second newly added variable is the pointer to the newly created function, which is used to call the newly created sub-object function; The third newly added variable is the pointer of the pre-deletion function, which is used to call the pre-deletion function; Step S30: when an application activity needs to be deleted, the object deletion function of LVGL is called to delete the object of the activity. At this time, LVGL automatically reclaims the object of the deleted application activity and the linked lists of all its child objects, external storage space and animation child threads; The order of step S20 and step S30 may be reversed or performed simultaneously.
2. The method for managing activities of LVGL-based applications according to claim 1, characterized in that: In the step S10, multiple activities belonging to one application are treated as objects in multiple LVGLs, and multiple activities belonging to different applications are also treated as objects in multiple LVGLs.
3. The method for managing activities of LVGL-based applications according to claim 1, characterized in that: In the step S30, if the object of the activity of the deleted application has applied for special resources during the creation process, the pre-deletion function is first called through the pointer of the pre-deletion function to release all the special resources applied for during the creation process of the object of the activity; then the object deletion function of LVGL is called to delete the object of the activity; The special resources refer to the resources applied for use in addition to the basic properties of the LVGL object when the activity of the newly created application is an object; these special resources are not applied for by the LVGL function of creating a new object, and therefore cannot be automatically released by the LVGL function of deleting an object.
4. The method for managing activities of LVGL-based applications according to claim 1, characterized in that: If a common control is needed in a graphical user interface, an active object of an application is used as a parent object, and a function of a newly created child object is called through a pointer to a newly created function to add a common control child object to the active object of the application; the common control child object includes any one or more of a picture box, a text box, and a sliding box.
5. The method for managing activities of LVGL-based applications according to claim 4, characterized in that: After being created, each common control sub-object also contains the basic properties of the LVGL object - the linked list of the sub-object, the external storage space of the sub-object, and the animation sub-thread of the sub-object; when an active object of an application is deleted, its sub-objects, their animation sub-threads and external storage space are automatically cleared by LVGL.
6. The method for managing activities of LVGL-based applications according to claim 1, characterized in that: The first newly added variable is used as a basis for matching objects of the activities of the applications in the screen display list.
7. The method for managing activities of LVGL-based applications according to claim 1, characterized in that: The top-level node in the screen display linked list is variable; each time a new active object of an application is created, a new node is inserted at the top level of the screen display linked list. The LVGL rendering program believes that the interface implemented by the active object of the application corresponding to the top-level node in the screen display linked list is the interface displayed on the top-level layer, so the active object of the application corresponding to the last node inserted in the screen display linked list is the interface displayed on the top-level layer.
8. A device for managing activities of an application based on LVGL, characterized in that: It includes a pre-processing unit, an activity creation unit and an activity deletion unit; The preprocessing unit is used to define the application activity as an object in the lightweight general-purpose graphics library LVGL, and use the application activity as the only object allowed to be added in the screen display list of LVGL; The activity creation unit is used to call the function of creating a new object of LVGL when a new application activity needs to be created, and add a new node to the head of the screen display linked list as an object and store the object; the object of the newly created application activity includes the basic attributes of the LVGL object - linked list, external storage space, i.e., node, animation subthread; The activity creation unit further sets one or more of the newly added variables for the object of the activity of the newly created application, and all the newly added variables are stored in the external storage space of the object of the activity of the newly created application; The first newly added variable is the serial number of the application's activity, which is used to uniquely identify each application's activity; The second newly added variable is the pointer to the newly created function, which is used to call the newly created sub-object function; The third newly added variable is the pointer of the pre-deletion function, which is used to call the pre-deletion function; The activity deletion unit is used to call the LVGL object deletion function to delete the object of the activity when an application activity needs to be deleted. At this time, LVGL automatically reclaims the deleted application activity object and its linked lists, external storage space and animation sub-threads of all its sub-objects.
Citation Information
Patent Citations
OpenGL ES (open graphics library for embedded system)-based graphical framework system designing method for pure liquid crystal automobile instrument panel
CN103745074A
Application development environment configuration method, device and equipment and storage medium
CN112199087A