robbielyman / seamstress

seamstress is an art engine
GNU General Public License v3.0
123 stars 12 forks source link

fix arc led index wrap #108

Closed p3r7 closed 9 months ago

p3r7 commented 9 months ago

before this change:

this PR implements wrapping of the led index (modulo 64, 1-indexed), akin to what norns does.

to test:


-- ------------------------------------------------------------------------
-- state

local a = nil

radial_pos = 1

-- ------------------------------------------------------------------------
-- init

local arc_redraw_clock
local ARC_FPS = 60

function init()
  a = arc.connect()

  arc_redraw_clock = clock.run(
    function()
      local step_s = 1 / ARC_FPS
      while true do
        clock.sleep(step_s)
        arc_redraw()
      end
  end)
end

-- ------------------------------------------------------------------------
-- main

function arc_redraw()

  -- spills over next ring after 64
  radial_pos = radial_pos + 1

  -- crashes
  -- radial_pos = radial_pos - 1

  a:all(0)

  a:led(1, radial_pos, 10)

  a:refresh()
end
p3r7 commented 9 months ago

also please note that my fix is in the lua layer. doing it in the zig might be a better idea, idk.

robbielyman commented 9 months ago

thanks for catching this! it's no trouble to wrap in zig, so i figured why not.