/** * @file lv_app_example.c * */ /********************* * INCLUDES *********************/ #include "lv_app_phantom.h" #if LV_APP_ENABLE != 0 && USE_LV_APP_PHANTOM != 0 #include "../lv_app/lv_app_util/lv_app_kb.h" #include /********************* * DEFINES *********************/ /********************** * TYPEDEFS **********************/ /*Application specific data for an instance of this application*/ typedef struct { void (*com_listen)(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, lv_app_com_type_t type , const void * data, uint32_t size); }my_app_data_t; /*Application specific data a window of this application*/ typedef struct { }my_win_data_t; /*Application specific data for a shortcut of this application*/ typedef struct { lv_obj_t * label; }my_sc_data_t; /********************** * STATIC PROTOTYPES **********************/ static void my_app_run(lv_app_inst_t * app, void * conf); static void my_app_close(lv_app_inst_t * app); static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, lv_app_com_type_t type , const void * data, uint32_t size); /********************** * STATIC VARIABLES **********************/ static lv_app_dsc_t my_app_dsc = { .name = "Phantom", .mode = LV_APP_MODE_NONE, .app_run = my_app_run, .app_close = my_app_close, .com_rec = my_com_rec, .win_open = NULL, .win_close = NULL, .sc_open = NULL, .sc_close = NULL, .app_data_size = sizeof(my_app_data_t), .sc_data_size = sizeof(my_sc_data_t), .win_data_size = sizeof(my_win_data_t), }; /********************** * MACROS **********************/ /********************** * GLOBAL FUNCTIONS **********************/ /** * Initialize the application * @return pointer to the application descriptor of this application */ const lv_app_dsc_t * lv_app_phantom_init(void) { return &my_app_dsc; } /********************** * STATIC FUNCTIONS **********************/ /** * Run an application according to 'app_dsc' * @param app_dsc pointer to an application descriptor * @param conf pointer to a lv_app_phantom_conf_t structure with configuration data or NULL if unused * @return pointer to the opened application or NULL if any error occurred */ static void my_app_run(lv_app_inst_t * app, void * conf) { /*Initialize the application*/ my_app_data_t * app_data = app->app_data; app_data->com_listen = NULL; if(conf != NULL) { lv_app_phantom_conf_t * my_conf = conf; app_data->com_listen = my_conf->com_listen; } } /** * Close a running application. * Close the Window and the Shortcut too if opened. * Free all the allocated memory by this application. * @param app pointer to an application */ static void my_app_close(lv_app_inst_t * app) { /*No dynamically allocated data in 'my_app_data'*/ } /** * Read the data have been sent to this application * @param app_send pointer to an application which sent the message * @param app_rec pointer to an application which is receiving the message * @param type type of data from 'lv_app_com_type_t' enum * @param data pointer to the sent data * @param size length of 'data' in bytes */ static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, lv_app_com_type_t type , const void * data, uint32_t size) { my_app_data_t * app_data = app_rec->app_data; if(app_data->com_listen != NULL) { app_data->com_listen(app_send, app_rec, type, data, size); } } /*-------------------- * OTHER FUNCTIONS ---------------------*/ #endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/