Skip to content

Commit b03c743

Browse files
committed
updated the X names; X support in all rgb demos
1 parent 0941c38 commit b03c743

File tree

5 files changed

+100
-27
lines changed

5 files changed

+100
-27
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ What's hot, what's not?
4141

4242
Launchpad Mini Mk3 - class "LaunchpadMiniMk3()" LEDs and buttons *** RENAMED 5/2020 ***
4343

44-
Launchpad X - class "LaunchpadLPX()" EXPERIMENTAL
44+
Launchpad X - class "LaunchpadLPX()" EXPERIMENTAL++ as in "should work"
4545

4646
Launch Control - class "LaunchControl()" EXPERIMENTAL
4747

@@ -76,6 +76,8 @@ Successfully tested with Ubuntu 18.04-LTS+. Requires compiling your own PyGame t
7676
### CHANGES 2020/08/XX:
7777
- added support for pressure events via ButtonStateRaw() for the Pro
7878
- added demo file "launchpad_pressure.py" for pressure sensitivity
79+
- added multiple search names for the X
80+
- updated all rgb-demos to work with the X
7981

8082
### CHANGES 2020/05/XX:
8183

@@ -1114,7 +1116,7 @@ Functions requiring a color code have a "...ByCode" naming style.
11141116
Launchpad() -> "Launchpad"
11151117
LaunchpadMk2() -> "Mk2"
11161118
LaunchpadMiniMk3() -> "MiniMk3"
1117-
LaunchpadLPX() -> "X"
1119+
LaunchpadLPX() -> "LPX" and "Launchpad X"
11181120
LaunchpadPro() -> "Launchpad Pro"
11191121
LaunchControl() -> "Control MIDI"
11201122
LaunchControlXL() -> "Control XL"
@@ -1201,7 +1203,7 @@ Functions requiring a color code have a "...ByCode" naming style.
12011203
Launchpad() -> "Launchpad"
12021204
LaunchpadMk2() -> "Mk2"
12031205
LaunchpadMiniMk3() -> "MiniMk3"
1204-
LaunchpadLPX() -> "X"
1206+
LaunchpadLPX() -> "LPX" and "Launchpad X"
12051207
LaunchpadPro() -> "Launchpad Pro"
12061208
LaunchControl() -> "Control MIDI"
12071209
LaunchControlXL() -> "Control XL"

examples/launchpad_rgb-fire.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env python
22
#
3-
# Launchpad Fire Demo for Mk2, Mini Mk3, Pro (and soon X)
3+
# Launchpad Fire Demo for Mk2, Mini Mk3, Pro, X
44
#
55
#
6-
# FMMT666(ASkr) 7/2013..5/2020
6+
# FMMT666(ASkr) 7/2013..8/2020
77
# www.askrprojects.net
88
#
99

@@ -328,7 +328,20 @@ def __init__( self ):
328328
else:
329329
print( " - Launchpad Pro: ERROR")
330330
return
331-
331+
332+
# try the first X
333+
# Notice that this is already built-in in the LPX class' methods Check() and Open,
334+
# but we're using the one from above!
335+
elif lp.Check( 1, "Launchpad X") or lp.Check( 1, "LPX" ):
336+
lp = launchpad.LaunchpadLPX()
337+
# Open() includes looking for "LPX" and "Launchpad X"
338+
if lp.Open( 1 ):
339+
print( " - Launchpad X: OK" )
340+
self.mode = "lpx"
341+
else:
342+
print( " - Launchpad X: ERROR")
343+
return
344+
332345
# nope
333346
else:
334347
raise Exception("No compatible Launchpad found. Only for Mk2, Mk3, Pro")
@@ -444,6 +457,8 @@ def ButtonFlush( self ):
444457
if buts[0:2] == [ 8, 8 ] and not buts[2]:
445458
a.SeedSetRow( 0.0 )
446459
# --- matrix button
460+
# TODO:
461+
# That does not workj for the X (always spits out this message)
447462
if 0 < buts[0] < 9 and 0 < buts[1] < 9 and not buts[2]:
448463
print("Don't push the matrix buttons. Might create a lag (pressure events).")
449464
# --- quit

examples/launchpad_rgb-pulse.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/python
22
#
33
# Stupid flashing/pulsing demo.
4-
# Works with Mk2, Mini Mk3, Pro (and soon X)
4+
# Works with Mk2, Mini Mk3, Pro, X
55
#
66
#
7-
# FMMT666(ASkr) 10/2018..5/2020
7+
# FMMT666(ASkr) 10/2018..8/2020
88
# www.askrprojects.net
99
#
1010

@@ -48,6 +48,12 @@ def main():
4848
print("Launchpad Mk3")
4949
mode = "Mk3"
5050

51+
elif lp.Check( 1, "launchpad x" ) or lp.Check( 1, "lpx" ):
52+
lp = launchpad.LaunchpadLPX()
53+
if lp.Open( 1 ):
54+
print("Launchpad X")
55+
mode = "LPX"
56+
5157
if mode is None:
5258
print("Did not find any compatible Launchpads, meh...")
5359
return

examples/launchpad_rgb.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env python
22
#
3-
# Launchpad tests for RGB-style variants Mk2, Mini Mk3, Pro ...
3+
# Launchpad tests for RGB-style variants Mk2, Mini Mk3, Pro, X ...
44
#
55
#
6-
# FMMT666(ASkr) 7/2013..5/2020
6+
# FMMT666(ASkr) 7/2013..8/2020
77
# www.askrprojects.net
88
#
99

@@ -37,7 +37,7 @@ def main():
3737
print( " - PyGame " + str( pygame.ver ) )
3838

3939
# create an instance
40-
lp = launchpad.Launchpad();
40+
lp = launchpad.Launchpad()
4141

4242
# try the first Mk2
4343
if lp.Check( 0, "mk2" ):
@@ -65,7 +65,19 @@ def main():
6565
else:
6666
print( " - Launchpad Pro: ERROR")
6767
return
68-
68+
69+
# try the first X
70+
# Notice that this is already built-in in the LPX class' methods Check() and Open,
71+
# but we're using the one from above!
72+
elif lp.Check( 1, "Launchpad X") or lp.Check( 1, "LPX" ):
73+
lp = launchpad.LaunchpadLPX()
74+
# Open() includes looking for "LPX" and "Launchpad X"
75+
if lp.Open( 1 ):
76+
print( " - Launchpad X: OK" )
77+
else:
78+
print( " - Launchpad X: ERROR")
79+
return
80+
6981
# nope
7082
else:
7183
print( " - No Launchpad available" )

launchpad_py/launchpad.py

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,9 @@ def __init__( self ):
255255
self.SCROLL_LEFT = -1
256256
self.SCROLL_RIGHT = 1
257257

258-
259-
def __delete__( self ):
258+
# LOL; That fixes a years old bug. Officially an idiot now :)
259+
# def __delete__( self ):
260+
def __del__( self ):
260261
self.Close()
261262

262263

@@ -316,7 +317,7 @@ def ButtonFlush( self ):
316317
while doReads < 3:
317318
if self.midi.ReadCheck():
318319
doReads = 0
319-
a = self.midi.ReadRaw()
320+
self.midi.ReadRaw()
320321
else:
321322
doReads += 1
322323
time.wait( 5 )
@@ -1670,7 +1671,7 @@ def TemplateSet( self, templateNum ):
16701671
if templateNum < 1 or templateNum > 16:
16711672
return
16721673
else:
1673-
self.UserTemplate = template
1674+
self.UserTemplate = templateNum
16741675
self.midi.RawWriteSysEx( [ 0, 32, 41, 2, 17, 119, templateNum-1 ] )
16751676

16761677

@@ -2493,26 +2494,63 @@ class LaunchpadLPX( LaunchpadPro ):
24932494

24942495
#-------------------------------------------------------------------------------------
24952496
#-- Opens one of the attached Launchpad MIDI devices.
2496-
#-- Uses search string "LPX", by default.
2497+
#-- This is one of the few devices that has different names in different OSs:
2498+
#--
2499+
#-- Windoze
2500+
#-- (b'MMSystem', b'LPX MIDI', 1, 0, 0)
2501+
#-- (b'MMSystem', b'MIDIIN2 (LPX MIDI)', 1, 0, 0)
2502+
#-- (b'MMSystem', b'LPX MIDI', 0, 1, 0)
2503+
#-- (b'MMSystem', b'MIDIOUT2 (LPX MIDI)', 0, 1, 0)
2504+
#--
2505+
#-- macOS
2506+
#-- (b'CoreMIDI', b'Launchpad X LPX DAW Out', 1, 0, 0)
2507+
#-- (b'CoreMIDI', b'Launchpad X LPX MIDI Out', 1, 0, 0)
2508+
#-- (b'CoreMIDI', b'Launchpad X LPX DAW In', 0, 1, 0)
2509+
#-- (b'CoreMIDI', b'Launchpad X LPX MIDI In', 0, 1, 0)
2510+
#--
2511+
#-- Linux [tm]
2512+
#-- ('ALSA', 'Launchpad X MIDI 1', 0, 1, 0)
2513+
#-- ('ALSA', 'Launchpad X MIDI 1', 1, 0, 0)
2514+
#-- ('ALSA', 'Launchpad X MIDI 2', 0, 1, 0)
2515+
#-- ('ALSA', 'Launchpad X MIDI 2', 1, 0, 0)
2516+
#--
2517+
#-- So the old strategy of simply looking for "LPX" will not work.
2518+
#-- Workaround: If the user doesn't request a specific name, we'll just
2519+
#-- search for "Launchpad X" and "LPX"...
2520+
24972521
#-------------------------------------------------------------------------------------
24982522
# Overrides "LaunchpadPro" method
2499-
# TODO: Find a fix for the two MK3 MIDI devices
2500-
def Open( self, number = 0, name = "LPX" ):
2501-
retval = super( LaunchpadLPX, self ).Open( number = number, name = name )
2502-
if retval == True:
2503-
self.LedSetMode( 1 )
2504-
2505-
return retval
2523+
def Open( self, number = 0, name = "AUTO" ):
2524+
nameList = [ "Launchpad X", "LPX" ]
2525+
if name != "AUTO":
2526+
# mhh, better not this way
2527+
# nameList.insert( 0, name )
2528+
nameList = [ name ]
2529+
for name in nameList:
2530+
rval = super( LaunchpadLPX, self ).Open( number = number, name = name )
2531+
if rval:
2532+
self.LedSetMode( 1 )
2533+
return rval
2534+
return False
25062535

25072536

25082537
#-------------------------------------------------------------------------------------
25092538
#-- Checks if a device exists, but does not open it.
25102539
#-- Does not check whether a device is in use or other, strange things...
2511-
#-- Uses search string "LPX", by default.
2540+
#-- See notes in "Open()" above.
25122541
#-------------------------------------------------------------------------------------
25132542
# Overrides "LaunchpadBase" method
2514-
def Check( self, number = 0, name = "LPX" ):
2515-
return super( LaunchpadLPX, self ).Check( number = number, name = name )
2543+
def Check( self, number = 0, name = "AUTO" ):
2544+
nameList = [ "Launchpad X", "LPX" ]
2545+
if name != "AUTO":
2546+
# mhh, better not this way
2547+
# nameList.insert( 0, name )
2548+
nameList = [ name ]
2549+
for name in nameList:
2550+
rval = super( LaunchpadLPX, self ).Check( number = number, name = name )
2551+
if rval:
2552+
return rval
2553+
return False
25162554

25172555

25182556
#-------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)