Beispiel #1
0
static void sw_init(void)
{
#if USE_LV_SW != 0
    static lv_style_t sw_bg, sw_indic, sw_knob_off, sw_knob_on;
    lv_style_copy(&sw_bg, theme.slider.bg);
    sw_bg.body.radius = LV_RADIUS_CIRCLE;

    lv_style_copy(&sw_indic, theme.slider.bg);
    sw_indic.body.radius = LV_RADIUS_CIRCLE;

    lv_style_copy(&sw_knob_on, theme.slider.knob);
    sw_knob_on.body.shadow.width = 4;
    sw_knob_on.body.shadow.type = LV_SHADOW_BOTTOM;
    sw_knob_on.body.shadow.color = DEF_SHADOW_COLOR;


    lv_style_copy(&sw_knob_off, &sw_knob_on);
    sw_knob_off.body.main_color = LV_COLOR_HEX(0xfafafa);
    sw_knob_off.body.grad_color = sw_knob_off.body.main_color;
    sw_knob_off.body.border.width = 1;
    sw_knob_off.body.border.color = LV_COLOR_HEX3(0x999);
    sw_knob_off.body.border.opa = LV_OPA_COVER;

    theme.sw.bg = &sw_bg;
    theme.sw.indic = &sw_indic;
    theme.sw.knob_off = &sw_knob_off;
    theme.sw.knob_on = &sw_knob_on;
#endif
}
Beispiel #2
0
static void cb_init(void)
{
#if USE_LV_CB != 0
    static lv_style_t rel, pr, tgl_rel, tgl_pr, ina;
    lv_style_copy(&rel,theme.panel);
    rel.body.shadow.type = LV_SHADOW_BOTTOM;
    rel.body.shadow.width = 2;

    lv_style_copy(&pr, &rel);
    pr.body.main_color = LV_COLOR_HEX3(0xccc);
    pr.body.grad_color = pr.body.main_color;
    pr.body.shadow.width = 0;

    lv_style_copy(&tgl_rel, &rel);
    tgl_rel.body.main_color = lv_color_hsv_to_rgb(_hue, 75, 85);
    tgl_rel.body.grad_color = tgl_rel.body.main_color;
    tgl_rel.body.shadow.type = LV_SHADOW_FULL;
    tgl_rel.body.shadow.width = 0;

    lv_style_copy(&tgl_pr, &tgl_rel);
    tgl_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 75, 65);
    tgl_pr.body.grad_color = tgl_pr.body.main_color;
    tgl_pr.body.shadow.width = 0;

    lv_style_copy(&ina, theme.btn.ina);

    theme.cb.bg = &lv_style_transp;
    theme.cb.box.rel = &rel;
    theme.cb.box.pr = ≺
    theme.cb.box.tgl_rel = &tgl_rel;
    theme.cb.box.tgl_pr = &tgl_pr;
    theme.cb.box.ina = &ina;
#endif
}
Beispiel #3
0
/**
 * Create a demo application
 */
void demo_create(void)
{
#if LV_DEMO_WALLPAPER
    lv_obj_t *wp = lv_img_create(lv_scr_act(), NULL);
    lv_img_set_src(wp, &img_bubble_pattern);
    lv_obj_set_width(wp, LV_HOR_RES * 4);
    lv_obj_set_protect(wp, LV_PROTECT_POS);
#endif

    static lv_style_t style_tv_btn_bg;
    lv_style_copy(&style_tv_btn_bg, &lv_style_plain);
    style_tv_btn_bg.body.main_color = LV_COLOR_HEX(0x487fb7);
    style_tv_btn_bg.body.grad_color = LV_COLOR_HEX(0x487fb7);
    style_tv_btn_bg.body.padding.ver = 0;

    static lv_style_t style_tv_btn_rel;
    lv_style_copy(&style_tv_btn_rel, &lv_style_btn_rel);
    style_tv_btn_rel.body.empty = 1;
    style_tv_btn_rel.body.border.width = 0;

    static lv_style_t style_tv_btn_pr;
    lv_style_copy(&style_tv_btn_pr, &lv_style_btn_pr);
    style_tv_btn_pr.body.radius = 0;
    style_tv_btn_pr.body.opa = LV_OPA_50;
    style_tv_btn_pr.body.main_color = LV_COLOR_WHITE;
    style_tv_btn_pr.body.grad_color = LV_COLOR_WHITE;
    style_tv_btn_pr.body.border.width = 0;
    style_tv_btn_pr.text.color = LV_COLOR_GRAY;

    lv_obj_t *tv = lv_tabview_create(lv_scr_act(), NULL);

#if LV_DEMO_WALLPAPER
    lv_obj_set_parent(wp, ((lv_tabview_ext_t *) tv->ext_attr)->content);
    lv_obj_set_pos(wp, 0, -5);
#endif

    lv_obj_t *tab1 = lv_tabview_add_tab(tv, "Write");
    lv_obj_t *tab2 = lv_tabview_add_tab(tv, "List");
    lv_obj_t *tab3 = lv_tabview_add_tab(tv, "Chart");

#if LV_DEMO_WALLPAPER == 0
    /*Blue bg instead of wallpaper*/
    lv_tabview_set_style(tv, LV_TABVIEW_STYLE_BG, &style_tv_btn_bg);
#endif
    lv_tabview_set_style(tv, LV_TABVIEW_STYLE_BTN_BG, &style_tv_btn_bg);
    lv_tabview_set_style(tv, LV_TABVIEW_STYLE_INDIC, &lv_style_plain);
    lv_tabview_set_style(tv, LV_TABVIEW_STYLE_BTN_REL, &style_tv_btn_rel);
    lv_tabview_set_style(tv, LV_TABVIEW_STYLE_BTN_PR, &style_tv_btn_pr);
    lv_tabview_set_style(tv, LV_TABVIEW_STYLE_BTN_TGL_REL, &style_tv_btn_rel);
    lv_tabview_set_style(tv, LV_TABVIEW_STYLE_BTN_TGL_PR, &style_tv_btn_pr);

    write_create(tab1);
    list_create(tab2);
    chart_create(tab3);

#if LV_DEMO_SLIDE_SHOW
	lv_task_create(tab_switcher, 3000, LV_TASK_PRIO_MID, tv);
#endif
}
Beispiel #4
0
/**
 * Create message boxes to test their functionalities
 */
void lv_test_mbox_1(void)
{
    /* Default object */
    lv_obj_t *mbox1 = lv_mbox_create(lv_scr_act(), NULL);
    lv_obj_set_pos(mbox1, 10, 10);

    /*Add buttons and modify text*/
    static const char * btns2[] = {"Ok", "Cancel", ""};
    lv_obj_t *mbox2 = lv_mbox_create(lv_scr_act(), NULL);
    lv_mbox_add_btns(mbox2, btns2, NULL);
    lv_mbox_set_text(mbox2, "Message");
    lv_obj_set_width(mbox2, LV_HOR_RES / 2);
    lv_obj_align(mbox2, mbox1, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);

    /*Add styles*/
    static lv_style_t bg;
    static lv_style_t btn_bg;
    lv_style_copy(&bg, &lv_style_pretty);
    lv_style_copy(&btn_bg, &lv_style_pretty);
    bg.body.padding.hor = 20;
    bg.body.padding.ver = 20;
    bg.body.padding.inner = 20;
    bg.body.main_color = LV_COLOR_BLACK;
    bg.body.grad_color = LV_COLOR_MARRON;
    bg.text.color = LV_COLOR_WHITE;

    btn_bg.body.padding.hor = 10;
    btn_bg.body.padding.ver = 5;
    btn_bg.body.padding.inner = 40;
    btn_bg.body.empty = 1;
    btn_bg.body.border.color = LV_COLOR_WHITE;
    btn_bg.text.color = LV_COLOR_WHITE;

    static lv_style_t btn_rel;
    lv_style_copy(&btn_rel, &lv_style_btn_rel);
    btn_rel.body.empty = 1;
    btn_rel.body.border.color = LV_COLOR_WHITE;

    lv_obj_t *mbox3 = lv_mbox_create(lv_scr_act(), mbox2);
    lv_mbox_set_style(mbox3, LV_MBOX_STYLE_BTN_REL, &btn_rel);
    lv_mbox_set_style(mbox3, LV_MBOX_STYLE_BTN_BG,  &btn_bg);
    lv_mbox_set_style(mbox3, LV_MBOX_STYLE_BG, &bg);
    lv_obj_align(mbox3, mbox1, LV_ALIGN_OUT_RIGHT_TOP, 10, 0);
    lv_mbox_set_action(mbox3, mbox_action);

    /*Copy with styles and set button width*/
    lv_obj_t *mbox4 = lv_mbox_create(lv_scr_act(), mbox3);
    lv_mbox_set_text(mbox4, "A quite long message text which is\n"
                            "manually broken into multiple lines");

    static const char * btns3[] = {"Ok", "Cancel", "Third", ""};
    lv_mbox_add_btns(mbox4, btns3, mbox_action);
    lv_obj_align(mbox4, mbox3, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
}
Beispiel #5
0
/**
 * Create lists to test their functionalities
 */
void lv_test_list_1(void)
{
    /* Default object. It will be an empty list*/
    list1 = lv_list_create(lv_scr_act(), NULL);
    lv_obj_set_pos(list1, 10, 10);

    list2 = lv_list_create(lv_scr_act(), NULL);
    lv_obj_align(list2, list1, LV_ALIGN_OUT_RIGHT_TOP, 20, 0);
    lv_list_add(list2, SYMBOL_FILE, "File", NULL);
    lv_list_add(list2, SYMBOL_DIRECTORY, "Directory", NULL);
    lv_list_add(list2, &img_flower_icon, "Image icon", NULL);
    lv_obj_set_width(list2, 100);

    list3 = lv_list_create(lv_scr_act(), list2);
    lv_obj_align(list3, list2, LV_ALIGN_OUT_RIGHT_TOP, 20, 0);
    lv_list_add(list3, NULL, "No icon", NULL);
    lv_list_add(list3, SYMBOL_CLOSE, "", NULL);
    lv_list_add(list3, SYMBOL_UP, "Up", NULL);
    lv_list_add(list3, SYMBOL_DOWN, "Down", NULL);

    static lv_style_t sb;
    static lv_style_t bg;
    lv_style_copy(&sb, &lv_style_pretty_color);
    lv_style_copy(&bg, &lv_style_pretty_color);
    sb.body.padding.hor = -10;
    sb.body.padding.inner = 10;

    bg.body.padding.hor = 20;

    list4 = lv_list_create(lv_scr_act(), list3);
    lv_list_set_style(list4, LV_LIST_STYLE_BG, &bg);
    lv_list_set_style(list4, LV_LIST_STYLE_SB, &sb);
    lv_obj_align(list4, list3, LV_ALIGN_OUT_RIGHT_TOP, 20, 0);
    lv_obj_set_width(list4, 200);

    /*Add list up/down buttons*/
    lv_obj_t *btn_up = lv_btn_create(lv_scr_act(), NULL);
    lv_obj_align(btn_up, list1, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
    lv_btn_set_action(btn_up, LV_BTN_ACTION_CLICK, list_move);
    lv_obj_set_free_num(btn_up, 0);
    lv_obj_t *label = lv_label_create(btn_up, NULL);
    lv_label_set_text(label, SYMBOL_UP);

    lv_obj_t *btn_down = lv_btn_create(lv_scr_act(), btn_up);
    lv_obj_align(btn_down, btn_up, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
    lv_obj_set_free_num(btn_down, 1);
    label = lv_label_create(btn_down, NULL);
    lv_label_set_text(label, SYMBOL_DOWN);

}
Beispiel #6
0
/**
 * Draw the needles of a gauge
 * @param gauge pointer to gauge object
 * @param mask mask of drawing
 */
static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * mask)
{
    lv_style_t style_needle;
    lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
    lv_style_t * style = lv_gauge_get_style(gauge);

    lv_coord_t r = lv_obj_get_width(gauge) / 2 - style->body.padding.hor;
    lv_coord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->coords.x1;
    lv_coord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->coords.y1;
    uint16_t angle = lv_lmeter_get_scale_angle(gauge);
    int16_t angle_ofs = 90 + (360 - angle) / 2;
    int16_t min = lv_gauge_get_min_value(gauge);
    int16_t max = lv_gauge_get_max_value(gauge);
    lv_point_t p_mid;
    lv_point_t p_end;
    uint8_t i;

    lv_style_copy(&style_needle, style);

    p_mid.x = x_ofs;
    p_mid.y = y_ofs;
    for(i = 0; i < ext->needle_count; i++) {
        /*Calculate the end point of a needle*/
        int16_t needle_angle = (ext->values[i] - min) * angle / (max - min) + angle_ofs;
        p_end.y = (lv_trigo_sin(needle_angle) * r) / LV_TRIGO_SIN_MAX + y_ofs;
        p_end.x = (lv_trigo_sin(needle_angle + 90) * r) / LV_TRIGO_SIN_MAX + x_ofs;

        /*Draw the needle with the corresponding color*/
        if(ext->needle_colors == NULL) style_needle.line.color = LV_GAUGE_DEF_NEEDLE_COLOR;
        else style_needle.line.color = ext->needle_colors[i];

        lv_draw_line(&p_mid, &p_end, mask, &style_needle);
    }

    /*Draw the needle middle area*/
    lv_style_t style_neddle_mid;
    lv_style_copy(&style_neddle_mid, &lv_style_plain);
    style_neddle_mid.body.main_color = style->body.border.color;
    style_neddle_mid.body.grad_color = style->body.border.color;
    style_neddle_mid.body.radius = LV_RADIUS_CIRCLE;

    lv_area_t nm_cord;
    nm_cord.x1 = x_ofs - style->body.padding.ver;
    nm_cord.y1 = y_ofs - style->body.padding.ver;
    nm_cord.x2 = x_ofs + style->body.padding.ver;
    nm_cord.y2 = y_ofs + style->body.padding.ver;

    lv_draw_rect(&nm_cord, mask, &style_neddle_mid);
}
Beispiel #7
0
static void list_create(lv_obj_t *parent)
{
    lv_page_set_style(parent, LV_PAGE_STYLE_BG, &lv_style_transp_fit);
    lv_page_set_style(parent, LV_PAGE_STYLE_SCRL, &lv_style_transp_fit);

    lv_page_set_scrl_fit(parent, false, false);
    lv_page_set_scrl_height(parent, lv_obj_get_height(parent));
    lv_page_set_sb_mode(parent, LV_SB_MODE_OFF);

    /*Create styles for the buttons*/
    static lv_style_t style_btn_rel;
    static lv_style_t style_btn_pr;
    lv_style_copy(&style_btn_rel, &lv_style_btn_rel);
    style_btn_rel.body.main_color = LV_COLOR_HEX3(0x333);
    style_btn_rel.body.grad_color = LV_COLOR_BLACK;
    style_btn_rel.body.border.color = LV_COLOR_SILVER;
    style_btn_rel.body.border.width = 1;
    style_btn_rel.body.border.opa = LV_OPA_50;
    style_btn_rel.body.radius = 0;

    lv_style_copy(&style_btn_pr, &style_btn_rel);
    style_btn_pr.body.main_color = LV_COLOR_MAKE(0x55, 0x96, 0xd8);
    style_btn_pr.body.grad_color = LV_COLOR_MAKE(0x37, 0x62, 0x90);
    style_btn_pr.text.color = LV_COLOR_MAKE(0xbb, 0xd5, 0xf1);

    lv_obj_t *list = lv_list_create(parent, NULL);
    lv_obj_set_height(list, 2 * lv_obj_get_height(parent) / 3);
    lv_list_set_style(list, LV_LIST_STYLE_BG, &lv_style_transp_tight);
    lv_list_set_style(list, LV_LIST_STYLE_SCRL, &lv_style_transp_tight);
    lv_list_set_style(list, LV_LIST_STYLE_BTN_REL, &style_btn_rel);
    lv_list_set_style(list, LV_LIST_STYLE_BTN_PR, &style_btn_pr);
    lv_obj_align(list, NULL, LV_ALIGN_IN_TOP_MID, 0, LV_DPI / 4);

    lv_list_add(list, SYMBOL_FILE, "New", list_btn_action);
    lv_list_add(list, SYMBOL_DIRECTORY, "Open", list_btn_action);
    lv_list_add(list, SYMBOL_TRASH, "Delete", list_btn_action);
    lv_list_add(list, SYMBOL_EDIT, "Edit", list_btn_action);
    lv_list_add(list, SYMBOL_SAVE, "Save", list_btn_action);
    lv_list_add(list, SYMBOL_WIFI, "WiFi", list_btn_action);
    lv_list_add(list, SYMBOL_GPS, "GPS", list_btn_action);

    lv_obj_t *mbox= lv_mbox_create(parent, NULL);
    lv_mbox_set_text(mbox, "Click a button to copy its text to the Text area ");
    lv_obj_set_width(mbox, LV_HOR_RES - LV_DPI);
    static const char * mbox_btns[] = {"Got it", ""};
    lv_mbox_add_btns(mbox, mbox_btns, NULL);    /*The default action is close*/
    lv_obj_align(mbox, parent, LV_ALIGN_IN_TOP_MID, 0, LV_DPI / 2);
}
Beispiel #8
0
/**
 * Open a terminal
 * @return pointer to the terminal window
 */
lv_obj_t * terminal_create(void)
{
    static lv_style_t style_bg;
    lv_style_copy(&style_bg, &lv_style_pretty);
    style_bg.body.main_color = LV_COLOR_MAKE(0x30, 0x30, 0x30);
    style_bg.body.grad_color = LV_COLOR_MAKE(0x30, 0x30, 0x30);
    style_bg.body.border.color = LV_COLOR_WHITE;
    style_bg.text.color = LV_COLOR_MAKE(0xE0, 0xE0, 0xE0);

    win = lv_win_create(lv_scr_act(), NULL);
    lv_win_set_style(win, LV_WIN_STYLE_BG, &style_bg);
    lv_obj_set_size(win, TERMINAL_WIDTH, TERMINAL_HEIGHT);
    lv_win_set_sb_mode(win, LV_SB_MODE_AUTO);
    lv_win_add_btn(win, SYMBOL_CLOSE, win_close_action);

    /*Make the window's content responsive*/
    lv_win_set_layout(win, LV_LAYOUT_PRETTY);

    /*Create a label for the text of the terminal*/
    label = lv_label_create(win, NULL);
    lv_label_set_long_mode(label, LV_LABEL_LONG_BREAK);
    lv_obj_set_width(label, lv_win_get_width(win));
    lv_label_set_static_text(label, txt_log);               /*Use the text array directly*/

    /*Create a clear button*/
    clr_btn = lv_btn_create(win, NULL);
    lv_cont_set_fit(clr_btn, true, true);
    lv_btn_set_action(clr_btn, LV_BTN_ACTION_CLICK, clr_click_action);
    lv_obj_t * btn_label = lv_label_create(clr_btn, NULL);
    lv_label_set_text(btn_label, "Clear");

    return win;
}
/**
 * Create object to see how they change from the anti aliasing
 * Modify LV_ANTIALIAS and LV_FONT_ANTIALIAS to see what is changing
 */
void lv_tutorial_antialiasing(void)
{
    lv_obj_t *label;

    static lv_style_t style1;
    lv_style_copy(&style1, &lv_style_btn_rel);
    style1.body.radius = 20;
    style1.body.border.width = 8;

    lv_obj_t *btn1;
    btn1 = lv_btn_create(lv_scr_act(), NULL);
    lv_obj_set_pos(btn1, 10, 10);
    lv_obj_set_size(btn1, 160, 80);
    lv_btn_set_style(btn1, LV_BTN_STYLE_REL, &style1);

    label = lv_label_create(btn1, NULL);
    lv_label_set_text(label, "Button");


    lv_img_create_file("red_flower", img_red_flower);       /*Create a file in the RAM FS*/

    /*Crate an image which is NOT automatically upscaled to compensate the anti aliasing*/
    lv_obj_t *img_normal = lv_img_create(lv_scr_act(), NULL);
    lv_img_set_file(img_normal, "U:/red_flower");
    lv_img_set_upscale(img_normal, false);
    lv_obj_align(img_normal, btn1, LV_ALIGN_OUT_RIGHT_TOP, 10, 0);

    /*Crate an image which is automatically upscaled to compensate the anti aliasing*/
    lv_obj_t *img_scaled = lv_img_create(lv_scr_act(), img_normal);  /*Crate an image object*/
    lv_img_set_upscale(img_scaled, true);
    lv_obj_align(img_scaled, img_normal, LV_ALIGN_OUT_RIGHT_TOP, 10, 0);


}
Beispiel #10
0
static void write_create(lv_obj_t *parent)
{
    lv_page_set_style(parent, LV_PAGE_STYLE_BG, &lv_style_transp_fit);
    lv_page_set_style(parent, LV_PAGE_STYLE_SCRL, &lv_style_transp_fit);

    lv_page_set_sb_mode(parent, LV_SB_MODE_OFF);

    static lv_style_t style_ta;
    lv_style_copy(&style_ta, &lv_style_pretty);
    style_ta.body.opa = LV_OPA_30;
    style_ta.body.radius = 0;
    style_ta.text.color = LV_COLOR_HEX3(0x222);

    ta = lv_ta_create(parent, NULL);
    lv_obj_set_size(ta, lv_page_get_scrl_width(parent), lv_obj_get_height(parent) / 2);
    lv_ta_set_style(ta, LV_TA_STYLE_BG, &style_ta);
    lv_ta_set_text(ta, "");
    lv_page_set_rel_action(ta, keyboard_open_close);

    lv_style_copy(&style_kb, &lv_style_plain);
    style_kb.body.opa = LV_OPA_70;
    style_kb.body.main_color = LV_COLOR_HEX3(0x333);
    style_kb.body.grad_color = LV_COLOR_HEX3(0x333);
    style_kb.body.padding.hor = 0;
    style_kb.body.padding.ver = 0;
    style_kb.body.padding.inner = 0;

    lv_style_copy(&style_kb_rel, &lv_style_plain);
    style_kb_rel.body.empty = 1;
    style_kb_rel.body.radius = 0;
    style_kb_rel.body.border.width = 1;
    style_kb_rel.body.border.color = LV_COLOR_SILVER;
    style_kb_rel.body.border.opa = LV_OPA_50;
    style_kb_rel.body.main_color = LV_COLOR_HEX3(0x333);    /*Recommended if LV_VDB_SIZE == 0 and bpp > 1 fonts are used*/
    style_kb_rel.body.grad_color = LV_COLOR_HEX3(0x333);
    style_kb_rel.text.color = LV_COLOR_WHITE;

    lv_style_copy(&style_kb_pr, &lv_style_plain);
    style_kb_pr.body.radius = 0;
    style_kb_pr.body.opa = LV_OPA_50;
    style_kb_pr.body.main_color = LV_COLOR_WHITE;
    style_kb_pr.body.grad_color = LV_COLOR_WHITE;
    style_kb_pr.body.border.width = 1;
    style_kb_pr.body.border.color = LV_COLOR_SILVER;

    keyboard_open_close(ta);
}
Beispiel #11
0
static void btn_init(void)
{
#if USE_LV_BTN != 0
    static lv_style_t rel, pr, tgl_rel, tgl_pr, ina;

    lv_style_copy(&rel, &def);
    rel.body.main_color = lv_color_hsv_to_rgb(_hue, 90, 70);
    rel.body.grad_color = rel.body.main_color;
    rel.body.radius = DEF_RADIUS;
    rel.body.padding.hor = LV_DPI / 6;
    rel.body.padding.ver = LV_DPI / 8;
    rel.body.padding.inner = LV_DPI / 10;
    rel.body.shadow.color = DEF_SHADOW_COLOR;
    rel.body.shadow.type = LV_SHADOW_BOTTOM;
    rel.body.shadow.width = 6;
    rel.text.color = lv_color_hsv_to_rgb(_hue, 5, 95);


    lv_style_copy(&pr, &rel);
    pr.body.main_color = lv_color_hsv_to_rgb(_hue, 90, 60);
    pr.body.grad_color = pr.body.main_color;
    pr.body.shadow.width = 4;

    lv_style_copy(&tgl_rel, &rel);
    tgl_rel.body.main_color = lv_color_hsv_to_rgb(_hue, 95, 50);
    tgl_rel.body.grad_color = tgl_rel.body.main_color;
    tgl_rel.body.shadow.width = 4;

    lv_style_copy(&tgl_pr, &tgl_rel);
    tgl_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 95, 40);
    tgl_pr.body.grad_color = tgl_pr.body.main_color;
    tgl_pr.body.shadow.width = 2;

    lv_style_copy(&ina, &rel);
    ina.body.main_color = LV_COLOR_HEX3(0xccc);
    ina.body.grad_color = ina.body.main_color;
    ina.body.shadow.width = 0;
    ina.text.color = lv_color_hsv_to_rgb(_hue, 95, 5);

    theme.btn.rel = &rel;
    theme.btn.pr = &pr;
    theme.btn.tgl_rel = &tgl_rel;
    theme.btn.tgl_pr =  &tgl_pr;
    theme.btn.ina =  &ina;
#endif
}
Beispiel #12
0
static void img_init(void)
{
#if USE_LV_IMG != 0
    static lv_style_t img_light, img_dark;
    lv_style_copy(&img_light, &def);
    img_light.image.color = lv_color_hsv_to_rgb(_hue, 15, 85);
    img_light.image.intense = LV_OPA_80;

    lv_style_copy(&img_dark, &def);
    img_light.image.color = lv_color_hsv_to_rgb(_hue, 85, 65);
    img_light.image.intense = LV_OPA_80;


    theme.img.light = &def;
    theme.img.dark = &def;
#endif
}
Beispiel #13
0
static void basic_init(void)
{
    lv_style_copy(&def, &lv_style_pretty);  /*Initialize the default style*/

    lv_style_copy(&sb, &lv_style_pretty_color);
    sb.body.grad_color = sb.body.main_color;
    sb.body.padding.hor = sb.body.padding.hor / 2;      /*Make closer to the edges*/
    sb.body.padding.ver = sb.body.padding.ver / 2;

    lv_style_copy(&plain_bordered, &lv_style_plain);
    plain_bordered.body.border.width = 2;
    plain_bordered.body.border.color = LV_COLOR_HEX3(0xbbb);

    theme.bg = &lv_style_plain;
    theme.panel = &lv_style_pretty;

}
Beispiel #14
0
static void label_init(void)
{
#if USE_LV_LABEL != 0

    lv_style_copy(&label_prim, &lv_style_plain);
    lv_style_copy(&label_sec, &lv_style_plain);
    lv_style_copy(&label_hint, &lv_style_plain);

    label_prim.text.color = LV_COLOR_HEX3(0x111);
    label_sec.text.color = LV_COLOR_HEX3(0x888);
    label_hint.text.color = LV_COLOR_HEX3(0xaaa);


    theme.label.prim = &label_prim;
    theme.label.sec = &label_sec;
    theme.label.hint = &label_hint;
#endif
}
Beispiel #15
0
static void basic_init(void)
{
    lv_style_copy(&def, &lv_style_pretty);  /*Initialize the default style*/
    def.text.font = _font;

    theme.bg = &def;
    theme.panel = &def;

}
Beispiel #16
0
static void mbox_init(void)
{
#if USE_LV_MBOX
    static lv_style_t pr, rel;

    lv_style_copy(&rel, &lv_style_transp);
    rel.glass = 0;
    rel.text.font = _font;
    rel.text.color = lv_color_hsv_to_rgb(_hue, 85, 75);

    lv_style_copy(&pr, theme.btnm.btn.pr);
    pr.text.color = lv_color_hsv_to_rgb(_hue, 85, 60);

    theme.mbox.bg = theme.panel;
    theme.mbox.btn.bg = &lv_style_transp;
    theme.mbox.btn.rel = &rel;
    theme.mbox.btn.pr = &pr;
#endif
}
Beispiel #17
0
static void label_init(void)
{
#if USE_LV_LABEL != 0
    static lv_style_t prim, sec, hint;

    lv_style_copy(&prim, &def);
    prim.text.font = _font;
    prim.text.color = lv_color_hsv_to_rgb(_hue, 80, 10);

    lv_style_copy(&sec, &prim);
    sec.text.color = lv_color_hsv_to_rgb(_hue, 80, 75);

    lv_style_copy(&hint, &prim);
    hint.text.color = lv_color_hsv_to_rgb(_hue, 40, 90);

    theme.label.prim = &prim;
    theme.label.sec = &sec;
    theme.label.hint = &hint;
#endif
}
Beispiel #18
0
static void roller_init(void)
{
#if USE_LV_ROLLER != 0
    static lv_style_t roller_bg, roller_sel;

    lv_style_copy(&roller_bg, &lv_style_transp);
    roller_bg.body.padding.hor = LV_DPI / 6;
    roller_bg.body.padding.ver = LV_DPI / 6;
    roller_bg.text.line_space = LV_DPI / 8;
    roller_bg.text.font = _font;
    roller_bg.glass = 0;

    lv_style_copy(&roller_sel, &roller_bg);
    roller_sel.text.color = lv_color_hsv_to_rgb(_hue, 90, 70);


    theme.roller.bg = &roller_bg;
    theme.roller.sel = &roller_sel;
#endif
}
Beispiel #19
0
static void slider_init(void)
{
#if USE_LV_SLIDER != 0
    lv_style_copy(&slider_bg, &lv_style_pretty);
    slider_bg.body.padding.hor = LV_DPI / 20;
    slider_bg.body.padding.ver = LV_DPI / 20;

    theme.slider.bg = &slider_bg;
    theme.slider.indic = &lv_style_pretty_color;
    theme.slider.knob = &lv_style_pretty;
#endif
}
Beispiel #20
0
static void lmeter_init(void)
{
#if USE_LV_LMETER != 0

    lv_style_copy(&lmeter, &lv_style_pretty_color);
    lmeter.line.color = LV_COLOR_HEX3(0xddd);
    lmeter.line.width = 2;
    lmeter.body.main_color = lv_color_mix(lmeter.body.main_color, LV_COLOR_WHITE, LV_OPA_50);
    lmeter.body.grad_color = lv_color_mix(lmeter.body.grad_color, LV_COLOR_BLACK, LV_OPA_50);

    theme.lmeter = &lmeter;
#endif
}
Beispiel #21
0
static void sw_init(void)
{
#if USE_LV_SW != 0
    lv_style_copy(&sw_bg, &lv_style_pretty);
    sw_bg.body.padding.hor = 3;
    sw_bg.body.padding.ver = 3;

    theme.sw.bg = &sw_bg;
    theme.sw.indic = &lv_style_pretty_color;
    theme.sw.knob_off = &lv_style_pretty;
    theme.sw.knob_on = &lv_style_pretty;
#endif
}
Beispiel #22
0
/**
 * Handle the drawing related tasks of the rollers
 * @param roller pointer to an object
 * @param mask the object will be drawn only in this area
 * @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
 *                                  (return 'true' if yes)
 *             LV_DESIGN_DRAW: draw the object (always return 'true')
 *             LV_DESIGN_DRAW_POST: drawing after every children are drawn
 * @param return true/false, depends on 'mode'
 */
static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_design_mode_t mode)
{
    /*Return false if the object is not covers the mask_p area*/
    if(mode == LV_DESIGN_COVER_CHK) {
    	return false;
    }
    /*Draw the object*/
    else if(mode == LV_DESIGN_DRAW_MAIN) {
        draw_bg(roller, mask);

        lv_style_t *style = lv_roller_get_style(roller, LV_ROLLER_STYLE_BG);
        const lv_font_t * font = style->text.font;
        lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
        lv_coord_t font_h = lv_font_get_height_scale(font);
        lv_area_t rect_area;
        rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - style->text.line_space / 2;
        rect_area.y2 = rect_area.y1 + font_h + style->text.line_space;
        rect_area.x1 = roller->coords.x1;
        rect_area.x2 = roller->coords.x2;

        lv_draw_rect(&rect_area, mask, ext->ddlist.sel_style);
    }
    /*Post draw when the children are drawn*/
    else if(mode == LV_DESIGN_DRAW_POST) {
        lv_style_t *style = lv_roller_get_style(roller, LV_ROLLER_STYLE_BG);
        lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
        const lv_font_t * font = style->text.font;
        lv_coord_t font_h = lv_font_get_height_scale(font);

        /*Redraw the text on the selected area with a different color*/
        lv_area_t rect_area;
        rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - style->text.line_space / 2;
        rect_area.y2 = rect_area.y1 + font_h + style->text.line_space;
        rect_area.x1 = roller->coords.x1;
        rect_area.x2 = roller->coords.x2;
        lv_area_t mask_sel;
        bool area_ok;
        area_ok = lv_area_union(&mask_sel, mask, &rect_area);
        if(area_ok) {
            lv_style_t *sel_style = lv_roller_get_style(roller, LV_ROLLER_STYLE_SEL);
            lv_style_t new_style;
            lv_style_copy(&new_style, style);
            new_style.text.color = sel_style->text.color;
            new_style.text.opa = sel_style->text.opa;
            lv_draw_label(&ext->ddlist.label->coords, &mask_sel, &new_style,
                          lv_label_get_text(ext->ddlist.label), LV_TXT_FLAG_CENTER, NULL);
        }
    }

    return true;
}
Beispiel #23
0
static void lmeter_init(void)
{
#if USE_LV_LMETER != 0
    static lv_style_t lmeter;
    lv_style_copy(&lmeter, &def);
    lmeter.body.main_color = lv_color_hsv_to_rgb(_hue, 75, 90);
    lmeter.body.grad_color = lmeter.body.main_color;
    lmeter.body.padding.hor = LV_DPI / 10;                       /*Scale line length*/
    lmeter.line.color = LV_COLOR_HEX3(0x999);
    lmeter.line.width = 3;

    theme.lmeter = &lmeter;
#endif
}
Beispiel #24
0
static void bar_init(void)
{
#if USE_LV_BAR
    static lv_style_t bar_bg, bar_indic;

    lv_style_copy(&bar_bg, &def);
    bar_bg.body.main_color = lv_color_hsv_to_rgb(_hue, 15, 95);
    bar_bg.body.grad_color = bar_bg.body.main_color;
    bar_bg.body.radius = 3;
    bar_bg.body.border.width = 0;
    bar_bg.body.padding.hor = LV_DPI / 12;
    bar_bg.body.padding.ver = LV_DPI / 12;

    lv_style_copy(&bar_indic, &bar_bg);
    bar_indic.body.main_color = lv_color_hsv_to_rgb(_hue, 85, 70);
    bar_indic.body.grad_color = bar_indic.body.main_color;
    bar_indic.body.padding.hor = 0;
    bar_indic.body.padding.ver = 0;

    theme.bar.bg = &bar_bg;
    theme.bar.indic = &bar_indic;
#endif
}
Beispiel #25
0
static void ddlist_init(void)
{
#if USE_LV_DDLIST != 0
    static lv_style_t bg, sel;
    lv_style_copy(&bg, theme.panel);
    bg.body.padding.hor = LV_DPI / 6;
    bg.body.padding.ver = LV_DPI / 6;
    bg.text.line_space = LV_DPI / 8;


    lv_style_copy(&sel, &bg);
    sel.body.main_color = lv_color_hsv_to_rgb(_hue, 90, 70);
    sel.body.grad_color = sel.body.main_color;
    sel.body.border.width = 0;
    sel.body.shadow.width = 0;
    sel.text.color = lv_color_hsv_to_rgb(_hue, 5, 95);


    theme.ddlist.bg = &bg;
    theme.ddlist.sel = &sel;
    theme.ddlist.sb = &sb;
#endif
}
Beispiel #26
0
static void gauge_init(void)
{
#if USE_LV_GAUGE != 0
    static lv_style_t gauge;
    lv_style_copy(&gauge, &lmeter);
    gauge.line.color = lmeter.body.grad_color;
    gauge.line.width = 2;
    gauge.body.main_color = LV_COLOR_HEX3(0x888);
    gauge.body.grad_color = lmeter.body.main_color;
    gauge.text.color = LV_COLOR_HEX3(0x888);

    theme.gauge = &gauge;
#endif
}
Beispiel #27
0
static void basic_init(void)
{
    lv_style_copy(&def, &lv_style_plain);  /*Initialize the default style*/
    def.text.font = _font;
    def.body.radius = DEF_RADIUS;

    static lv_style_t bg, panel;
    lv_style_copy(&bg, &def);
    bg.body.main_color = LV_COLOR_HEX(0xf0f0f0);
    bg.body.grad_color = bg.body.main_color;
    bg.body.radius = 0;

    lv_style_copy(&panel, &def);
    panel.body.radius = DEF_RADIUS;
    panel.body.main_color = LV_COLOR_WHITE;
    panel.body.grad_color = LV_COLOR_WHITE;
    panel.body.border.width = 1;
    panel.body.border.color = LV_COLOR_HEX3(0xbbb);
    panel.body.border.opa = LV_OPA_COVER;
    panel.body.shadow.color = DEF_SHADOW_COLOR;
    panel.body.shadow.type = LV_SHADOW_BOTTOM;
    panel.body.shadow.width = 4;
    panel.body.padding.hor = LV_DPI / 8;
    panel.body.padding.ver = LV_DPI / 8;
    panel.body.padding.inner = LV_DPI / 12;
    panel.text.color = LV_COLOR_HEX3(0x333);

    lv_style_copy(&sb, &def);
    sb.body.main_color = LV_COLOR_BLACK;
    sb.body.grad_color = LV_COLOR_BLACK;
    sb.body.opa = LV_OPA_40;

    theme.bg = &bg;
    theme.panel = &panel;

}
Beispiel #28
0
static void win_init(void)
{
#if USE_LV_WIN != 0
    static lv_style_t header, pr;

    lv_style_copy(&header, &def);
    header.body.main_color = LV_COLOR_HEX3(0xccc);
    header.body.grad_color = header.body.main_color;
    header.body.radius = DEF_RADIUS;
    header.body.border.width = 1;
    header.body.border.color = LV_COLOR_HEX3(0xbbb);
    header.body.border.part = LV_BORDER_BOTTOM;
    header.body.border.opa = LV_OPA_COVER;
    header.body.padding.inner = 0;
    header.body.padding.hor = 0;
    header.body.padding.ver = 0;
    header.text.color = LV_COLOR_HEX3(0x333);

    lv_style_copy(&pr, &def);
    pr.body.main_color = LV_COLOR_HEX3(0xbbb);
    pr.body.grad_color = pr.body.main_color;
    pr.body.border.width = 0;
    pr.body.empty = 0;
    pr.body.radius = 0;
    pr.text.color = LV_COLOR_HEX3(0x111);


    theme.win.bg = theme.panel;
    theme.win.sb = &sb;
    theme.win.header = &header;
    theme.win.content.bg = &lv_style_transp;
    theme.win.content.scrl = &lv_style_transp;
    theme.win.btn.rel = &lv_style_transp;
    theme.win.btn.pr = &pr;
#endif
}
Beispiel #29
0
static void ssd1306_task(void *pvParameters)
{
    printf("%s: Started user interface task\n", __FUNCTION__);
    vTaskDelay(SECOND);
    ssd1306_set_whole_display_lighting(&dev, false);

    //Set a style for the obj
    lv_style_copy(&style, &lv_style_transp);
    style.text.font = &lv_font_dejavu_10;   /*Unicode and symbol fonts already assigned by the library*/
    style.text.color.full = 1;
    style.text.opa = 255;

    style.body.main_color.full = 0;
    style.body.grad_color.full = 0;
    style.body.shadow.color.full = 0;
    style.body.border.color.full = 0;
    style.body.empty = 1;

    style.image.color.full = 1;
    style.image.intense = 255;
    style.image.opa = 255;

    style.line.color.full = 1;
    style.line.opa = 255;
    style.line.width = 1;
    style.line.rounded = false;

    //Create main screen obj
    lv_obj_t * scr = lv_obj_create(NULL, NULL);
    lv_scr_load(scr);
    lv_obj_set_style(scr, &style);

    //Create a simple label
    label = lv_label_create(lv_scr_act(), NULL);
    lv_obj_set_style(label, &style);

    lv_obj_align(label, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 0, 0);
    lv_label_set_long_mode(label, LV_LABEL_LONG_BREAK);
    lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
    lv_label_set_text(label, "lvgl work with esp-open-rtos");
    lv_obj_set_width(label, LV_HOR_RES);

    while (1) {
        /*draw system call */
        lv_task_handler();
        vTaskDelay(1);
    }
}
Beispiel #30
0
static void led_init(void)
{
#if USE_LV_LED != 0
    static lv_style_t led;

    lv_style_copy(&led, &lv_style_pretty_color);
    led.body.shadow.width = LV_DPI / 10;
    led.body.radius = LV_RADIUS_CIRCLE;
    led.body.border.width = LV_DPI / 30;
    led.body.border.opa = LV_OPA_30;
    led.body.shadow.color = led.body.main_color;


    theme.led = &led;
#endif
}