diff --git a/gridstep.lua b/gridstep.lua old mode 100755 new mode 100644 index 3a0b453..d94901d --- a/gridstep.lua +++ b/gridstep.lua @@ -81,6 +81,7 @@ local textentry = require 'textentry' +local grid = util.file_exists(_path.code .. "midigrid") and include "midigrid/lib/mg_128" or grid local g = grid.connect() local gridType_none = 0 @@ -212,6 +213,7 @@ local shift_down = false local track = 1 local is_playing = false +local animation = true local edit_steps_9_16 = false -- for 64x64 grids @@ -695,6 +697,20 @@ function toggle_playback() end end +function toggle_animation() + for i, gKey in pairs(all_gridKeys) do + if gKey.animation then + gKey.animation = false + animation = false + show_temporary_notification("Animation Off") + else + gKey.animation = true + animation = true + show_temporary_notification("Animation On") + end + end +end + function clock.transport.start() -- print("we begin") -- position = 16 @@ -1202,6 +1218,9 @@ function grid_key_toolbar_128( x, y, z) change_grid_page("GridSeq") grid_dirty = true end + elseif x == 6 then -- Toggle animation + toggle_animation() + grid_dirty = true end end else -- key released @@ -1235,6 +1254,9 @@ function grid_key_toolbar_64( x, y, z) local new_page = (config.grid_page_index % 3) + 1 change_grid_page(grid_page_names[new_page]) grid_dirty = true + elseif x == 4 then -- Toggle animation + toggle_animation() + grid_dirty = true elseif x == 7 then -- edit steps 1-8 edit_steps_9_16 = false show_temporary_notification("Edit 1-8") @@ -2738,8 +2760,18 @@ function grid_draw_toolbar() g:led(3,toolY, config.grid_page_index == 1 and mode_on_brightness or mode_off_brightness) -- play mode active g:led(4,toolY, config.grid_page_index == 2 and mode_on_brightness or mode_off_brightness) -- pat launch mode not active g:led(5,toolY, config.grid_page_index == 3 and mode_on_brightness or mode_off_brightness) -- step mode not active + if animation then + g:led(6, toolY, mode_on_brightness) -- animation active + else + g:led(6, toolY, mode_off_brightness) -- animation inactive + end elseif gridType == gridType_64 then g:led(3,toolY, mode_on_brightness) + if animation then + g:led(4, toolY, mode_on_brightness) -- animation active + else + g:led(4, toolY, mode_off_brightness) -- animation inactive + end g:led(7,toolY, edit_steps_9_16 and mode_off_brightness or mode_on_brightness) g:led(8,toolY, edit_steps_9_16 and mode_on_brightness or mode_off_brightness) @@ -3023,9 +3055,19 @@ function grid_draw_param_edit(edit_type) g:led(3,toolY,edit_type == 1 and mode_on_brightness or mode_off_brightness) g:led(4,toolY,edit_type == 2 and mode_on_brightness or mode_off_brightness) g:led(5,toolY,edit_type == 3 and mode_on_brightness or mode_off_brightness) + if animation then + g:led(6, toolY, mode_on_brightness) -- animation active + else + g:led(6, toolY, mode_off_brightness) -- animation inactive + end elseif gridType == gridType_64 then g:led(1,toolY,mode_off_brightness) g:led(3,toolY,mode_on_brightness) + if animation then + g:led(4, toolY, mode_on_brightness) -- animation active + else + g:led(4, toolY, mode_off_brightness) -- animation inactive + end g:led(7,toolY, edit_steps_9_16 and mode_off_brightness or mode_on_brightness) g:led(8,toolY, edit_steps_9_16 and mode_on_brightness or mode_off_brightness) diff --git a/lib/Q7GridKeys.lua b/lib/Q7GridKeys.lua index abb9198..006e11e 100644 --- a/lib/Q7GridKeys.lua +++ b/lib/Q7GridKeys.lua @@ -59,6 +59,7 @@ function Q7GridKeys.new(width,height) gk.enable_note_highlighting = true gk.enable_key_playback = true + gk.animation = true gk.lit_keys = {} @@ -351,15 +352,17 @@ function Q7GridKeys:animate() end function Q7GridKeys:anim_set_leds(step_position, x, y) - local pixels = ripple_anim[step_position] - local brightness = math.floor(util.linlin(1,8,5,1,step_position)) - - for i=1,#pixels do - local pixel = pixels[i] - self:set_anim_grid(x + pixel[1], y + pixel[2], brightness) - self:set_anim_grid(x - pixel[1], y + pixel[2], brightness) - self:set_anim_grid(x - pixel[1], y - pixel[2], brightness) - self:set_anim_grid(x + pixel[1], y - pixel[2], brightness) + if self.animation then + local pixels = ripple_anim[step_position] + local brightness = math.floor(util.linlin(1,8,5,1,step_position)) + + for i=1,#pixels do + local pixel = pixels[i] + self:set_anim_grid(x + pixel[1], y + pixel[2], brightness) + self:set_anim_grid(x - pixel[1], y + pixel[2], brightness) + self:set_anim_grid(x - pixel[1], y - pixel[2], brightness) + self:set_anim_grid(x + pixel[1], y - pixel[2], brightness) + end end end