修改lvgl。cjson内存管理器
This commit is contained in:
1 parent
552a916705
commit
541738319d
11 files changed
+100
-26
No files matched your search
@@ -29,6 +29,8 @@ static const mb_backend_param_t mb_bkd_prm = {
|
||||
};
|
||||
|
||||
extern unsigned char sys_time[6];
|
||||
uint8_t r_buffer[16],w_buffer[16];
|
||||
uint16_t r_regsD[128],w_regsD[128];
|
||||
|
||||
static void mb_plc_read_regs(mb_inst_t *hinst)
|
||||
{
|
||||
@@ -39,7 +41,7 @@ static void mb_plc_read_regs(mb_inst_t *hinst)
|
||||
}
|
||||
|
||||
//输入m0000->rtu2000
|
||||
uint8_t r_buffer[(DI_TABLE_SIZE + 7) / 8];
|
||||
//uint8_t r_buffer[(DI_TABLE_SIZE + 7) / 8];
|
||||
//读取 Modbus bits
|
||||
int mrx = mb_read_bits(hinst, 2000, DI_TABLE_SIZE, r_buffer);
|
||||
if (mrx > 0)
|
||||
@@ -53,7 +55,7 @@ static void mb_plc_read_regs(mb_inst_t *hinst)
|
||||
}
|
||||
|
||||
// 输出 m0256 -> RTU 2256
|
||||
uint8_t w_buffer[(DO_TABLE_SIZE + 7) / 8]; // 关键:初始化为0
|
||||
//uint8_t w_buffer[(DO_TABLE_SIZE + 7) / 8]; // 关键:初始化为0
|
||||
// 打包 do_table 到 bit_buffer
|
||||
for (int i = 0; i < DO_TABLE_SIZE; i++) {
|
||||
const int byte_idx = i / 8;
|
||||
@@ -73,7 +75,7 @@ static void mb_plc_read_regs(mb_inst_t *hinst)
|
||||
}
|
||||
|
||||
//输入寄存器d0->6000
|
||||
u16 r_regsD[AI_TABLE_SIZE];
|
||||
//u16 r_regsD[AI_TABLE_SIZE];
|
||||
// 读 Modbus
|
||||
int mrd = mb_read_regs(hinst, 6000, AI_TABLE_SIZE, r_regsD);
|
||||
if (mrd > 0)
|
||||
@@ -87,7 +89,7 @@ static void mb_plc_read_regs(mb_inst_t *hinst)
|
||||
}
|
||||
|
||||
//输出寄存器d100->6100
|
||||
u16 w_regsD [AO_TABLE_SIZE];
|
||||
//u16 w_regsD [AO_TABLE_SIZE];
|
||||
for (int i = 0; i < AO_TABLE_SIZE; i++)
|
||||
{
|
||||
w_regsD [i] = ao_table[i].current_Value;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2026-01-24 Administrator the first version
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include "lvgl.h"
|
||||
#include <stddef.h>
|
||||
|
||||
extern struct rt_memheap sdram_heap; //
|
||||
|
||||
void *lv_custom_mem_alloc(size_t size)
|
||||
{
|
||||
return rt_memheap_alloc(&sdram_heap, size);
|
||||
}
|
||||
|
||||
void lv_custom_mem_free(void *ptr)
|
||||
{
|
||||
if (ptr) rt_memheap_free(ptr);
|
||||
}
|
||||
|
||||
void *lv_custom_mem_realloc(void *ptr, size_t new_size)
|
||||
{
|
||||
return rt_memheap_realloc(&sdram_heap, ptr, new_size);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2026-01-24 Administrator the first version
|
||||
*/
|
||||
#ifndef APPLICATIONS_LVGL_LV_PORT_MEM_H_
|
||||
#define APPLICATIONS_LVGL_LV_PORT_MEM_H_
|
||||
|
||||
void *lv_custom_mem_alloc(size_t size);
|
||||
void lv_custom_mem_free(void *ptr);
|
||||
void *lv_custom_mem_realloc(void *ptr, size_t new_size);
|
||||
|
||||
#endif /* APPLICATIONS_LVGL_LV_PORT_MEM_H_ */
|
||||
@@ -190,8 +190,6 @@ void db_sqlite_init_full(void)
|
||||
if (g_db)
|
||||
{
|
||||
sqlite3_close(g_db);
|
||||
//限制缓存大小 (100KB)
|
||||
sqlite3_exec(g_db, "PRAGMA cache_size = 50;", 0, 0, 0);
|
||||
g_db = RT_NULL;
|
||||
}
|
||||
return; //
|
||||
@@ -286,7 +284,6 @@ static void db_sqlite(void *parameter) {
|
||||
if (first_wait_done)
|
||||
{
|
||||
first_wait_done = RT_FALSE;
|
||||
sqlite3_exec(g_db, "PRAGMA shrink_memory;", 0, 0, 0);
|
||||
sqlite3_close(g_db);
|
||||
g_db=RT_NULL;
|
||||
op_link=0;
|
||||
|
||||
@@ -35,6 +35,9 @@ static void idle_hook(void)
|
||||
|
||||
static int wdt_sample()
|
||||
{
|
||||
|
||||
rt_thread_mdelay(5000);
|
||||
|
||||
rt_err_t ret = RT_EOK;
|
||||
rt_uint32_t timeout = 1; /* 溢出时间,单位:秒 */
|
||||
char device_name[RT_NAME_MAX];
|
||||
|
||||
Reference in new issue
Block a user