diff --git a/components/modules/rotary.c b/components/modules/rotary.c index 7686557b0..7ca2e4f9c 100644 --- a/components/modules/rotary.c +++ b/components/modules/rotary.c @@ -190,7 +190,7 @@ static void update_self_ref(lua_State *L, DATA *d, int argnum) { d->self_ref = luaL_ref(L, LUA_REGISTRYINDEX); } } else { - if (d->self_ref != LUA_NOREF) { + if (d->self_ref != LUA_NOREF && !rotary_has_queued_event(d->handle)) { luaL_unref(L, LUA_REGISTRYINDEX, d->self_ref); d->self_ref = LUA_NOREF; } @@ -205,7 +205,7 @@ static int lrotary_close( lua_State* L ) if (d->handle) { callback_free(L, d, ROTARY_ALL); - if (!rotary_has_queued_task(d->handle)) { + if (!rotary_has_queued_event(d->handle)) { update_self_ref(L, d, 1); } diff --git a/components/modules/rotary_driver.c b/components/modules/rotary_driver.c index 702530876..934175cfb 100644 --- a/components/modules/rotary_driver.c +++ b/components/modules/rotary_driver.c @@ -175,15 +175,6 @@ void rotary_event_handled(rotary_driver_handle_t d) d->task_queued = 0; } -bool rotary_has_queued_task(rotary_driver_handle_t d) { - if (!d) { - return false; - } - - return d->task_queued; -} - - // The pin numbers are actual platform GPIO numbers rotary_driver_handle_t rotary_setup(int phase_a, int phase_b, int press, task_handle_t tasknumber, void *arg) { diff --git a/components/modules/rotary_driver.h b/components/modules/rotary_driver.h index 1b04f8b79..5d805009f 100644 --- a/components/modules/rotary_driver.h +++ b/components/modules/rotary_driver.h @@ -25,6 +25,4 @@ int rotary_close(struct rotary_driver_handle *handle); void rotary_event_handled(struct rotary_driver_handle *handle); -bool rotary_has_queued_task(struct rotary_driver_handle *handle); - #endif