Skip to content

Instantly share code, notes, and snippets.

@trentgill
Created November 26, 2021 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trentgill/29b5d2c1a3dfedf0702fa0828ffff114 to your computer and use it in GitHub Desktop.
Save trentgill/29b5d2c1a3dfedf0702fa0828ffff114 to your computer and use it in GitHub Desktop.
teletype expansion initial concept
--- crow: teletype expansion
local TT = {}
--- hardware events
-- overload these fns so when setting the handlers, we activate
-- the ii-communication (to reduce ii traffic if unused)
TT.key = function(state) end
TT.param = function(volts) end
TT.input.trigger = function(n, state) end
TT.input.cv = function(state) end -- like .stream but with hysteresis
--- usb events
TT.keyboard = function(char, modifer_mask) end
TT.grid = function(x, y, state) end
TT.arc = function(n, delta) end
TT.midi = function(...) end
--- configuration
TT.takeover = function(state) end -- put screen in expander mode
TT.listen = function(channel, state) end -- manually activate listeners for elements: key, trigger, param, input, usb
--- actions
-- output.tr
TT.output.tr[n] = state
TT.output.tr[n].pulse()
TT.output.tr[n].time = pulse_seconds
-- output.cv
TT.output.cv[n] = volts
TT.output.cv[n].slew = slew_seconds
-- screen
TT.screen.level(level) -- set brightness for drawing commands
TT.screen.px(x,y) -- location
TT.screen.line(x,y,x,y) -- start/end points
TT.screen.rect(x,y,w,h) -- draws outline
TT.screen.fill(level) -- fills the most recent drawing (use after .rect)
TT.screen.move(x,y) -- move the text cursor to this location
TT.screen.font(scale) -- scales font size by integers (default = 1)
TT.screen.char(char) -- draw a character at the current location & move cursor to the right
TT.screen.string = function(str) str:gsub('.', TT.screen.char) end -- macro over char
--- usb.actions
TT.grid.level(x,y,s) -- draw a grid pixel
-- how to draw something more complex
-- object style could work, but requires more coordination
TT.arc.level(n,y,s) -- draw an arc pixel
-- add 'range' option. can ignore anti-aliasing (or support it on TT)
TT.midi.transport(msg) -- send a midi transport message 'start', 'stop' etc
-- do MIDI input-devices need other kinds of feedback?
--- screen example
-- super minimal API which can be composed for fun things:
-- draw a rectangle & fill it with a dim level
TT.screen.level(15) -- set pen to brightest
TT.screen.rect(2,2,40,32) -- draws the outline at brightest level
TT.screen.fill(1) -- paint the centre of the rectangle with dim light
-- draw a string of text
TT.screen.level(5) -- mid-low drawing level
TT.screen.move(5,35) -- set cursor to this location
TT.screen.string'hello!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment