Hi All,
I found that I needed to have a common look and feel as well as page/screen navigation without the need to consistently deal with that on every page or screen that is created.
So I wrote a LittlevGL application framework I have called Sandbox.
It has the following features and characteristics,
- Home, Previous and Next page navigations,
- Optionally Settings, Info and Help button callbacks. These can be context specific (IE associated with a specific page) or one which handles the same for the application as a whole or only part thereof.
- Each page has a title which is displayed in the header.
- Allocates, clears and deallocates memory required by each page. No global variables needed or required (in fact discouraged) if used as intended.
- Provides for “Create, Task and Destroy” callbacks.
- All configuration and parameters can be placed in Read only memory. I am always one to be frugal with RAM …
- Does not limit or restrict any LittlevGL functions or features.
- Effectively self contained within only a few C source and header files.
- Coding style and naming conventions modeled on that in LittlevGL.
- Auto prunes the navigation list length so as not to become to long, nested or congested.
- Navigation uses a different linked list to that of LittlevGL (it just suited my purposes better), but it can easily written to use LittlevGL’s.
The Sandbox provides for “Create, Task and Destroy” callbacks, global variables are not required at all, again if the programming model is used as intended.
A descriptor pointer is passed with parameters to the Sandbox at instantiation,
The API is simple. It looks as follows,
/**********************
* TYPEDEFS
**********************/
typedef void (*sndbx_pge_create_cb_t)(lv_obj_t *, void *, const void *);
typedef void (*sndbx_pge_task_cb_t)(void *);
typedef void (*sndbx_pge_destroy_cb_t)(void *);
typedef void (*sndbx_pge_help_cb_t)(void *, lv_event_t);
typedef void (*sndbx_pge_settings_cb_t)(void *, lv_event_t);
typedef void (*sndbx_pge_info_cb_t)(void *, lv_event_t);
typedef struct {
const char * name; /**< Name of page, displayed in the toolbar */
uint32_t mem_size; /**< How much memory the page needs */
sndbx_pge_create_cb_t create_cb; /**< Called when the page is created */
sndbx_pge_task_cb_t task_cb; /**< Called periodically, set by task_interval */
sndbx_pge_destroy_cb_t destroy_cb; /**< Called when the page is destroyed */
lv_task_prio_t task_prio; /**< Task Priority */
uint32_t task_period; /**< How often the task should run */
sndbx_pge_settings_cb_t settings_cb; /**< Called on settings button events */
sndbx_pge_info_cb_t info_cb; /**< Called on info button events */
sndbx_pge_help_cb_t help_cb; /**< Called on help button events */
} sndbx_pge_dsc_t;
typedef struct {
const sndbx_pge_dsc_t * dsc;
const void * prms;
} sndbx_pge_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
*
*/
extern void sndbx_create_app( const sndbx_pge_t * home );
extern void sndbx_create_page( const sndbx_pge_t * page );
extern lv_task_t * sndbx_get_task( void );
I am in the process of converting all of the LittlevGL example repo apps, tutorials and tests so that they can contained within a single application and dispatched via a home page,
So far I have completed “Hello world”, “Demo”, “Benchmark”, “Sysmon” and soon to complete “Theme Test’s 1 & 2” and later the others. I have not had any issues with this so far, it has mainly involved placing all global (to the app/demo/test file that is, more specifically statically or linker allocated memory) variables in a structure which is sized and included in the sandbox page descriptor so that the correct amount of memory can be allocated for the concerned page.
The model relies on the user data members in the lv_x objects to pass memory pointers to the callbacks and assumes that lv_user_data_t
, lv_anim_user_data_t
etc are defined as void *
in lv_config.h.
Please see the screen shots below,
Note the use of the Warning (for Info) and Call (for Help) symbols, I just have not had the time to generate more suitable ones using the online font converter, but that is a mechanical process and easy to do.
I am posting this to see if there is any interest for what I have done so far. If so I will create a GitHub repo (after properly structuring and organizing the file placement for an easy bolt on to LittlevGL and to ensure there are no compiler complaints when correctly placed) and make it available.
If there is absolutely no interest then I will not waste my time