-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtext_s.go
More file actions
52 lines (41 loc) · 1.03 KB
/
Copy pathtext_s.go
File metadata and controls
52 lines (41 loc) · 1.03 KB
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
package launchpad
import (
"gitlab.com/gomidi/midi"
)
type scrollingTextBuilderS struct {
Seq []byte
outputStream midi.Out
}
func (l *LaunchpadS) Text(color Color) ScrollingTextBuilder {
return l.text(color, false)
}
func (l *LaunchpadS) TextLoop(color Color) ScrollingTextBuilder {
return l.text(color, true)
}
func (l *LaunchpadS) text(color Color, loop bool) ScrollingTextBuilder {
c := color.AsBytes()[0]
if loop {
c += 64
}
return &scrollingTextBuilderS{
Seq: []byte{0xF0, 0x00, 0x20, 0x29, 0x09, c},
outputStream: l.outputStream,
}
}
func (s *scrollingTextBuilderS) Add(speed byte, text string) ScrollingTextBuilder {
if speed > 7 {
speed = 7
} else if speed < 1 {
speed = 1
}
s.Seq = append(s.Seq, speed)
s.Seq = append(s.Seq, []byte(text)...)
return s
}
func (s *scrollingTextBuilderS) Perform() error {
s.Seq = append(s.Seq, 0xF7)
// the syntax of the scrolling text message:
// F0 00 20 29 09 <colour> <text inclusive speed ...> F7
_, err := s.outputStream.Write(s.Seq)
return err
}