1. 更新页面管理
2. 更新日志接口
This commit is contained in:
parent
031dc7641b
commit
405527c3a1
@ -11,6 +11,11 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
// 外部需要定义该宏, 用于说明页面数量, 如果不定义, 默认搜索 kUIPageMax 枚举
|
||||||
|
#ifndef HUI_PAGE_MAX_NUM
|
||||||
|
#define HUI_PAGE_MAX_NUM kUIPageMax
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __COUNT_ARGS_IMPL
|
#ifndef __COUNT_ARGS_IMPL
|
||||||
#define __COUNT_ARGS_IMPL(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, N, ...) N
|
#define __COUNT_ARGS_IMPL(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, N, ...) N
|
||||||
#endif
|
#endif
|
||||||
@ -51,7 +56,6 @@
|
|||||||
#define UI_CALL_INDEX_TYPE(value) ((HUiPageIndex_t *)value)
|
#define UI_CALL_INDEX_TYPE(value) ((HUiPageIndex_t *)value)
|
||||||
/** ================================================================= */
|
/** ================================================================= */
|
||||||
|
|
||||||
typedef uint8_t HUiPageIndex_t;
|
|
||||||
|
|
||||||
// hide -> free -> update Page -> init -> show
|
// hide -> free -> update Page -> init -> show
|
||||||
// 或者非返回时如下, 此时的hide和index事件都可存储该页面索引:
|
// 或者非返回时如下, 此时的hide和index事件都可存储该页面索引:
|
||||||
@ -66,13 +70,7 @@ enum eCallCmd
|
|||||||
kCallIndexSave, ///< 存储当前索引事件, 通知此事件说明当前不是返回事件(cmd, HUiPageIndex_t *nextPage, 1);
|
kCallIndexSave, ///< 存储当前索引事件, 通知此事件说明当前不是返回事件(cmd, HUiPageIndex_t *nextPage, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef uint8_t HUiPageIndex_t;
|
||||||
// 每个页面占用一个枚举, 根据枚举切换页面, kUIPageMax最大页面值, 要求格式统一 kUIPage + 页面名, 可以任意调整位置
|
|
||||||
typedef enum eUIPage
|
|
||||||
{
|
|
||||||
|
|
||||||
kUIPageMax = 4, ///< ui最大个数, 不超过254个页面, 如超过则需要修改字节栈类型
|
|
||||||
} eUIPage;
|
|
||||||
|
|
||||||
///< cmd命令, data数据, len数据长度
|
///< cmd命令, data数据, len数据长度
|
||||||
typedef uint8_t (*pageCallType_t)(uint16_t cmd, void *data, uint16_t len);
|
typedef uint8_t (*pageCallType_t)(uint16_t cmd, void *data, uint16_t len);
|
||||||
|
|||||||
@ -323,7 +323,7 @@ void HDLogDebugDeleteStackAddr(unsigned long currTask)
|
|||||||
uint32_t HDLogDebugGetCurrStackSize()
|
uint32_t HDLogDebugGetCurrStackSize()
|
||||||
{
|
{
|
||||||
void *curr = NULL;
|
void *curr = NULL;
|
||||||
int16_t index = HDLogGetIndex(NULL);
|
int16_t index = HDLogGetIndex(0);
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
#include <HUIPageManage.h>
|
#include <HUIPageManage.h>
|
||||||
#include <HByteStack.h>
|
#include <HByteStack.h>
|
||||||
#include <HBit.h>
|
#include <HBit.h>
|
||||||
|
#include <HDPageInit.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -24,7 +25,7 @@
|
|||||||
|
|
||||||
typedef struct HUIPageManage
|
typedef struct HUIPageManage
|
||||||
{
|
{
|
||||||
pageCallType_t pageCall[kUIPageMax]; ///< 页面回调
|
pageCallType_t pageCall[HUI_PAGE_MAX_NUM]; ///< 页面回调
|
||||||
long userData; ///< 用户数据
|
long userData; ///< 用户数据
|
||||||
uint8_t homePage; ///< 首页, 当切换到首页时清空返回栈
|
uint8_t homePage; ///< 首页, 当切换到首页时清空返回栈
|
||||||
uint8_t currPage; ///< 当前页面
|
uint8_t currPage; ///< 当前页面
|
||||||
@ -45,10 +46,10 @@ static HBYTE_STACK_DEFINE(pageStack, HUIPAGE_STACK_SIZE);
|
|||||||
static HBYTE_STACK_DEFINE(indexStack, HUIPAGE_STACK_SIZE);
|
static HBYTE_STACK_DEFINE(indexStack, HUIPAGE_STACK_SIZE);
|
||||||
|
|
||||||
// 不释放页面
|
// 不释放页面
|
||||||
static HBIT_DEFINE(notFreeBit, kUIPageMax);
|
static HBIT_DEFINE(notFreeBit, HUI_PAGE_MAX_NUM);
|
||||||
|
|
||||||
// 已初始化页面
|
// 已初始化页面
|
||||||
static HBIT_DEFINE(initPageBit, kUIPageMax);
|
static HBIT_DEFINE(initPageBit, HUI_PAGE_MAX_NUM);
|
||||||
|
|
||||||
|
|
||||||
/** =================================================== */
|
/** =================================================== */
|
||||||
@ -178,7 +179,7 @@ void HUIPageSetHome(HUiPageIndex_t page) {
|
|||||||
// 切换页面, 当前页面入栈, 相同页面不操作, 需要检查栈, 栈存在就回栈清空之后的, 不存在就压栈
|
// 切换页面, 当前页面入栈, 相同页面不操作, 需要检查栈, 栈存在就回栈清空之后的, 不存在就压栈
|
||||||
// 因为有些页面可能不用HUIPageBack来返回, 所以需要兼容这种情况
|
// 因为有些页面可能不用HUIPageBack来返回, 所以需要兼容这种情况
|
||||||
void HUIPageSwitch(HUiPageIndex_t page) {
|
void HUIPageSwitch(HUiPageIndex_t page) {
|
||||||
if (page < 0 || page >= kUIPageMax) {
|
if (page < 0 || page >= HUI_PAGE_MAX_NUM) {
|
||||||
LogD("page[%d] out of range", page);
|
LogD("page[%d] out of range", page);
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
@ -304,7 +305,7 @@ void _HUIPageAddStack(int len, ...) {
|
|||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, len);
|
va_start(args, len);
|
||||||
HUiPageIndex_t curr = va_arg(args, int);
|
HUiPageIndex_t curr = (HUiPageIndex_t)va_arg(args, int);
|
||||||
HByteLenType findPos = HByteStackFind(pageStack, curr);
|
HByteLenType findPos = HByteStackFind(pageStack, curr);
|
||||||
if (findPos != HBYTE_STACK_ERROR) {
|
if (findPos != HBYTE_STACK_ERROR) {
|
||||||
HByteStackSetUseLen(pageStack, findPos);
|
HByteStackSetUseLen(pageStack, findPos);
|
||||||
@ -313,6 +314,7 @@ void _HUIPageAddStack(int len, ...) {
|
|||||||
} else if (curr == pageManage.homePage) {
|
} else if (curr == pageManage.homePage) {
|
||||||
// 如果查找不到, 传入的首个页面又是首页, 则清空返回栈
|
// 如果查找不到, 传入的首个页面又是首页, 则清空返回栈
|
||||||
if (HUIPageClear() == 0) {
|
if (HUIPageClear() == 0) {
|
||||||
|
va_end(args);
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,8 +322,8 @@ void _HUIPageAddStack(int len, ...) {
|
|||||||
findPos = HByteStackGetUseLen(pageStack);
|
findPos = HByteStackGetUseLen(pageStack);
|
||||||
HByteStackPush(pageStack, curr);
|
HByteStackPush(pageStack, curr);
|
||||||
for (int i = 1; i < len; ++i) {
|
for (int i = 1; i < len; ++i) {
|
||||||
curr = va_arg(args, int);
|
curr = (HUiPageIndex_t)va_arg(args, int);
|
||||||
if (curr < 0 || curr >= kUIPageMax) {
|
if (curr < 0 || curr >= HUI_PAGE_MAX_NUM) {
|
||||||
LogD("page[%d] out of range", curr);
|
LogD("page[%d] out of range", curr);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user