Skip to content

Commit f98d69d

Browse files
committed
changed message handling, added light & screen operations, updated API
1 parent 5db5568 commit f98d69d

18 files changed

+694
-164
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# `mikro`
22
[![Go Reference](https://pkg.go.dev/badge/github.com/antoi-ne/mikro.svg)](https://pkg.go.dev/github.com/antoi-ne/mikro)
33

4-
Go driver for the Native Instruments Maschine Mikro Mk3.
4+
Go driver for the Native Instruments [Maschine Mikro Mk3](https://www.native-instruments.com/en/products/maschine/production-systems/maschine-mikro/).

api/mk3/mk3.bitproto

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,13 @@ message LightState {
3838
ColoredLight[39] buttons = 2
3939
ColoredLight[16] pads = 3
4040
ColoredLight[35] strip = 4
41+
}
42+
43+
message ScreenState {
44+
option max_bytes = 265
45+
46+
byte[3] magic1 = 1
47+
byte screen_portion = 2
48+
byte[5] magic2 = 3
49+
byte[256] pixels = 4
4150
}

api/mk3/mk3_bp.go

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

button.go

Lines changed: 85 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,108 @@
11
package mikro
22

3+
//go:generate go run golang.org/x/tools/cmd/stringer@latest -type=Button -trimprefix Button
34
type Button int
45

56
const (
67
// Browser Section
78

8-
ProjectButton Button = iota
9-
FavoritesButton
10-
BrowserButton
9+
ButtonProject Button = iota
10+
ButtonFavorites
11+
ButtonBrowser
1112

1213
// Edit section
1314

14-
VolumeButton
15-
SwingButton
16-
TempoButton
17-
PluginButton
18-
SamplingButton
15+
ButtonVolume
16+
ButtonSwing
17+
ButtonTempo
18+
ButtonPlugin
19+
ButtonSampling
1920

20-
ArrowLeftButton
21-
ArrowRightButton
21+
ButtonArrowLeft
22+
ButtonArrowRight
2223

2324
// Performance section
2425

25-
PitchButton
26-
ModButton
27-
PerformButton
28-
NotesButton
26+
ButtonPitch
27+
ButtonMod
28+
ButtonPerform
29+
ButtonNotes
2930

30-
GroupButton
31-
AutoButton
32-
LockButton
33-
NoteRepeatButton
31+
ButtonGroup
32+
ButtonAuto
33+
ButtonLock
34+
ButtonNoteRepeat
3435

3536
// Transport section
3637

37-
RestartButton
38-
EraseButton
39-
TapButton
40-
FollowButton
38+
ButtonRestart
39+
ButtonErase
40+
ButtonTap
41+
ButtonFollow
4142

42-
PlayButton
43-
RecButton
44-
StopButton
45-
ShiftButton
43+
ButtonPlay
44+
ButtonRec
45+
ButtonStop
46+
ButtonShift
4647

4748
// Pads section
4849

49-
FixedVelButton
50-
PadModeButton
51-
KeyboardButton
52-
ChordsButton
53-
StepButton
54-
55-
SceneButton
56-
PatternButton
57-
EventsButton
58-
VariationButton
59-
DuplicateButton
60-
SelectButton
61-
SoloButton
62-
MuteButton
63-
64-
EncoderButton
50+
ButtonFixedVel
51+
ButtonPadMode
52+
ButtonKeyboard
53+
ButtonChords
54+
ButtonStep
55+
56+
ButtonScene
57+
ButtonPattern
58+
ButtonEvents
59+
ButtonVariation
60+
ButtonDuplicate
61+
ButtonSelect
62+
ButtonSolo
63+
ButtonMute
64+
65+
ButtonEncoder
6566
)
67+
68+
type ButtonMessage struct {
69+
pressed uint64 // bitflag of all currently pressed buttons
70+
71+
encoderTouched bool
72+
encoderPosition uint8
73+
74+
stripPos1 uint8
75+
stripPos2 uint8
76+
}
77+
78+
func (b *ButtonMessage) IsButtonPressed(btn Button) bool {
79+
return b.pressed&(1<<btn) != 0
80+
}
81+
82+
func (b *ButtonMessage) PressedButtons() []Button {
83+
var pressed []Button
84+
85+
for idx := 0; idx < 64; idx++ {
86+
if b.pressed&(1<<idx) != 0 {
87+
pressed = append(pressed, Button(idx))
88+
}
89+
}
90+
91+
return pressed
92+
}
93+
94+
func (b *ButtonMessage) IsEncoderTouched() bool {
95+
return b.encoderTouched
96+
}
97+
98+
func (b *ButtonMessage) EncoderPosition() uint8 {
99+
return b.encoderPosition
100+
}
101+
102+
func (b *ButtonMessage) StripPosition() uint8 {
103+
return b.stripPos1
104+
}
105+
106+
func (b *ButtonMessage) StripSecondPosition() uint8 {
107+
return b.stripPos2
108+
}

button_message.go

Lines changed: 0 additions & 47 deletions
This file was deleted.

button_string.go

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)