cmcu为stm32h743IIt6
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

75 lines
2.0 KiB

/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2025-11-25 Administrator the first version
*/
#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>
#include "lvgl.h"
#include "lv_demo_widgets.h"
#define DBG_TAG "gui"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>
#define LCD_BL_PIN GET_PIN(D,12)
#define LCD_RST_PIN GET_PIN(D,11)
static void btn_led_on_evt_handler(lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
if (code == LV_EVENT_CLICKED)
{
rt_kprintf("LED ON\n");
//led_on();
}
}
static void btn_led_off_evt_handler(lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
if (code == LV_EVENT_CLICKED)
{
rt_kprintf("LED OFF\n");
// led_off();
}
}
void lv_user_gui_init(void)
{
lv_demo_widgets();
/* lv_obj_t *scr = lv_scr_act();
// 创建“按钮” —— 实际是一个可点击的普通对象
lv_obj_t *btn_on = lv_obj_create(scr);
lv_obj_set_size(btn_on, 100, 50);
lv_obj_align(btn_on, LV_ALIGN_CENTER, -60, 0);
lv_obj_add_flag(btn_on, LV_OBJ_FLAG_CLICKABLE); // 启用点击
lv_obj_clear_flag(btn_on, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_t *label_on = lv_label_create(btn_on);
lv_label_set_text(label_on, "LED ON");
lv_obj_center(label_on);
lv_obj_add_event_cb(btn_on, btn_led_on_evt_handler, LV_EVENT_CLICKED, NULL);
// 第二个按钮
lv_obj_t *btn_off = lv_obj_create(scr);
lv_obj_set_size(btn_off, 100, 50);
lv_obj_align(btn_off, LV_ALIGN_CENTER, 60, 0);
lv_obj_add_flag(btn_off, LV_OBJ_FLAG_CLICKABLE);
lv_obj_clear_flag(btn_off, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_t *label_off = lv_label_create(btn_off);
lv_label_set_text(label_off, "LED OFF");
lv_obj_center(label_off);
lv_obj_add_event_cb(btn_off, btn_led_off_evt_handler, LV_EVENT_CLICKED, NULL);*/
}