Last active
November 15, 2018 04:18
-
-
Save okyeron/e7e2e94393f69937fa16a4f82dffc3f5 to your computer and use it in GitHub Desktop.
clARCk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- clARCk port | |
-- for arc-dev branch | |
-- original maxpat by JP | |
-- https://github.com/monome-community/collected/tree/master/clarck | |
-- engine.name = 'TestSine' | |
local steps = {} | |
local aleds = {{},{},{},{}} | |
local position = 1 | |
localintensity = 1 | |
local ar = arc.connect() | |
function init() | |
counter = metro.alloc() | |
counter.time = 1/64 -- interval | |
counter.count = -1 -- run how long | |
counter.callback = count | |
counter:start() | |
mcount = 0 | |
lastsec = 0 | |
ar.all(0) | |
arc_redraw() | |
end | |
function count() | |
now = os.date("*t") | |
mcount = mcount+1 | |
--print (mcount) | |
--print (now) | |
-- add a tick to led array each second | |
-- what hour/min/second are we? | |
hour = now.hour | |
mins = now.min | |
secs = now.sec | |
if (secs > lastsec) or (secs == 0) then | |
mcount = 0 | |
end | |
msecs = mcount | |
lastsec = secs | |
ar.all(0) | |
for i=1,64 do | |
if i < math.floor(hour*5) then aleds[1][i] = 15 end | |
if i < mins then aleds[2][i] = 15 end | |
if i < secs then aleds[3][i] = 15 end | |
if i < msecs then aleds[4][i] = 15 end | |
end | |
-- ar.led(1, hour, 15) | |
-- ar.led(2, mins, 15) | |
-- ar.led(3, secs, 15) | |
for key,value in ipairs(aleds[1]) do ar.led(1, key, value) end | |
for key,value in ipairs(aleds[2]) do ar.led(2, key, value) end | |
for key,value in ipairs(aleds[3]) do ar.led(3, key, value) end | |
for key,value in ipairs(aleds[4]) do ar.led(4, key, value) end | |
if hour == 0 then | |
aleds[1] = {} | |
end | |
if mins == 0 then | |
aleds[2] = {} | |
end | |
if secs == 0 then | |
aleds[3] = {} | |
end | |
if msecs == 0 then | |
aleds[4] = {} | |
end | |
-- | |
arc_redraw() | |
end | |
function ar.event(n, z, typ) | |
--aleds[n] = math.random(64) | |
print (n) | |
print (z) | |
print (typ) | |
--ar.all(0) | |
for i=1,64 do | |
-- ar.led(n, i, math.floor(i/4)) | |
end | |
end | |
function arc_redraw() | |
-- redraw | |
ar.refresh() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment