BigW Consortium Gitlab

Commit 454b0e2a by Gabor

App connection added

parent 5459fc3c
......@@ -61,7 +61,7 @@ typedef struct __LV_APP_DSC_T
lv_app_mode_t mode;
void (*app_run)(lv_app_inst_t *, const char *);
void (*app_close) (lv_app_inst_t *);
void (*com_rec) (lv_app_inst_t *, lv_app_inst_t *, lv_app_com_type_t, void *, uint32_t);
void (*com_rec) (lv_app_inst_t *, lv_app_inst_t *, lv_app_com_type_t, const void *, uint32_t);
void (*sc_open) (lv_app_inst_t *, lv_obj_t *);
void (*sc_close) (lv_app_inst_t *);
void (*win_open) (lv_app_inst_t *, lv_obj_t *);
......@@ -80,6 +80,8 @@ typedef struct {
lv_pages_t sc_page_style;
lv_wins_t win_style;
lv_btns_t sc_style;
lv_btns_t sc_send_style;
lv_btns_t sc_rec_style;
lv_labels_t sc_title_style;
opa_t menu_opa;
......@@ -99,7 +101,7 @@ typedef struct {
void lv_app_init(void);
lv_app_inst_t * lv_app_run(const lv_app_dsc_t * app_dsc, const char * cstr);
void lv_app_close(lv_app_inst_t * app);
uint16_t lv_app_com_send(lv_app_inst_t * app_send, lv_app_com_type_t type , void * data, uint32_t len);
uint16_t lv_app_com_send(lv_app_inst_t * app_send, lv_app_com_type_t type , const void * data, uint32_t len);
lv_obj_t * lv_app_sc_open(lv_app_inst_t * app);
void lv_app_sc_close(lv_app_inst_t * app);
lv_obj_t * lv_app_win_open(lv_app_inst_t * app);
......@@ -107,6 +109,7 @@ void lv_app_win_close(lv_app_inst_t * app);
lv_obj_t * lv_app_get_win_from_obj(lv_obj_t * obj);
const lv_app_dsc_t * lv_app_get_dsc(const char * name);
void lv_app_set_con(lv_app_inst_t * sender, lv_app_inst_t * receiver);
lv_app_style_t * lv_app_get_style(void);
void lv_app_rename(lv_app_inst_t * app, const char * name);
void lv_app_refr_style(void);
......
......@@ -44,7 +44,7 @@ typedef struct
**********************/
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_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_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 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);
......@@ -123,17 +123,22 @@ static void my_app_close(lv_app_inst_t * app)
/**
* 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 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 len length of 'data' in bytes
*/
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)
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 len)
{
if(type == LV_APP_COM_TYPE_STR) { /*data: string*/
my_sc_data_t * sc_data = app_rec->sc_data;
if (sc_data->label != NULL) {
lv_label_set_text(sc_data->label, data);
lv_obj_align(sc_data->label , NULL,LV_ALIGN_CENTER, 0, 0);
}
}
else if(type == LV_APP_COM_TYPE_BIN) { /*data: array of 'int32_t' */
......@@ -186,11 +191,18 @@ static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
lv_obj_set_size_us(ta, 200, 100);
lv_obj_set_pos_us(ta, 20, 200);
lv_page_set_rel_action(ta, kb_open);
lv_obj_set_free_p(ta, app);
}
void kb_ok(lv_obj_t * ta) {
lv_app_inst_t * app = lv_obj_get_free_p(ta);
const char * txt = lv_ta_get_txt(ta);
lv_app_com_send(app, LV_APP_COM_TYPE_STR, txt, strlen(txt) + 1);
}
lv_action_res_t kb_open(lv_obj_t * ta, lv_dispi_t * dispi)
{
lv_app_kb_open(ta, LV_APP_KB_MODE_TXT, NULL, NULL);
lv_app_kb_open(ta, LV_APP_KB_MODE_TXT, NULL, kb_ok);
return LV_ACTION_RES_OK;
}
......
......@@ -141,13 +141,7 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
vdb_buf_tmp += (row_start * vdb_width) + col_start;
/*Move on the map too*/
#if LV_UPSCALE_FONT == 0 || LV_DOWNSCALE == 1
map_p += (row_start * font_p->width_byte) + (col_start>>3);
#elif LV_DOWNSCALE == 2
map_p += ((row_start >> 1) * font_p->width_byte) + ((col_start >> 1)>>3);
#elif LV_DOWNSCALE == 4
map_p += ((row_start >> 2) * font_p->width_byte) + ((col_start >> 2)>>3);
#endif
for(row = row_start; row < row_end; row ++) {
col_byte_cnt = 0;
......@@ -161,34 +155,16 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
vdb_buf_tmp++;
/*Use a col. more times depending on LV_UPSCALE_FONT*/
#if LV_UPSCALE_FONT == 0 || LV_DOWNSCALE == 1
/*Use all cols.*/
#elif LV_DOWNSCALE == 2
if((col & 0x01) == 0)
#elif LV_DOWNSCALE == 4
if((col & 0x03) == 0)
#endif
{
if(col_bit != 0) col_bit --;
else {
col_bit = 7;
col_byte_cnt ++;
map_p ++;
}
if(col_bit != 0) col_bit --;
else {
col_bit = 7;
col_byte_cnt ++;
map_p ++;
}
}
/*Use a row more times depending on LV_UPSCALE_FONT*/
#if LV_UPSCALE_FONT == 0 || LV_DOWNSCALE == 1
map_p += font_p->width_byte - col_byte_cnt;
#elif LV_DOWNSCALE == 2
if((row & 0x01) == 0) map_p += font_p->width_byte - col_byte_cnt; /*Next row in the map*/
else map_p -= col_byte_cnt; /*Reset the row*/
#elif LV_DOWNSCALE == 4
if((row & 0x03) == 0) map_p += font_p->width_byte - col_byte_cnt; /*Next row in the map*/
else map_p -= col_byte_cnt; /*Reset the row*/
#endif
vdb_buf_tmp += vdb_width - (col_end - col_start); /*Next row in VDB*/
}
}
......
......@@ -88,11 +88,7 @@ static inline const uint8_t * font_get_bitmap(const font_t * font_p, uint8_t let
*/
static inline uint8_t font_get_height(const font_t * font_p)
{
#if LV_DOWNSCALE > 1 && LV_UPSCALE_FONT != 0
return font_p->height_row * LV_DOWNSCALE;
#else
return font_p->height_row;
#endif
}
/**
......@@ -112,11 +108,7 @@ static inline uint8_t font_get_width(const font_t * font_p, uint8_t letter)
font_p->width_bit_a[letter];
}
#if LV_DOWNSCALE > 1 && LV_UPSCALE_FONT != 0
return w * LV_DOWNSCALE;
#else
return w;
#endif
}
#endif
......@@ -64,10 +64,10 @@ void txt_get_size(point_t * size_res, const char * text, const font_t * font,
size_res->y += letter_height + line_space;
}
/*Correction with the last line space*/
if(size_res->y >= 0) {
size_res->y -= line_space;
}
/*Correction with the last line space or set the height manually if the text is empty*/
if(size_res->y == 0) size_res->y = letter_height;
else size_res->y -= line_space;
}
/**
......
......@@ -28,8 +28,8 @@
#error "LV: LV_DOWNSCALE can be only 1, 2 or 4"
#endif
#if LV_VDB_SIZE == 0 && (LV_DOWNSCALE != 1 || LV_UPSCALE_MAP != 0 || LV_UPSCALE_FONT != 0 || LV_UPSCALE_STYLE != 0)
#error "LV: If LV_VDB_SIZE == 0 then LV_DOWNSCALE must be 1, LV_UPSCALE_MAP 0, LV_UPSCALE_FONT 0, LV_UPSCALE_STYLE 0"
#if LV_VDB_SIZE == 0 && (LV_DOWNSCALE != 1 || LV_UPSCALE_MAP != 0 || LV_UPSCALE_STYLE != 0)
#error "LV: If LV_VDB_SIZE == 0 then LV_DOWNSCALE must be 1, LV_UPSCALE_MAP 0, LV_UPSCALE_STYLE 0"
#endif
/*New defines*/
......
......@@ -120,7 +120,7 @@ bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void* param)
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
bool tgl = lv_btn_get_tgl(btn);
switch (sign){
switch (sign) {
case LV_SIGNAL_PRESSED:
/*Refresh the state*/
if(ext->state == LV_BTN_STATE_REL) {
......@@ -357,7 +357,17 @@ static bool lv_btn_design(lv_obj_t * btn, const area_t * mask, lv_design_mode_t
/* Because of the radius it is not sure the area is covered*/
if(mode == LV_DESIGN_COVER_CHK) {
return ancestor_design_f(btn, mask, mode);
/*Temporally set a rectangle style for the button to look like as rectangle*/
lv_rects_t rects_tmp;
lv_btns_t * btns_tmp = lv_obj_get_style(btn);
bool ret = false;
lv_btn_style_load(btn, &rects_tmp);
if(rects_tmp.objs.transp == 0) {
btn->style_p = &rects_tmp;
ret = ancestor_design_f(btn, mask, mode); /*Draw the rectangle*/
btn->style_p = btns_tmp; /*Reload the original button style*/
}
return ret;
} else if(mode == LV_DESIGN_DRAW_MAIN) {
area_t area;
lv_obj_get_cords(btn, &area);
......
......@@ -140,6 +140,7 @@ bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
}
break;
case LV_SIGNAL_RELEASED:
case LV_SIGNAL_LONG_PRESS_REP:
if(ext->cb != NULL &&
ext->btn_pr != LV_BTNM_BTN_PR_INVALID) {
uint16_t txt_i = 0;
......@@ -153,7 +154,7 @@ bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
ext->cb(btnm, txt_i);
}
ext->btn_pr = LV_BTNM_BTN_PR_INVALID;
if(sign == LV_SIGNAL_RELEASED) ext->btn_pr = LV_BTNM_BTN_PR_INVALID;
lv_obj_inv(btnm);
break;
default:
......
......@@ -159,6 +159,18 @@ bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
lv_page_sb_refresh(page);
}
break;
case LV_SIGNAL_PRESSED:
if(ext->pr_action != NULL) {
ext->pr_action(page, param);
}
break;
case LV_SIGNAL_RELEASED:
if(lv_dispi_is_dragging(param) == false) {
if(ext->rel_action != NULL) {
ext->rel_action(page, param);
}
}
break;
default:
break;
......@@ -268,17 +280,17 @@ static bool lv_scrolling_signal(lv_obj_t * scrolling, lv_signal_t sign, void* pa
}
break;
case LV_SIGNAL_PRESSED:
if(page_ext->pr_action != NULL) {
page_ext->pr_action(page, param);
}
break;
if(page_ext->pr_action != NULL) {
page_ext->pr_action(page, param);
}
break;
case LV_SIGNAL_RELEASED:
if(lv_dispi_is_dragging(param) == false) {
if(page_ext->rel_action != NULL) {
page_ext->rel_action(page, param);
}
}
break;
if(lv_dispi_is_dragging(param) == false) {
if(page_ext->rel_action != NULL) {
page_ext->rel_action(page, param);
}
}
break;
default:
break;
......@@ -491,8 +503,6 @@ static bool lv_page_design(lv_obj_t * page, const area_t * mask, lv_design_mode_
*/
static void lv_page_sb_refresh(lv_obj_t * page)
{
lv_page_ext_t * page_ext = lv_obj_get_ext(page);
lv_pages_t * pages = lv_obj_get_style(page);
lv_obj_t * scrolling = page_ext->scrolling;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment