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.

76 lines
2.0 KiB

2 months ago
/*
* 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
*/
1 month ago
#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>
2 months ago
#include "lvgl.h"
1 month ago
#include "lv_demo_widgets.h"
2 months ago
1 month ago
#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)
1 month ago
static void btn_led_on_evt_handler(lv_event_t *e)
2 months ago
{
1 month ago
lv_event_code_t code = lv_event_get_code(e);
1 month ago
1 month ago
if (code == LV_EVENT_CLICKED)
1 month ago
{
1 month ago
rt_kprintf("LED ON\n");
//led_on();
1 month ago
}
1 month ago
}
1 month ago
1 month ago
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)
1 month ago
{
1 month ago
rt_kprintf("LED OFF\n");
// led_off();
1 month ago
}
1 month ago
}
void lv_user_gui_init(void)
{
1 month ago
lv_demo_widgets();
/* lv_obj_t *scr = lv_scr_act();
1 month ago
// 创建“按钮” —— 实际是一个可点击的普通对象
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);
1 month ago
1 month ago
lv_obj_t *label_off = lv_label_create(btn_off);
lv_label_set_text(label_off, "LED OFF");
lv_obj_center(label_off);
1 month ago
1 month ago
lv_obj_add_event_cb(btn_off, btn_led_off_evt_handler, LV_EVENT_CLICKED, NULL);*/
2 months ago
}