-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdemo.lua
110 lines (92 loc) · 1.89 KB
/
demo.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
-- shbobo shnth demo
-- by @cfd90
--
-- prints out shnth values
-- connect shnth on HID slot 1
local shnth = include("shnth/lib/shnth")
-- Data for display.
local bars = {0, 0, 0, 0}
local corps = {0, 0}
local majors = {0, 0, 0, 0}
local minors = {0, 0, 0, 0}
local wind = 0
function init()
-- Connect shnth.
s = hid.connect()
s.event = shnth.event
-- Update screen timer.
screen_metro = metro.init()
screen_metro.event = function()
redraw()
end
screen_metro:start(1/15)
end
function shnth.bar(n, d)
-- bar input, always firing
-- n bar index
-- d bar depth
bars[n] = d
end
function shnth.corp(n, d)
-- corp input, always firing
-- n corp index
-- d corp depth
corps[n] = d
end
function shnth.major(n, z)
-- major buttons, fires on touch
-- n button index
-- z button state
majors[n] = z
end
function shnth.minor(n, z)
-- minor buttons, fires on touch
-- n button index
-- z button state
minors[n] = z
end
function shnth.wind(d)
-- wind input, always firing
-- d wind depth
wind = v
end
function redraw()
screen.clear()
screen.move(1, 10)
screen.level(1)
screen.text("shbobo shnth demo")
screen.move(1, 20)
screen.level(15)
screen.text("bars: ")
for i=1,4 do
screen.level(3)
screen.text(math.floor(bars[i] * 10) / 10 .. " ")
end
screen.move(1, 30)
screen.level(15)
screen.text("corps: ")
for i=1,2 do
screen.level(3)
screen.text(math.floor(corps[i] * 10) / 10 .. " ")
end
screen.move(1, 40)
screen.level(15)
screen.text("minors: ")
for i=1,4 do
screen.level(3)
screen.text(minors[i] .. " ")
end
screen.move(1, 50)
screen.level(15)
screen.text("majors: ")
for i=1,4 do
screen.level(3)
screen.text(majors[i] .. " ")
end
screen.move(1, 60)
screen.level(15)
screen.text("wind: ")
screen.level(3)
screen.text(math.floor(wind * 10) / 10)
screen.update()
end