lv_app_notice added

This commit is contained in:
Kiss-Vamosi Gabor
2016-12-29 07:10:49 +01:00
parent 3019787dcf
commit 2f11b276ac
8 changed files with 202 additions and 22 deletions

View File

@@ -9,7 +9,8 @@
#include "lv_app.h"
#if LV_APP_ENABLE != 0
#include "lv_app_sup.h"
#include "lv_app_util/lv_app_kb.h"
#include "lv_app_util/lv_app_notice.h"
#include "lvgl/lv_misc/anim.h"
/*********************
@@ -58,7 +59,6 @@ static lv_obj_t * app_scr; /*Screen of the applications*/
static lv_obj_t * menuh; /*Holder of timg_bubbleshe menu on the top*/
static lv_obj_t * app_btn; /*The "Apps" button on the menu*/
static lv_obj_t * sys_apph; /*Holder of the system app. buttons*/
static lv_obj_t * clock; /*Clock on the menu bar (right top)*/
static lv_obj_t * app_list; /*A list which is opened on 'app_btn' release*/
static lv_obj_t * sc_page; /*A page for the shortcuts */
static lv_app_inst_t * con_send; /*The sender application in connection mode. Not NLL means connection mode is active*/
@@ -117,6 +117,10 @@ void lv_app_init(void)
/*Create the desktop elements*/
lv_app_init_desktop();
/*Init. the utilities*/
lv_app_kb_init();
lv_app_notice_init();
/*Initialize all application descriptors*/
/*ADD NEW APPLICATION INITS HERE!!!*/
const lv_app_dsc_t ** dsc;
@@ -286,6 +290,11 @@ uint16_t lv_app_com_send(lv_app_inst_t * app_send, lv_app_com_type_t type , cons
lv_app_con_t * con;
uint16_t rec_cnt = 0;
/*Add the notifications to the notice utility*/
if(type == LV_APP_COM_TYPE_NOTICE) {
lv_app_notice_add(data);
}
LL_READ(app_con_ll, con) {
if(con->sender == app_send) {
if(con->receiver->dsc->com_rec != NULL)
@@ -485,9 +494,10 @@ static void lv_app_init_desktop(void)
lv_rect_set_fit(sys_apph, true, false);
lv_obj_set_height(sys_apph, app_style.menu_h);
lv_obj_set_style(sys_apph, lv_rects_get(LV_RECTS_TRANSP, NULL));
clock = lv_label_create(sys_apph, NULL);
/* clock = lv_label_create(sys_apph, NULL);
lv_obj_set_style(clock, &app_style.menu_btn_label_style);
lv_label_set_text(clock, "20:17");
*/
lv_obj_align(sys_apph, NULL, LV_ALIGN_IN_RIGHT_MID, 0, 0);
lv_app_refr_style();

View File

@@ -33,7 +33,7 @@ typedef enum
LV_APP_COM_TYPE_BIN, /*Binary data as 'int32_t' array*/
LV_APP_COM_TYPE_SYS, /*System level event*/
LV_APP_COM_TYPE_LOG, /*String about an event to log*/
LV_APP_COM_TYPE_NOTE, /*String to display to the user as a notification*/
LV_APP_COM_TYPE_NOTICE, /*String to display to the user as a notification*/
LV_APP_COM_TYPE_TRIG, /*A trigger to do some specific action (data is ignored)*/
}lv_app_com_type_t;

View File

@@ -6,11 +6,11 @@
/*********************
* INCLUDES
*********************/
#include "lv_app_sup.h"
#include "lv_app_kb.h"
#if LV_APP_ENABLE != 0
#include "../lv_objx/lv_btnm.h"
#include "../lv_objx/lv_ta.h"
#include "lvgl/lv_objx/lv_btnm.h"
#include "lvgl/lv_objx/lv_ta.h"
/*********************
* DEFINES
@@ -65,7 +65,6 @@ static bool kb_first;
static void (*kb_close_action)(lv_obj_t *);
static void (*kb_ok_action)(lv_obj_t *);
static lv_btnms_t kb_btnms;
static bool kb_inited;
/**********************
* MACROS
@@ -75,6 +74,15 @@ static bool kb_inited;
* GLOBAL FUNCTIONS
**********************/
void lv_app_kb_init(void)
{
lv_btnms_get(LV_BTNMS_DEF, &kb_btnms);
kb_btnms.rects.opad = 4 + LV_DOWNSCALE;
kb_btnms.rects.vpad = 3 + LV_DOWNSCALE;
kb_btnms.rects.hpad = 3 + LV_DOWNSCALE;
kb_btnms.rects.round = 0;
}
/**
* Open a keyboard for a text area object
* @param ta pointer to a text area object
@@ -84,17 +92,6 @@ static bool kb_inited;
*/
void lv_app_kb_open(lv_obj_t * ta, lv_app_kb_mode_t mode, void (*close)(lv_obj_t *), void (*ok)(lv_obj_t *))
{
/*Init the style*/
if(kb_inited == false) {
lv_btnms_get(LV_BTNMS_DEF, &kb_btnms);
kb_btnms.rects.opad = 4 + LV_DOWNSCALE;
kb_btnms.rects.vpad = 3 + LV_DOWNSCALE;
kb_btnms.rects.hpad = 3 + LV_DOWNSCALE;
kb_btnms.rects.round = 0;
kb_inited = true;
}
/*Close the previous keyboard*/
if(kb_btnm != NULL) {
lv_app_kb_close(false);

View File

@@ -9,7 +9,7 @@
/*********************
* INCLUDES
*********************/
#include "lv_app.h"
#include "../lv_app.h"
#if LV_APP_ENABLE != 0
/*********************
@@ -29,6 +29,7 @@ typedef enum
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_app_kb_init(void);
void lv_app_kb_open(lv_obj_t * ta, lv_app_kb_mode_t mode, void (*close)(lv_obj_t *), void (*ok)(lv_obj_t *));
void lv_app_kb_close(bool ok);

View File

@@ -0,0 +1,135 @@
/**
* @file lv_app_notice.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_app_notice.h"
#if LV_APP_ENABLE != 0
#include "lvgl/lv_objx/lv_rect.h"
#include "lvgl/lv_objx/lv_label.h"
#include "lvgl/lv_misc/anim.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* STATIC VARIABLES
**********************/
static lv_obj_t * notice_h;
static lv_rects_t notice_rects;
static lv_labels_t notice_labels;
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
void lv_app_notice_init(void)
{
lv_app_style_t * app_style = lv_app_get_style();
memcpy(&notice_rects, &app_style->menu_style, sizeof(lv_rects_t));
notice_rects.round = 5 * LV_DOWNSCALE;
notice_rects.bcolor = COLOR_WHITE;
notice_rects.bwidth = 1 * LV_DOWNSCALE;
notice_rects.bopa = 90;
notice_rects.light = 5 * LV_DOWNSCALE;
memcpy(&notice_labels, &app_style->menu_btn_label_style, sizeof(lv_labels_t));
notice_labels.mid = 0;
notice_labels.font = LV_APP_FONT_MEDIUM;
notice_h = lv_rect_create(lv_scr_act(), NULL);
lv_obj_set_size(notice_h, LV_HOR_RES, LV_VER_RES - app_style->menu_h);
lv_obj_set_y(notice_h, app_style->menu_h);
lv_obj_set_click(notice_h, false);
lv_obj_set_style(notice_h, lv_rects_get(LV_RECTS_TRANSP, NULL));
lv_rect_set_layout(notice_h, LV_RECT_LAYOUT_COL_R);
}
void lv_app_notice_add(const char * txt)
{
lv_app_style_t * app_style = lv_app_get_style();
lv_obj_t * n;
n = lv_rect_create(notice_h, NULL);
lv_rect_set_fit(n, true, true);
lv_obj_set_style(n, &notice_rects);
lv_obj_set_opa(n, app_style->menu_opa);
lv_obj_t * l;
l = lv_label_create(n, NULL);
lv_label_set_text(l, txt);
lv_obj_set_style(l, &notice_labels);
lv_obj_set_parent(notice_h, lv_scr_act());
lv_rect_set_fit(n, false, false);
#if LV_APP_EFFECT_ANIM != 0 && LV_APP_ANIM_NOTICE != 0
anim_t a;
a.var = n;
a.path = anim_get_path(ANIM_PATH_LIN);
a.time = LV_APP_ANIM_NOTICE;
a.act_time = - LV_APP_NOTICE_SHOW_TIME;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
a.repeat_pause = 0;
a.end_cb = NULL;
#if LV_APP_EFFECT_OPA_ANIM != 0
a.fp = (anim_fp_t) lv_obj_set_opar;
a.start = lv_obj_get_opa(n);
a.end = OPA_TRANSP;
anim_create(&a);
/*Restore the label opacity because the opar anim changes it*/
lv_obj_set_opa(l, OPA_COVER);
a.act_time = - LV_APP_NOTICE_SHOW_TIME - LV_APP_ANIM_NOTICE; /*Do the next animation after the opa animation*/
#endif
a.fp = (anim_fp_t) lv_obj_set_height;
a.start = lv_obj_get_height(n);
a.end = 0;
a.end_cb = lv_obj_del;
anim_create(&a);
#else
anim_t a;
a.var = n;
a.path = anim_get_path(ANIM_PATH_STEP);
a.time = LV_APP_ANIM_NOTICE;
a.act_time = - LV_APP_NOTICE_SHOW_TIME + LV_APP_ANIM_NOTICE;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
a.repeat_pause = 0;
a.fp = (anim_fp_t) lv_obj_set_height;
a.start = lv_obj_get_height(n);
a.end = lv_obj_get_height(n);
a.end_cb = lv_obj_del;
anim_create(&a);
#endif
}
/**********************
* STATIC FUNCTIONS
**********************/
#endif

View File

@@ -0,0 +1,35 @@
/**
* @file lv_app_notice.h
*
*/
#ifndef LV_APP_NOTICE_H
#define LV_APP_NOTICE_H
/*********************
* INCLUDES
*********************/
#include "../lv_app.h"
#if LV_APP_ENABLE != 0
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_app_notice_init(void);
void lv_app_notice_add(const char * txt);
/**********************
* MACROS
**********************/
#endif /*LV_APP_NOTICE_H*/
#endif