添加 manual window 项,意外重启后恢复状态

-------------------
报位置会死机,待排查
This commit is contained in:
CSSC-WORK\murmur 2023-09-01 11:38:33 +08:00
parent 71c308b2fc
commit b8048ab60d
6 changed files with 60 additions and 20 deletions

View File

@ -3,7 +3,7 @@
# #
# RT-Thread Kernel # RT-Thread Kernel
# #
CONFIG_RT_NAME_MAX=8 CONFIG_RT_NAME_MAX=30
# CONFIG_RT_USING_ARCH_DATA_TYPE is not set # CONFIG_RT_USING_ARCH_DATA_TYPE is not set
# CONFIG_RT_USING_SMP is not set # CONFIG_RT_USING_SMP is not set
CONFIG_RT_ALIGN_SIZE=4 CONFIG_RT_ALIGN_SIZE=4
@ -20,7 +20,7 @@ CONFIG_RT_IDLE_HOOK_LIST_SIZE=4
CONFIG_IDLE_THREAD_STACK_SIZE=512 CONFIG_IDLE_THREAD_STACK_SIZE=512
CONFIG_RT_USING_TIMER_SOFT=y CONFIG_RT_USING_TIMER_SOFT=y
CONFIG_RT_TIMER_THREAD_PRIO=4 CONFIG_RT_TIMER_THREAD_PRIO=4
CONFIG_RT_TIMER_THREAD_STACK_SIZE=512 CONFIG_RT_TIMER_THREAD_STACK_SIZE=1024
# #
# kservice optimization # kservice optimization
@ -328,9 +328,9 @@ CONFIG_ULOG_USING_ISR_LOG=y
CONFIG_ULOG_ASSERT_ENABLE=y CONFIG_ULOG_ASSERT_ENABLE=y
CONFIG_ULOG_LINE_BUF_SIZE=256 CONFIG_ULOG_LINE_BUF_SIZE=256
CONFIG_ULOG_USING_ASYNC_OUTPUT=y CONFIG_ULOG_USING_ASYNC_OUTPUT=y
CONFIG_ULOG_ASYNC_OUTPUT_BUF_SIZE=2048 CONFIG_ULOG_ASYNC_OUTPUT_BUF_SIZE=10240
CONFIG_ULOG_ASYNC_OUTPUT_BY_THREAD=y CONFIG_ULOG_ASYNC_OUTPUT_BY_THREAD=y
CONFIG_ULOG_ASYNC_OUTPUT_THREAD_STACK=2048 CONFIG_ULOG_ASYNC_OUTPUT_THREAD_STACK=10240
CONFIG_ULOG_ASYNC_OUTPUT_THREAD_PRIORITY=29 CONFIG_ULOG_ASYNC_OUTPUT_THREAD_PRIORITY=29
# #

View File

@ -118,11 +118,11 @@ int get_cfg(const char *k)
// int rst = ini_gets("config",k,"000000",buf,MAX_KEY_LEN,LJW_CFG_FILE_NAME); // int rst = ini_gets("config",k,"000000",buf,MAX_KEY_LEN,LJW_CFG_FILE_NAME);
// if(strcmp(buf, "000000") == 0) { // if(strcmp(buf, "000000") == 0) {
// // 采用默认值 // // 采用默认值
int rst = ini_getl("config", k, -1, LJW_CFG_FILE_NAME); int rst = ini_getl("config", k, -3.14, LJW_CFG_FILE_NAME);
if (rst == -1) { if (rst == -3.14) {
LOG_W("no such KEY:%s",k); LOG_W("no such KEY:%s",k);
// clearLock(); // clearLock();
return -RT_ERROR; // return -RT_ERROR;
} }
else { else {
// LOG_I("%s = %s",k,buf); // LOG_I("%s = %s",k,buf);

View File

@ -222,7 +222,7 @@ void sysInit(void)
{ {
sysSemInit(); sysSemInit();
// sysEventInit(); // sysEventInit();
if (isInWindowZone()) {//开机检查是否在开窗区间内是则给TT开机 if (isInWindowZone() || isManualWindow()) {//开机检查是否在开窗区间内是则给TT开机
initTT(); initTT();
setWindowMode(); setWindowMode();
} }

View File

@ -246,7 +246,7 @@ int upSend(uint8_t *din, size_t len)
// return -RT_ERROR; // return -RT_ERROR;
// } // }
/* 创建 serial 线程 */ /* 创建 serial 线程 */
rt_thread_t thread = rt_thread_create("upSend", upSend_thread_entry, (void *) &msg, 1024 * 5, 27-1, 10); rt_thread_t thread = rt_thread_create("upSend", upSend_thread_entry, (void *) &msg, 1024 * 5, 26, 10);
/* 创建成功则启动线程 */ /* 创建成功则启动线程 */
if (thread != RT_NULL) if (thread != RT_NULL)
{ {
@ -375,15 +375,54 @@ void d_sw(void)
} }
/**
* 便
* @param isManualWindow 0
*/
void setManualWindow(uint8_t isManualWindow)
{
set_cfg("isMaWin", isManualWindow);
}
void closeWindow(void);
/**
*
* @return 1-0-
*/
int isManualWindow(void)
{
int rst = get_cfg("isMaWin");
if (rst < 0) {//none
return 0;
}
if (rst == 0) {//manual open without auto close
return 1;
}
//设置定时器,定时器到则关窗
/* 创建定时器,单次定时器 */
rt_timer_t timer1;
timer1 = rt_timer_create("window", closeWindow,
RT_NULL, rt_tick_from_millisecond(rst*60*1000),
RT_TIMER_FLAG_ONE_SHOT);
/* 启动定时器 */
if (timer1 != RT_NULL)
{
rt_timer_start(timer1);
LOG_D("手动开窗完成,%d分钟后自动关窗。",rst);
}
return 1;
}
/** /**
* *
* @param t t=0 * @param t t=0
*/ */
void openWindow(int t) void openWindow(int t)
{ {
//保存记录
setManualWindow(t);
//开启TT //开启TT
// pwTT_thread_entry("1");//开机
initTT(); initTT();
setWindowMode(); setWindowMode();
//手动开窗优先级最高,自动开窗其次,高优先级会屏蔽低优先级 //手动开窗优先级最高,自动开窗其次,高优先级会屏蔽低优先级
@ -396,7 +435,7 @@ void openWindow(int t)
//设置定时器,定时器到则关窗 //设置定时器,定时器到则关窗
/* 创建定时器,单次定时器 */ /* 创建定时器,单次定时器 */
rt_timer_t timer1; rt_timer_t timer1;
timer1 = rt_timer_create("window", deInitTT(), timer1 = rt_timer_create("window", closeWindow,
RT_NULL, rt_tick_from_millisecond(t*60*1000), RT_NULL, rt_tick_from_millisecond(t*60*1000),
RT_TIMER_FLAG_ONE_SHOT); RT_TIMER_FLAG_ONE_SHOT);
/* 启动定时器 */ /* 启动定时器 */
@ -411,9 +450,11 @@ void openWindow(int t)
/** /**
* *
*/ */
void closeWindow() void closeWindow(void)
{ {
// pwTT_thread_entry("0");//关 机 setManualWindow(-1);
// 恢复RTC
startAlarm();
deInitTT(); deInitTT();
LOG_D("手动关窗完成。"); LOG_D("手动关窗完成。");
} }

View File

@ -36,7 +36,7 @@ typedef enum
#define ROOT_PATH ROOT_PATH_DEBUG //设置保存路径 #define ROOT_PATH ROOT_PATH_DEBUG //设置保存路径
#define FILE_SIZE 10*1024 //设置单个文件大小 #define FILE_SIZE 10*1024 //设置单个文件大小
#define BUFF_SIZE 1*1024 //设备缓存区大小 #define BUFF_SIZE 10*1024 //设备缓存区大小
static struct ulog_backend sys_log_backend; static struct ulog_backend sys_log_backend;
static struct ulog_file_be sys_log_file; static struct ulog_file_be sys_log_file;
@ -55,7 +55,6 @@ static struct _log_file table[] =
* @retval None. * @retval None.
* @note None. * @note None.
*/ */
void sys_log_file_backend_init(void) void sys_log_file_backend_init(void)
{ {
static struct ulog_file_be *file_be = &sys_log_file; static struct ulog_file_be *file_be = &sys_log_file;

View File

@ -18,7 +18,7 @@
#define IDLE_THREAD_STACK_SIZE 512 #define IDLE_THREAD_STACK_SIZE 512
#define RT_USING_TIMER_SOFT #define RT_USING_TIMER_SOFT
#define RT_TIMER_THREAD_PRIO 4 #define RT_TIMER_THREAD_PRIO 4
#define RT_TIMER_THREAD_STACK_SIZE 512*2 #define RT_TIMER_THREAD_STACK_SIZE 1024
/* kservice optimization */ /* kservice optimization */
@ -114,7 +114,7 @@
#define RT_USING_SDIO #define RT_USING_SDIO
#define RT_SDIO_STACK_SIZE 5120 #define RT_SDIO_STACK_SIZE 5120
#define RT_SDIO_THREAD_PRIORITY 15 #define RT_SDIO_THREAD_PRIORITY 15
#define RT_MMCSD_STACK_SIZE 10240 #define RT_MMCSD_STACK_SIZE 1024
#define RT_MMCSD_THREAD_PREORITY 22 #define RT_MMCSD_THREAD_PREORITY 22
#define RT_MMCSD_MAX_PARTITION 16 #define RT_MMCSD_MAX_PARTITION 16
#define RT_USING_SPI #define RT_USING_SPI
@ -204,9 +204,9 @@
#define ULOG_ASSERT_ENABLE #define ULOG_ASSERT_ENABLE
#define ULOG_LINE_BUF_SIZE 256 #define ULOG_LINE_BUF_SIZE 256
#define ULOG_USING_ASYNC_OUTPUT #define ULOG_USING_ASYNC_OUTPUT
#define ULOG_ASYNC_OUTPUT_BUF_SIZE 2048 #define ULOG_ASYNC_OUTPUT_BUF_SIZE 10240
#define ULOG_ASYNC_OUTPUT_BY_THREAD #define ULOG_ASYNC_OUTPUT_BY_THREAD
#define ULOG_ASYNC_OUTPUT_THREAD_STACK 2048 #define ULOG_ASYNC_OUTPUT_THREAD_STACK 10240
#define ULOG_ASYNC_OUTPUT_THREAD_PRIORITY 29 #define ULOG_ASYNC_OUTPUT_THREAD_PRIORITY 29
/* log format */ /* log format */