lvgl-v7/Origin__V0.3_LVGL7/UART/SimplUART/APP/BoardCfg.c

53 lines
1.5 KiB
C

#include "BoardCfg.h"
static void btn_event_cb(lv_obj_t *btn, lv_event_t event)
{
if (event == LV_EVENT_CLICKED)
{
static uint8_t cnt = 0;
cnt++;
/*Get the first child of the button which is the label and change its text*/
lv_obj_t *label = lv_obj_get_child(btn, NULL);
lv_label_set_text_fmt(label, "Button: %d", cnt);
}
}
void lvgl_first_demo_start(void)
{
lv_obj_t *btn = lv_btn_create(lv_scr_act(), NULL); /*Add a button the current screen*/
lv_obj_set_pos(btn, 60, 60); /*Set its position*/
lv_obj_set_size(btn, 120, 50); /*Set its size*/
lv_obj_set_event_cb(btn, btn_event_cb); /*Assign a callback to the button*/
lv_obj_t *label = lv_label_create(btn, NULL); /*Add a label to the button*/
lv_label_set_text(label, "AAAAA"); /*Set the labels text*/
lv_obj_t *label1 = lv_label_create(lv_scr_act(), NULL);
lv_label_set_text(label1, "Hello world!");
lv_obj_align(label1, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_align(btn, label1, LV_ALIGN_OUT_TOP_MID, 0, -10);
}
/**
* @brief 系统初始化
*
*/
void BoardInit(void)
{
#if (SPI_FLASH)
SPI_FlashInit();
#endif
#if (LCD_RGB)
RGBLCDInit();
MemoryInit();
#endif
#if (LVGL_V7)
extern void lv_init();
lv_init();
extern void lv_port_disp_init();
lv_port_disp_init();
lvgl_first_demo_start();
#endif
GPIO_Init(GPIOB, PIN12, 1, 0, 0);
GPIO_SetBit(GPIOB, PIN12);
extern void XPY2046Init();
XPY2046Init();
}