Skip to content

Commit 5242dd3

Browse files
committed
some fixes and improvements
1 parent 3a361c7 commit 5242dd3

File tree

3 files changed

+39
-22
lines changed

3 files changed

+39
-22
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ Successfully tested with Ubuntu 18.04-LTS+. Requires compiling your own PyGame t
8888
---
8989
## NEWS
9090

91+
### CHANGES 2020/09/XX:
92+
- fixed sending command to not ready Pro Mk3
93+
- fixed MF64 LedCtrlString() to correctly work with the background color
94+
- updated hello.py demo file for Midi Fighter 64
95+
- updated demo files to new and recommended default device search strategy
96+
97+
9198
### CHANGES 2020/08/XX:
9299
- added support for pressure events via ButtonStateRaw() for the Pro and Pro Mk3
93100
- added support for pressure events via ButtonStateRaw() for the X
@@ -304,13 +311,12 @@ Successfully tested with Ubuntu 18.04-LTS+. Requires compiling your own PyGame t
304311
- "PK3": the Pro Mk3 has some issues; needs to be fixed
305312
- "All": optionally pressure events also for ButtonStateXY(); Pro, Pro Mk3, X
306313
- "All": optionally avoid resetting the X and Pro Mk3 to Live mode in Close(); (bc LEDs turn on)
307-
- "All": New, officially recommended device selection code in all demo files
308-
- "M64": Add character and string methods for the Midi Fighter
314+
- "FNT": fix character set; e.g. "!", "0", "N" and probably many more
309315
- "All": RGB to color code approximation (for flash/pulse and color code methods)
310-
- "Pro": Finally add the Mk3Pro (has problems!)
311316
- "All": either remove or add the (non-) optional \<colorcode\> argument to all methods
312317
- "DCR": query mode
313318
- "All": native scrolling for RGB pads
319+
- "All": split the doc in smaller, readable parts
314320
- "CXL": x/y support (if it makes sense...)
315321
- "All": LedCtrlChar() make y-offset work
316322
- "Pro": change ButtonStateXY() to return True/False + velocity, as in the LaunchKeyMini

examples/hello.py

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
# Quick usage of "launchpad.py", LEDs and buttons.
44
# Works with all Launchpads: Mk1, Mk2, Mini Mk3, S/Mini, Pro, Pro Mk3, XL and LaunchKey
5+
# And these: Midifighter 64
56
#
67
#
78
# FMMT666(ASkr) 7/2013..8/2020
@@ -26,17 +27,14 @@ def main():
2627

2728
mode = None
2829

29-
# create an instance
30-
lp = launchpad.Launchpad()
31-
32-
# check what we have here and override lp if necessary
33-
if lp.Check( 0, "pad pro" ):
30+
# create an instance for the Pro
31+
if launchpad.LaunchpadPro().Check( 0 ):
3432
lp = launchpad.LaunchpadPro()
35-
if lp.Open(0,"pad pro"):
33+
if lp.Open( 0 ):
3634
print("Launchpad Pro")
3735
mode = "Pro"
3836

39-
elif lp.Check( 0, "promk3" ):
37+
elif launchpad.LaunchpadProMk3().Check( 0 ):
4038
lp = launchpad.LaunchpadProMk3()
4139
if lp.Open( 0 ):
4240
print("Launchpad Pro Mk3")
@@ -45,7 +43,7 @@ def main():
4543
# experimental MK3 implementation
4644
# The MK3 has two MIDI instances per device; we need the 2nd one.
4745
# If you have two MK3s attached, its "1" for the first and "3" for the 2nd device
48-
elif lp.Check( 1, "minimk3" ):
46+
elif launchpad.LaunchpadMiniMk3().Check( 1 ):
4947
lp = launchpad.LaunchpadMiniMk3()
5048
if lp.Open( 1, "minimk3" ):
5149
print("Launchpad Mini Mk3")
@@ -54,37 +52,44 @@ def main():
5452
# experimental LPX implementation
5553
# Like the Mk3, the LPX also has two MIDI instances per device; we need the 2nd one.
5654
# If you have two LPXs attached, its "1" for the first and "3" for the 2nd device
57-
elif lp.Check( 1, "lpx" ):
55+
elif launchpad.LaunchpadLPX().Check( 1 ):
5856
lp = launchpad.LaunchpadLPX()
5957
if lp.Open( 1, "lpx" ):
6058
print("Launchpad X")
6159
mode = "Pro"
6260

63-
elif lp.Check( 0, "mk2" ):
61+
elif launchpad.LaunchpadMk2().Check( 0 ):
6462
lp = launchpad.LaunchpadMk2()
6563
if lp.Open( 0, "mk2" ):
6664
print("Launchpad Mk2")
6765
mode = "Mk2"
6866

69-
elif lp.Check( 0, "control xl" ):
67+
elif launchpad.LaunchControlXL().Check( 0 ):
7068
lp = launchpad.LaunchControlXL()
7169
if lp.Open( 0, "control xl" ):
7270
print("Launch Control XL")
7371
mode = "XL"
7472

75-
elif lp.Check( 0, "launchkey" ):
73+
elif launchpad.LaunchKeyMini().Check( 0 ):
7674
lp = launchpad.LaunchKeyMini()
7775
if lp.Open( 0, "launchkey" ):
7876
print("LaunchKey (Mini)")
7977
mode = "LKM"
8078

81-
elif lp.Check( 0, "dicer" ):
79+
elif launchpad.Dicer().Check( 0 ):
8280
lp = launchpad.Dicer()
8381
if lp.Open( 0, "dicer" ):
8482
print("Dicer")
8583
mode = "Dcr"
86-
84+
85+
elif launchpad.MidiFighter64().Check( 0 ):
86+
lp = launchpad.MidiFighter64()
87+
if lp.Open( 0 ):
88+
print("Midi Fighter 64")
89+
mode = "MF64"
90+
8791
else:
92+
lp = launchpad.Launchpad()
8893
if lp.Open():
8994
print("Launchpad Mk1/S/Mini")
9095
mode = "Mk1"
@@ -94,12 +99,15 @@ def main():
9499
return
95100

96101

97-
# scroll "HELLO" from right to left
102+
# scroll a string from right to left
98103
if mode == "Mk1":
99-
lp.LedCtrlString( "HELLO ", 0, 3, -1 )
104+
lp.LedCtrlString( "HENLO!", 0, 3, -1 )
105+
# the MF64's methods are not compatible with the Launchpad ones
106+
elif mode == "MF64":
107+
lp.LedCtrlString( "HENLO!", 5, 0, -1, waitms = 50 )
100108
# for all others except the XL and the LaunchKey
101109
elif mode != "XL" and mode != "LKM" and mode != "Dcr":
102-
lp.LedCtrlString( "HELLO ", 0, 63, 0, -1 )
110+
lp.LedCtrlString( "HENLO!", 0, 63, 0, -1, waitms = 50 )
103111

104112

105113
# random output
@@ -129,6 +137,8 @@ def main():
129137
lp.LedCtrlRaw( random.randint(0,127), random.randint(0,3), random.randint(0,3) )
130138
elif mode == "Dcr":
131139
lp.LedCtrlRaw( random.randint(0,130), random.randint(0,7), random.randint(0,15) )
140+
elif mode == "MF64":
141+
lp.LedCtrlRaw( random.randint(36,99), random.randint(0,127) )
132142
elif mode != "LKM":
133143
lp.LedCtrlRaw( random.randint(0,127), random.randint(0,63), random.randint(0,63), random.randint(0,63) )
134144

launchpad_py/launchpad.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3007,7 +3007,7 @@ def LedCtrlString( self, string, colorcode, coloroff=0, direction = None, waitms
30073007
# TODO: not a good idea :)
30083008
for i in string:
30093009
for n in range(4): # pseudo repetitions to compensate the timing a bit
3010-
self.LedCtrlChar(i, colorcode)
3010+
self.LedCtrlChar(i, colorcode, coloroff = coloroff)
30113011
time.wait(waitms)
30123012

30133013

@@ -3388,7 +3388,8 @@ def Reset( self ):
33883388
#-------------------------------------------------------------------------------------
33893389
def Close( self ):
33903390
# re-enter Live mode
3391-
self.LedSetMode( 0 )
3391+
if self.midi.devIn != None and self.midi.devOut != None:
3392+
self.LedSetMode( 0 )
33923393
# TODO: redundant (but needs fix for Py2 embedded anyway)
33933394
# self.midi.CloseInput()
33943395
# self.midi.CloseOutput()

0 commit comments

Comments
 (0)