This commit is contained in:
sc committed 2025-12-10 21:52:05 +08:00
1 parent 8565af8a2e
commit d8854fea10
16 files changed
+945 -901

No files matched your search

+45 -34
View File
@@ -19,44 +19,55 @@
#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)
{
// rt_pin_mode(LCD_BL_PIN, PIN_MODE_OUTPUT);
// rt_pin_write( LCD_BL_PIN, PIN_HIGH);
// rt_pin_mIN, ode(LCD_RST_PIN, PIN_MODE_OUTPUT);
// rt_pin_write( LCD_RST_PPIN_LOW);
lv_obj_t *scr = lv_scr_act();
// 检查 LTDC 是否全局使能
if (LTDC->GCR & LTDC_GCR_LTDCEN)
{
LOG_D("LTDC is ENABLED");
}
else
{
LOG_E("LTDC is NOT enabled!");
}
// 创建“按钮” —— 实际是一个可点击的普通对象
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);
// 检查图层 0 是否使能
if (LTDC_Layer1->CR & LTDC_LxCR_LEN)
{
LOG_D("Layer 0 is ENABLED");
}
else
{
LOG_E("Layer 0 is NOT enabled!");
}
if (__HAL_RCC_LTDC_IS_CLK_ENABLED())
{
LOG_D("LTDC clock is enabled");
}
else
{
LOG_E("LTDC clock is DISABLED! <-- This is likely the root cause");
}
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 *label = lv_label_create(lv_scr_act());
// lv_label_set_text(label, "Hello LVGL on RT-Thread!");
// lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
// 第二个按钮
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);
}
//INIT_APP_EXPORT(lv_user_gui_init);
+21 -7
View File
@@ -10,6 +10,8 @@
* INCLUDES
*********************/
#include "lv_port_disp.h"
#include "ltdc.h"
#include "lcd.h"
#include <stdbool.h>
/*********************
@@ -174,25 +176,37 @@ void disp_disable_update(void)
*'lv_disp_flush_ready()' has to be called when finished.*/
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
if(disp_flush_enabled) {
/*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/
// if(disp_flush_enabled){
// ltdc_color_fill(area->x1,area->y1,area->x2,area->y2,(uint16_t*)color_p);
// }
if(!RGB_DIR) /*竖屏*/
{
int32_t x;
int32_t y;
for(y = area->y1; y <= area->y2; y++) {
for(x = area->x1; x <= area->x2; x++) {
/*Put a pixel to the display. For example:*/
/*put_px(x, y, *color_p)*/
for(y = area->y1; y <= area->y2; y++)
{
for(x = area->x1; x <= area->x2; x++)
{
#if LTDC_PIXFORMAT == LTDC_PIXFORMAT_ARGB8888
ltdc_draw_point(x, y, *(uint32_t *)(uint32_t*)color_p);
#elif LTDC_PIXFORMAT_RGB565
ltdc_draw_point(x, y, *(uint16_t *)(uint32_t*)color_p);
#endif
color_p++;
}
}
}
else /*横屏*/
{
ltdc_color_fill(area->x1,area->y1,area->x2,area->y2,(uint16_t*)color_p);
}
/*IMPORTANT!!!
*Inform the graphics library that you are ready with the flushing*/
lv_disp_flush_ready(disp_drv);
}
/*OPTIONAL: GPU INTERFACE*/
/*If your MCU has hardware accelerator (GPU) then you can use it to fill a memory with a color*/
+2
View File
@@ -25,6 +25,8 @@ extern "C" {
/*********************
* DEFINES
*********************/
#define MY_DISP_HOR_RES 1024
#define MY_DISP_VER_RES 600
/**********************
* TYPEDEFS
-3
View File
@@ -12,7 +12,6 @@
#include <dfs_posix.h>
#include <light/RUN_LED.h>
#include "DB_SQLite.h"
#include "lv__user_gui.h"
#include "lcd.h"
#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
@@ -26,8 +25,6 @@ int main(void)
thread_DB_SQLite();
thread_RUN_LED();//运行指示灯线程
lcd_init();
// lv_user_gui_init();
return RT_EOK;
}
+1 -1
View File
@@ -69,4 +69,4 @@ static int wdt_sample()
return ret;
}
//INIT_APP_EXPORT(wdt_sample);
INIT_APP_EXPORT(wdt_sample);