Design Patterns for Lua and Norns

norns
#1

Are there any good resources for common patterns for programming UI (grid, screen, arc) on Norns? I’m back into developing new features for the FM7 library and it’s been long enough I forgot simple stuff like the following

  • A function that saves button state from a grid
  • A toggle rather than a momentary button
  • Define smaller grid areas of LEDs for specific controls
  • Recalling LED state on a grid
  • Dynamic parameter assignment for Arc encoders

I keep going back to the studies and reading example code each time. I’d like to have a solid pattern for these higher level concepts.

8 Likes
#2

Toggle is easy:

toggle = false

function key()
    toggle = not toggle
end
4 Likes
#3

I quite like this idea. Long, long time ago in my COBOL programming days ‘common’ routines / processes were shared around to save reinventing the wheel. I guess these could/would be self generated, ie if someone developing a script or part script and thinks ‘hang on a tick - this would be useful to flag up as a common process’ then log it/store it some where. Maybe a tag category of the Library? or similar

2 Likes
#4

Thanks! I forget that Lua has logical operators that look like English. But this is only half way there. I’ll start compiling a guide of high level UI examples and the ways I’ve found to hack through them. I will likely get things wrong and update these examples.

2 Likes