Skip to content

Commit

Permalink
add:pm.dtimerCheck 添加剩余时间
Browse files Browse the repository at this point in the history
  • Loading branch information
Dozingfiretruck committed Jan 30, 2024
1 parent e94b74c commit 388cebd
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions luat/modules/luat_lib_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,26 +128,31 @@ static int l_pm_dtimer_stop(lua_State *L) {
return 0;
}

LUAT_WEAK uint32_t luat_pm_dtimer_remain(int id){
return -1;
}

/**
检查底层定时器是不是在运行
@api pm.dtimerCheck(id)
@int 定时器id
@return boolean 处理结果,true还在运行,false不在运行
@return number 如果运行,运行剩余时间,单位毫秒
@usage
-- 检查底层定时器是不是在运行
pm.dtimerCheck(0) -- 检查id=0的底层定时器
*/
static int l_pm_dtimer_check(lua_State *L) {
int dtimer_id = luaL_checkinteger(L, 1);
if (luat_pm_dtimer_check(dtimer_id))
{
if (luat_pm_dtimer_check(dtimer_id)){
uint32_t remain = luat_pm_dtimer_remain(dtimer_id)
lua_pushboolean(L, 1);
}
else
{
lua_pushinteger(L, remain);
return 2;
}else
lua_pushboolean(L, 0);
}
return 1;
return 1;

}

static int l_pm_dtimer_list(lua_State *L) {
Expand Down

0 comments on commit 388cebd

Please sign in to comment.