瀏覽代碼

add: pm添加2个新方法, 一个读取唤醒的deepTimer的id, 一个读取deepTimer唤醒时间

Wendal Chen 5 年之前
父節點
當前提交
faff0117ca
共有 2 個文件被更改,包括 42 次插入2 次删除
  1. 4 0
      luat/include/luat_pm.h
  2. 38 2
      luat/modules/luat_lib_pm.c

+ 4 - 0
luat/include/luat_pm.h

@@ -26,3 +26,7 @@ int luat_pm_force(int mode);
 
 int luat_pm_check(void);
 
+int luat_pm_dtimer_list(size_t* count, size_t* list);
+
+int uat_pm_dtimer_wakeup_id(int id);
+

+ 38 - 2
luat/modules/luat_lib_pm.c

@@ -98,6 +98,38 @@ static int l_pm_dtimer_check(lua_State *L) {
     return 1;
 }
 
+static int l_pm_dtimer_list(lua_State *L) {
+    size_t c = 0;
+    size_t dlist[24];
+
+    luat_pm_dtimer_list(&c, dlist);
+
+    lua_createtable(L, c, 0);
+    for (size_t i = 0; i < c; i++)
+    {
+        if (dlist[i] > 0) {
+            lua_pushinteger(L, dlist[i]);
+            lua_seti(L, -3, i+1);
+        }
+    }
+
+    return 1;
+}
+
+static int l_pm_dtimer_wakeup_id(lua_State *L) {
+    int dtimer_id = 0xFF;
+
+    luat_pm_dtimer_wakeup_id(&dtimer_id);
+
+    if (dtimer_id != 0xFF) {
+        lua_pushinteger(L, dtimer_id);
+    }
+    else {
+        lua_pushinteger(L, -1);
+    }
+    return 1;
+}
+
 static int l_pm_on(lua_State *L) {
     if (lua_isfunction(L, 1)) {
         if (lua_event_cb != 0) {
@@ -126,7 +158,7 @@ static int l_pm_last_reson(lua_State *L) {
     luat_pm_last_state(&lastState, &rtcOrPad);
     lua_pushinteger(L, lastState);
     lua_pushinteger(L, rtcOrPad);
-    return 1;
+    return 2;
 }
 
 /**
@@ -164,6 +196,8 @@ static int l_pm_check(lua_State *L) {
     return 2;
 }
 
+
+
 static int luat_pm_msg_handler(lua_State *L, void* ptr) {
     rtos_msg_t* msg = (rtos_msg_t*)lua_topointer(L, -1);
     if (lua_event_cb == 0) {
@@ -196,7 +230,9 @@ static const rotable_Reg reg_pm[] =
     // { "release" ,       l_pm_release,  0},
     { "dtimerStart",    l_pm_dtimer_start,0},
     { "dtimerStop" ,    l_pm_dtimer_stop, 0},
-	{ "dtimerCheck" ,    l_pm_dtimer_check, 0},
+	{ "dtimerCheck" ,   l_pm_dtimer_check, 0},
+    { "dtimerList",     l_pm_dtimer_list, 0 },
+    { "dtimerWkId",     l_pm_dtimer_wakeup_id, 0},
     //{ "on",             l_pm_on,   0},
     { "force",          l_pm_force, 0},
     { "check",          l_pm_check, 0},