From 493083d8faf92dfb39eeb4bcbc4e2a36b1eead63 Mon Sep 17 00:00:00 2001 From: Manuel Cartagena Date: Mon, 8 Aug 2022 12:17:10 -0400 Subject: [PATCH 1/2] Add midigrid and animation toggle button in toolbar --- gridstep.lua | 22 ++++++++++++++++++++-- lib/Q7GridKeys.lua | 21 ++++++++++++--------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/gridstep.lua b/gridstep.lua index 3a0b453..edf131c 100755 --- a/gridstep.lua +++ b/gridstep.lua @@ -80,7 +80,7 @@ local fileselect = require 'fileselect' 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 @@ -695,6 +695,18 @@ function toggle_playback() end end +function toggle_animation() + for i, gKey in pairs(all_gridKeys) do + if gKey.animation then + gKey.animation = false + show_temporary_notification("Animation Off") + else + gKey.animation = true + show_temporary_notification("Animation On") + end + end +end + function clock.transport.start() -- print("we begin") -- position = 16 @@ -1202,6 +1214,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 +1250,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") @@ -4745,4 +4763,4 @@ function PageMicroTiming.redraw() screen.level(gridSeq:get_triplet_mode() and 15 or 3) screen.move(128-2,60) screen.text_right("Triplet Mode [K3]") -end \ No newline at end of file +end 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 From 21f37749e41197ddab53a6433de559521bbfae47 Mon Sep 17 00:00:00 2001 From: Manuel Cartagena Date: Mon, 8 Aug 2022 14:49:45 -0400 Subject: [PATCH 2/2] Add animation led toggle --- gridstep.lua | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) mode change 100755 => 100644 gridstep.lua diff --git a/gridstep.lua b/gridstep.lua old mode 100755 new mode 100644 index edf131c..d94901d --- a/gridstep.lua +++ b/gridstep.lua @@ -80,7 +80,8 @@ local fileselect = require 'fileselect' local textentry = require 'textentry' -local grid = util.file_exists(_path.code.."midigrid") and include "midigrid/lib/mg_128" or grid + +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 @@ -699,9 +701,11 @@ 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 @@ -2756,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) @@ -3041,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) @@ -4763,4 +4787,4 @@ function PageMicroTiming.redraw() screen.level(gridSeq:get_triplet_mode() and 15 or 3) screen.move(128-2,60) screen.text_right("Triplet Mode [K3]") -end +end \ No newline at end of file