miker2049 / midigrid

A helper library for midi grids and monome norns
GNU General Public License v3.0
63 stars 36 forks source link

Launchpad Pro support (and a bunch of refactoring) #2

Closed tildebyte closed 4 years ago

tildebyte commented 4 years ago

@miker2049 - PTAL! I started out wanting to support the LP Pro, and ended up doing a lot more :P

I'd suggest reviewing commit-by-commit, as the final diffs are too different to reason about easily.

I'm a Pythonista by trade and by calling, so I have to tell you that learning Lua has been PAINFUL. I tried to avoid making changes just for the sake of making changes, or to look at it another way, I only made changes which I felt would help (me and others) when trying to reason about the data structures and logic herein.

I could only test with my LP Pro - I have no other devices. OTOH e.g. Loom is a pretty complex script, grid-display-wise, and works perfectly, so I feel pretty good about this PR, ie. that it should work OOB for other devices.

Changes which aren't strictly for the LP Pro:

timm052 commented 4 years ago

Thanks for the work esspecially on sysex and you also seem to have solved the button latching issue just had a quick look on my launchpad mk2 and the pro config file actully works with sysex commands with very minor changes to the profile. The only issue i've come across is trying to run a script with the launchpad disconnected casues loading the script to fail with this error which is not ideal if you're not using the norns with the launchpad.

# script load: /home/we/dust/code/awake/awake.lua
# cleanup
# script clear
including /home/we/dust/code/awake/lib/halfsecond.lua
including /home/we/dust/code/midigrid/lib/midigrid.lua
No supported device found
### MISSING INCLUDE: none
### SCRIPT ERROR: load fail
/home/we/dust/code/midigrid/lib/midigrid.lua:30: MISSING INCLUDE: none
stack traceback:
    /home/we/norns/lua/core/norns.lua:126: in function </home/we/norns/lua/core/norns.lua:126>
    [C]: in function 'error'
    /home/we/norns/lua/core/startup.lua:45: in function 'include'
    /home/we/dust/code/midigrid/lib/midigrid.lua:30: in main chunk
    [C]: in function 'dofile'
    /home/we/norns/lua/core/startup.lua:42: in function 'include'
    /home/we/dust/code/awake/awake.lua:44: in main chunk
    [C]: in function 'dofile'
    /home/we/norns/lua/core/script.lua:149: in function </home/we/norns/lua/core/script.lua:149>
    [C]: in function 'xpcall'
    /home/we/norns/lua/core/norns.lua:127: in field 'try'
    /home/we/norns/lua/core/script.lua:149: in function 'core/script.load'
    /home/we/norns/lua/core/menu/preview.lua:21: in function 'core/menu/preview.key'
    /home/we/norns/lua/core/menu.lua:139: in function </home/we/norns/lua/core/menu.lua:116>
# script clear
tildebyte commented 4 years ago

Thanks for the work esspecially on sysex and you also seem to have solved the button latching issue just had a quick look on my launchpad mk2 and the pro config file actully works with sysex commands with very minor changes to the profile.

Awesome!

The only issue i've come across is trying to run a script with the launchpad disconnected casues loading the script to fail with this error which is not ideal if you're not using the norns with the launchpad.

I never even thought to try it without an LP plugged in; I was too busy trying to get it to work :P

I'll definitely take a look at trapping this so it's possible to modify a script to use a launchpad, but is not necessary for it to work (i.e. same behavior as a monome grid)