-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Matrix keyboard module #3631
base: dev-esp32
Are you sure you want to change the base?
Matrix keyboard module #3631
Conversation
int character = -1; | ||
|
||
// We are either waiting for a negative edge (keypress) or a positive edge | ||
// (keyrelease) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is confusing me - we just disabled row interrupts, so why would we be waiting for an edge?
QUEUE_IT(d, character); | ||
if (!d->task_queued) { | ||
if (task_post_medium(tasknumber, (task_param_t)d)) { | ||
d->task_queued = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe d->task_queued
needs to be mutex protected, as it gets written by both the GPIO ISR/task as well as the NodeMCU task.
if (*cb_ptr != LUA_NOREF) { | ||
luaL_unref(L, LUA_REGISTRYINDEX, *cb_ptr); | ||
*cb_ptr = LUA_NOREF; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be neater with luaL_unref2()
instead.
|
||
typedef struct { | ||
int32_t character; // 1 + character for press, -1 - character for release | ||
uint32_t time_us; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field never appears to be filled in, but is used in the callback.
|
||
if (!HAS_QUEUED_DATA(d)) { | ||
luaL_unref(L, LUA_REGISTRYINDEX, d->self_ref); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be tempted to change this to a task_post so we only have a single place where we release the self_ref, for easier reasoning.
callback_free(L, d, MATRIX_ALL); | ||
|
||
if (matrix_close( d )) { | ||
return luaL_error( L, "Unable to close switch." ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch?
@@ -0,0 +1,77 @@ | |||
# matrix Module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would a better name be matrixkdb
even? There are many types of matrices, I mean.
Ah, one other review comment - the documentation needs to be linked in |
Fixes #3630
dev
branch rather than for therelease
branch.docs/*
.This adds the
matrix
module which supports simple matrix keypads. Simple interface -- it just calls a specified callback on key press (and/or key release).