vletter draw optimited, LV_UPSCALE_STYLE and LV_STYLE_MULT removed and replaced with LV_DOWNSCALE
This commit is contained in:
@@ -6,8 +6,11 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <lvgl/lv_app/lv_app_sup.h>
|
||||
#include "lv_app_example.h"
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0
|
||||
|
||||
#include "../lv_app/lv_app_sup.h"
|
||||
#include "misc/os/ptask.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
@@ -22,31 +25,33 @@
|
||||
typedef struct
|
||||
{
|
||||
const char * txt;
|
||||
}app_data_t;
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}win_data_t;
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}sc_data_t;
|
||||
lv_obj_t * label;
|
||||
}my_sc_data_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, const char * cstr);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_event_read(lv_app_inst_t * app, lv_app_event_t event);
|
||||
static void my_com_rec(lv_app_inst_t * app_rec, lv_app_inst_t * app_sender, lv_app_com_type_t type , void * data, uint32_t len);
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc);
|
||||
static void my_sc_close(lv_app_inst_t * app);
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win);
|
||||
static void my_win_close(lv_app_inst_t * app);
|
||||
|
||||
static void task(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
@@ -56,14 +61,14 @@ static lv_app_dsc_t my_app_dsc =
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.event_read = my_event_read,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = my_win_open,
|
||||
.win_close = my_win_close,
|
||||
.sc_open = my_sc_open,
|
||||
.sc_close = my_sc_close,
|
||||
.app_data_size = sizeof(app_data_t),
|
||||
.sc_data_size = sizeof(sc_data_t),
|
||||
.win_data_size = sizeof(win_data_t),
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
/**********************
|
||||
@@ -76,6 +81,8 @@ static lv_app_dsc_t my_app_dsc =
|
||||
|
||||
const lv_app_dsc_t * lv_app_example_init(void)
|
||||
{
|
||||
ptask_create(task, 200, PTASK_PRIO_MID);
|
||||
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
@@ -97,7 +104,7 @@ static void my_app_run(lv_app_inst_t * app, const char * cstr)
|
||||
}
|
||||
|
||||
/*Initialize the application*/
|
||||
((app_data_t *)app->app_data)->txt = cstr; /*Save the create string*/
|
||||
((my_app_data_t *)app->app_data)->txt = cstr; /*Save the create string*/
|
||||
char buf[256];
|
||||
sprintf(buf,"%s - %s", my_app_dsc.name, cstr);
|
||||
lv_app_rename(app, buf);
|
||||
@@ -115,13 +122,22 @@ static void my_app_close(lv_app_inst_t * app)
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish an event.
|
||||
* @param app pointer to an application which publishes the event
|
||||
* @param event an event from 'lv_app_event_t' enum
|
||||
* Read the data have been sent to this application
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param len length of 'data' in bytes
|
||||
*/
|
||||
static void my_event_read(lv_app_inst_t * app, lv_app_event_t event)
|
||||
static void my_com_rec(lv_app_inst_t * app_rec, lv_app_inst_t * app_send,
|
||||
lv_app_com_type_t type , void * data, uint32_t len)
|
||||
{
|
||||
if(type == LV_APP_COM_TYPE_STR) { /*data: string*/
|
||||
|
||||
}
|
||||
else if(type == LV_APP_COM_TYPE_BIN) { /*data: array of 'int32_t' */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,11 +148,12 @@ static void my_event_read(lv_app_inst_t * app, lv_app_event_t event)
|
||||
*/
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
|
||||
{
|
||||
lv_obj_t * label;
|
||||
label = lv_label_create(sc, NULL);
|
||||
lv_label_set_text(label, ((app_data_t *)app->app_data)->txt);
|
||||
lv_obj_set_style(label, lv_labels_get(LV_LABELS_BTN, NULL));
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
sc_data->label = lv_label_create(sc, NULL);
|
||||
lv_label_set_text(sc_data->label, ((my_app_data_t *)app->app_data)->txt);
|
||||
lv_obj_set_style(sc_data->label, lv_labels_get(LV_LABELS_DEF, NULL));
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,24 +174,23 @@ lv_action_res_t kb_open(lv_obj_t * ta, lv_dispi_t * dispi);
|
||||
*/
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
|
||||
{
|
||||
my_sc_data_t * win_data = app->win_data;
|
||||
|
||||
|
||||
lv_obj_t * label;
|
||||
label = lv_label_create(win, NULL);
|
||||
lv_label_set_text(label, ((app_data_t *)app->app_data)->txt);
|
||||
win_data->label = lv_label_create(win, NULL);
|
||||
lv_label_set_text(win_data->label, ((my_app_data_t *)app->app_data)->txt);
|
||||
|
||||
|
||||
lv_obj_t * ta;
|
||||
ta = lv_ta_create(win, NULL);
|
||||
lv_obj_set_size_us(ta, 200, 100);
|
||||
lv_obj_set_pos_us(ta, 20, 200);
|
||||
// lv_rect_set_fit(ta, false, true);
|
||||
lv_page_set_rel_action(ta, kb_open);
|
||||
}
|
||||
|
||||
lv_action_res_t kb_open(lv_obj_t * ta, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_NUM, NULL, NULL);
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_TXT, NULL, NULL);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
@@ -188,3 +204,38 @@ static void my_win_close(lv_app_inst_t * app)
|
||||
}
|
||||
|
||||
|
||||
static void task(void)
|
||||
{
|
||||
|
||||
return;
|
||||
dm_defrag();
|
||||
|
||||
dm_mon_t mon;
|
||||
dm_monitor(&mon);
|
||||
|
||||
lv_app_inst_t * app;
|
||||
app = lv_app_get_next_app(NULL, &my_app_dsc);
|
||||
|
||||
while(app != NULL) {
|
||||
char buf[256];
|
||||
sprintf(buf, "Mem. total: %d\nMem. free: %d (%d)\nFrag: %d%%",
|
||||
DM_MEM_SIZE, mon.size_free, mon.size_free * 100 / DM_MEM_SIZE, mon.pct_frag);
|
||||
|
||||
if(app->sc_data != NULL) {
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
lv_label_set_text(sc_data->label, buf);
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
if(app->win_data != NULL) {
|
||||
my_sc_data_t * win_data = app->win_data;
|
||||
lv_label_set_text(win_data->label, buf);
|
||||
// lv_obj_align(win_data->label, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
|
||||
}
|
||||
app = lv_app_get_next_app(app, &my_app_dsc);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@@ -18,6 +20,10 @@
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}lv_app_example_conf_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@@ -27,4 +33,6 @@
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
|
||||
|
||||
#endif /* LV_APP_EXAMPLE */
|
||||
|
||||
Reference in New Issue
Block a user