Skip to content

Commit

Permalink
Simplified the code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
pjsg committed Apr 25, 2024
1 parent f017089 commit 3485019
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
4 changes: 2 additions & 2 deletions components/modules/rotary.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
}

Expand Down
9 changes: 0 additions & 9 deletions components/modules/rotary_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions components/modules/rotary_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3485019

Please sign in to comment.