Drum rack and lights firmware examples #1

Open
flpvsk wants to merge 3 commits from flpvsk/neogrid:example/drum-rack into main
First-time contributor
  • Add two firware examples;
  • Update firmware dev instructions based on the issues I had
* Add two firware examples; * Update firmware dev instructions based on the issues I had
flpvsk force-pushed example/drum-rack from 860b195765 to e59e2818bf 2026-04-11 15:07:15 +02:00 Compare
flpvsk force-pushed example/drum-rack from e59e2818bf to 9c57c04a00 2026-04-11 23:32:16 +02:00 Compare
@ -0,0 +145,4 @@
if not col_pin.value():
pressed_keys.add(key)
row_pin.value(1)
return set(pressed_keys)
Owner

This is a (minor) memory leak allocation inefficiency as it will create a new set object on every loop iteration. It's fine to return pressed_keys directly.

This is a (minor) memory ~~leak~~ allocation inefficiency as it will create a new `set` object on every loop iteration. It's fine to return `pressed_keys` directly.
Author
First-time contributor

Yes, makes sense to remove it. Out of curiousity, shouldn't python take care of cleaning up that memory once the references to the new set go out of scope? just saw your correction :)

Also, not sure if it's overoptimizing things, but we could use a single integer instead of a set here. Each bit representing an on/off state of a btn. We'd have to deal with bitwise operations, but the memory footprint would likely be smaller. Maybe the amount of cycles too?

E.g.

# no btns pressed
pressed_keys = 0

# btn 3 is pressed
pressed_keys = pressed_keys | (1 << 3)

# btn 4 is not pressed
pressed_keys = pressed_keys & ~(1 << 4)

# check if btn 2 is pressed
(pressed_keys >> 2) & 1

# set intersection
pressed_keys_1 & pressed_keys_2

# set difference
pressed_keys_1 & ~pressed_keys_2

# get all the pressed btns
pressed_list = []
for i in range(NUM_BTNS):
  if (pressed_keys >> i) & 1:
    pressed_list.append(i)
Yes, makes sense to remove it. ~Out of curiousity, shouldn't python take care of cleaning up that memory once the references to the new set go out of scope?~ just saw your correction :) Also, not sure if it's overoptimizing things, but we could use a single integer instead of a set here. Each bit representing an on/off state of a btn. We'd have to deal with bitwise operations, but the memory footprint would likely be smaller. Maybe the amount of cycles too? E.g. ```python # no btns pressed pressed_keys = 0 # btn 3 is pressed pressed_keys = pressed_keys | (1 << 3) # btn 4 is not pressed pressed_keys = pressed_keys & ~(1 << 4) # check if btn 2 is pressed (pressed_keys >> 2) & 1 # set intersection pressed_keys_1 & pressed_keys_2 # set difference pressed_keys_1 & ~pressed_keys_2 # get all the pressed btns pressed_list = [] for i in range(NUM_BTNS): if (pressed_keys >> i) & 1: pressed_list.append(i) ```
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u example/drum-rack:flpvsk-example/drum-rack
git switch flpvsk-example/drum-rack

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff flpvsk-example/drum-rack
git switch flpvsk-example/drum-rack
git rebase main
git switch main
git merge --ff-only flpvsk-example/drum-rack
git switch flpvsk-example/drum-rack
git rebase main
git switch main
git merge --no-ff flpvsk-example/drum-rack
git switch main
git merge --squash flpvsk-example/drum-rack
git switch main
git merge --ff-only flpvsk-example/drum-rack
git switch main
git merge flpvsk-example/drum-rack
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
viernullvier/neogrid!1
No description provided.