添加信息
This commit is contained in:
1 parent
b185a8ec12
commit
115d1d12c3
22 files changed
+3619
-1829
No files matched your search
@@ -0,0 +1,59 @@
|
||||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
|
||||
/**
|
||||
* @brief Allocate aligned memory from a memheap
|
||||
*
|
||||
* @param heap Pointer to the memheap object
|
||||
* @param size Requested user memory size (in bytes)
|
||||
* @param align Alignment boundary (must be power of 2, e.g., 4, 8, 16)
|
||||
* @return void* Aligned pointer on success, RT_NULL on failure
|
||||
*
|
||||
* @note The returned pointer must be freed with rt_memheap_free_align()
|
||||
*/
|
||||
void *rt_memheap_alloc_align(struct rt_memheap *heap, rt_size_t size, rt_size_t align)
|
||||
{
|
||||
void *raw_ptr;
|
||||
void *aligned_ptr;
|
||||
uintptr_t *header; // stores raw_ptr for free
|
||||
|
||||
RT_ASSERT(heap != RT_NULL);
|
||||
RT_ASSERT(size > 0);
|
||||
RT_ASSERT(align > 0 && (align & (align - 1)) == 0); // check power of 2
|
||||
|
||||
// Minimum space: user data + alignment padding + hidden header (sizeof(uintptr_t))
|
||||
rt_size_t total_size = size + align - 1 + sizeof(uintptr_t);
|
||||
|
||||
raw_ptr = rt_memheap_alloc(heap, total_size);
|
||||
if (raw_ptr == RT_NULL)
|
||||
return RT_NULL;
|
||||
|
||||
// Calculate aligned address after hidden header
|
||||
uintptr_t addr = (uintptr_t)raw_ptr + sizeof(uintptr_t);
|
||||
aligned_ptr = (void *)((addr + align - 1) & ~(align - 1));
|
||||
|
||||
// Store raw_ptr just before aligned_ptr (in the hidden header)
|
||||
header = (uintptr_t *)aligned_ptr - 1;
|
||||
*header = (uintptr_t)raw_ptr;
|
||||
|
||||
return aligned_ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Free memory allocated by rt_memheap_alloc_align()
|
||||
*
|
||||
* @param heap Pointer to the memheap object
|
||||
* @param ptr Pointer returned by rt_memheap_alloc_align()
|
||||
*/
|
||||
void rt_memheap_free_align(struct rt_memheap *heap, void *ptr)
|
||||
{
|
||||
if (ptr == RT_NULL)
|
||||
return;
|
||||
|
||||
// Retrieve raw_ptr from hidden header
|
||||
uintptr_t *header = (uintptr_t *)ptr - 1;
|
||||
void *raw_ptr = (void *)(*header);
|
||||
|
||||
rt_memheap_free(raw_ptr);
|
||||
}
|
||||
|
||||
@@ -327,8 +327,7 @@ typedef struct
|
||||
lv_obj_t *screen_do64;
|
||||
lv_obj_t *screen_do65;
|
||||
lv_obj_t *screen_do66;
|
||||
lv_obj_t *screen_do67;
|
||||
lv_obj_t *screen_name_do0;
|
||||
lv_obj_t *screen_name_do0;
|
||||
lv_obj_t *screen_name_do1;
|
||||
lv_obj_t *screen_name_do2;
|
||||
lv_obj_t *screen_name_do3;
|
||||
@@ -337,7 +336,7 @@ typedef struct
|
||||
lv_obj_t *screen_name_do6;
|
||||
lv_obj_t *screen_name_do7;
|
||||
lv_obj_t *screen_name_do8;
|
||||
lv_obj_t *screen_name_do9;
|
||||
lv_obj_t *screen_name_do09;
|
||||
lv_obj_t *screen_name_do10;
|
||||
lv_obj_t *screen_name_do11;
|
||||
lv_obj_t *screen_name_do12;
|
||||
@@ -418,6 +417,7 @@ typedef struct
|
||||
lv_obj_t *screen_sys_name;
|
||||
lv_obj_t *screen_machine_id;
|
||||
lv_obj_t *screen_sys_id;
|
||||
lv_obj_t *screen_sys_var;
|
||||
lv_obj_t *g_kb_top_layer;
|
||||
}lv_ui;
|
||||
|
||||
@@ -462,6 +462,7 @@ LV_FONT_DECLARE(lv_font_Alatsi_Regular_20)
|
||||
LV_FONT_DECLARE(lv_font_simsun_21)
|
||||
LV_FONT_DECLARE(lv_font_Acme_Regular_16)
|
||||
LV_FONT_DECLARE(lv_font_Alatsi_Regular_18)
|
||||
LV_FONT_DECLARE(lv_font_simsun_14)
|
||||
LV_FONT_DECLARE(lv_font_montserratMedium_14)
|
||||
LV_FONT_DECLARE(lv_font_simsun_32)
|
||||
LV_FONT_DECLARE(lv_font_montserratMedium_30)
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -287,7 +287,7 @@ void ui_init_dio_leds(lv_ui *ui) {
|
||||
do_name_array[6] = ui->screen_name_do6;
|
||||
do_name_array[7] = ui->screen_name_do7;
|
||||
do_name_array[8] = ui->screen_name_do8;
|
||||
do_name_array[9] = ui->screen_name_do9;
|
||||
do_name_array[9] = ui->screen_name_do09;
|
||||
do_name_array[10] = ui->screen_name_do10;
|
||||
do_name_array[11] = ui->screen_name_do11;
|
||||
do_name_array[12] = ui->screen_name_do12;
|
||||
@@ -357,6 +357,9 @@ void setup_user_screen(lv_ui *ui)
|
||||
|
||||
|
||||
|
||||
//lv_label_set_text(di_name_array[0], lang_get_str(0));
|
||||
//lv_label_set_text(di_name_array[i], lang_get_str(di_table[i].name));
|
||||
//lv_label_set_text(di_name_array[i], lang_get_str(di_table[i].name));
|
||||
|
||||
for (int i = 0; i < DI_TABLE_SIZE; i++)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,9 @@
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
#define DBG_TAG "LVGLd"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
@@ -47,7 +49,15 @@ static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_colo
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
static lv_disp_draw_buf_t draw_buf_dsc_1;
|
||||
static lv_disp_draw_buf_t draw_buf_dsc_2;
|
||||
static lv_disp_draw_buf_t draw_buf_dsc_3;
|
||||
|
||||
static lv_color_t *buf_1 = RT_NULL;
|
||||
static lv_color_t *buf_2_1 = RT_NULL;
|
||||
static lv_color_t *buf_2_2 = RT_NULL;
|
||||
static lv_color_t *buf_3_1 = RT_NULL;
|
||||
static lv_color_t *buf_3_2 = RT_NULL;
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
@@ -85,35 +95,65 @@ void lv_port_disp_init(void)
|
||||
*/
|
||||
|
||||
/* Example for 1) */
|
||||
static lv_disp_draw_buf_t draw_buf_dsc_1 __attribute__((aligned(4)));
|
||||
static lv_color_t *buf_1 __attribute__((aligned(4))) = RT_NULL;
|
||||
//static lv_disp_draw_buf_t draw_buf_dsc_1 __attribute__((aligned(8)));
|
||||
//static lv_color_t *buf_1 __attribute__((aligned(8))) = RT_NULL;
|
||||
//static lv_color_t buf_1[MY_DISP_HOR_RES * 10] __attribute__((section(".sdram"))); /*A buffer for 10 rows*/
|
||||
buf_1 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_HOR_RES * 10);
|
||||
//buf_1 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_HOR_RES * 10);
|
||||
|
||||
lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/
|
||||
//lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/
|
||||
|
||||
/* Example for 2) */
|
||||
static lv_disp_draw_buf_t draw_buf_dsc_2 __attribute__((aligned(4)));
|
||||
static lv_color_t *buf_2_1 __attribute__((aligned(4)))= RT_NULL;
|
||||
static lv_color_t *buf_2_2 __attribute__((aligned(4)))= RT_NULL;
|
||||
//static lv_disp_draw_buf_t draw_buf_dsc_2 __attribute__((aligned(8)));
|
||||
//static lv_color_t *buf_2_1 __attribute__((aligned(8)))= RT_NULL;
|
||||
//static lv_color_t *buf_2_2 __attribute__((aligned(8)))= RT_NULL;
|
||||
//static lv_color_t buf_2_1[MY_DISP_HOR_RES * 10] __attribute__((section(".sdram"))); /*A buffer for 10 rows*/
|
||||
//static lv_color_t buf_2_2[MY_DISP_HOR_RES * 10] __attribute__((section(".sdram"))); /*An other buffer for 10 rows*/
|
||||
buf_2_1 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_HOR_RES * 10);
|
||||
buf_2_2 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_HOR_RES * 10);
|
||||
//buf_2_1 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_HOR_RES * 10);
|
||||
//buf_2_2 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_HOR_RES * 10);
|
||||
|
||||
lv_disp_draw_buf_init(&draw_buf_dsc_2, buf_2_1, buf_2_2, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/
|
||||
//lv_disp_draw_buf_init(&draw_buf_dsc_2, buf_2_1, buf_2_2, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/
|
||||
|
||||
/* Example for 3) also set disp_drv.full_refresh = 1 below*/
|
||||
static lv_disp_draw_buf_t draw_buf_dsc_3 __attribute__((aligned(4)));
|
||||
static lv_color_t *buf_3_1 __attribute__((aligned(4)))= RT_NULL;
|
||||
static lv_color_t *buf_3_2 __attribute__((aligned(4)))= RT_NULL;
|
||||
//static lv_disp_draw_buf_t draw_buf_dsc_3 __attribute__((aligned(8)));
|
||||
//static lv_color_t *buf_3_1 __attribute__((aligned(8)))= RT_NULL;
|
||||
//static lv_color_t *buf_3_2 __attribute__((aligned(8)))= RT_NULL;
|
||||
//static lv_color_t buf_3_1[MY_DISP_HOR_RES * MY_DISP_VER_RES] __attribute__((section(".sdram"))); /*A screen sized buffer*/
|
||||
//static lv_color_t buf_3_2[MY_DISP_HOR_RES * MY_DISP_VER_RES] __attribute__((section(".sdram"))); /*Another screen sized buffer*/
|
||||
buf_3_1 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_VER_RES * 10);
|
||||
buf_3_2 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_VER_RES * 10);
|
||||
//buf_3_1 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_VER_RES * 10);
|
||||
//buf_3_2 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_VER_RES * 10);
|
||||
|
||||
lv_disp_draw_buf_init(&draw_buf_dsc_3, buf_3_1, buf_3_2, MY_DISP_HOR_RES * MY_DISP_VER_RES ); /*Initialize the display buffer*/
|
||||
//lv_disp_draw_buf_init(&draw_buf_dsc_3, buf_3_1, buf_3_2, MY_DISP_HOR_RES * MY_DISP_VER_RES ); /*Initialize the display buffer*/
|
||||
|
||||
|
||||
|
||||
|
||||
// 使用对齐分配函数
|
||||
buf_1 = (lv_color_t *)rt_memheap_alloc_align(&sdram_heap,
|
||||
sizeof(lv_color_t) * MY_DISP_HOR_RES * 10,
|
||||
4); // ← 关键:对齐到 4 字节
|
||||
|
||||
buf_2_1 = (lv_color_t *)rt_memheap_alloc_align(&sdram_heap,
|
||||
sizeof(lv_color_t) * MY_DISP_HOR_RES * 10,
|
||||
4);
|
||||
buf_2_2 = (lv_color_t *)rt_memheap_alloc_align(&sdram_heap,
|
||||
sizeof(lv_color_t) * MY_DISP_HOR_RES * 10,
|
||||
4);
|
||||
|
||||
buf_3_1 = (lv_color_t *)rt_memheap_alloc_align(&sdram_heap,
|
||||
sizeof(lv_color_t) * MY_DISP_HOR_RES * MY_DISP_VER_RES,
|
||||
4);
|
||||
buf_3_2 = (lv_color_t *)rt_memheap_alloc_align(&sdram_heap,
|
||||
sizeof(lv_color_t) * MY_DISP_HOR_RES * MY_DISP_VER_RES,
|
||||
4);
|
||||
|
||||
if (!buf_1 || !buf_2_1 || !buf_2_2 || !buf_3_1 || !buf_3_2) {
|
||||
LOG_E("Failed to alloc aligned draw buffers");
|
||||
}
|
||||
|
||||
// 初始化 draw buffer
|
||||
lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, MY_DISP_HOR_RES * 10);
|
||||
lv_disp_draw_buf_init(&draw_buf_dsc_2, buf_2_1, buf_2_2, MY_DISP_HOR_RES * 10);
|
||||
lv_disp_draw_buf_init(&draw_buf_dsc_3, buf_3_1, buf_3_2, MY_DISP_HOR_RES * MY_DISP_VER_RES);
|
||||
/*-----------------------------------
|
||||
* Register the display in LVGL
|
||||
*----------------------------------*/
|
||||
@@ -131,7 +171,7 @@ void lv_port_disp_init(void)
|
||||
disp_drv.flush_cb = disp_flush;
|
||||
|
||||
/*Set a display buffer*/
|
||||
disp_drv.draw_buf = &draw_buf_dsc_1;
|
||||
disp_drv.draw_buf = &draw_buf_dsc_2;
|
||||
|
||||
/*Required for Example 3)*/
|
||||
//disp_drv.full_refresh = 1;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <rtdbg.h>
|
||||
|
||||
extern rt_sem_t mount_sem; // 引用上面SD挂载线程定义的信号量
|
||||
extern struct rt_memheap sram_DTCMRAM,sram_AXIRAM,sram_SRAM1,sram_SRAM2;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
@@ -293,8 +293,8 @@ static void db_sqlite(void *parameter) {
|
||||
}
|
||||
continue;
|
||||
}else{
|
||||
if(op_link>1000)
|
||||
{//连续操作数据库1000次后强制关闭防止内存占用
|
||||
if(op_link>255)
|
||||
{//连续操作数据库255次后强制关闭防止内存占用
|
||||
sqlite3_close(g_db);
|
||||
g_db=RT_NULL;
|
||||
op_link=0;
|
||||
|
||||
+1
-1
@@ -69,4 +69,4 @@ static int wdt_sample()
|
||||
return ret;
|
||||
}
|
||||
|
||||
INIT_APP_EXPORT(wdt_sample);
|
||||
//INIT_APP_EXPORT(wdt_sample);
|
||||
Reference in new issue
Block a user