Skip to content

Commit df34cd4

Browse files
committed
added LED modes for the Midi FIghter 64
1 parent b99eaa3 commit df34cd4

File tree

2 files changed

+91
-15
lines changed

2 files changed

+91
-15
lines changed

README.md

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Did we mention [Python 3][18] yet?
2323

2424
First [Mk3][21] and [X][22] Launchpad code snippets running now (4/2020).
2525

26-
Now with (some) [Midi Fighter 64][23] support (8/2020).
26+
Now with full [Midi Fighter 64][23] support (8/2020).
2727

2828
Finally! Hehe, say hello to the [Mk3 Pro][24] (8/2020)
2929

@@ -56,7 +56,7 @@ What's hot, what's not?
5656

5757
Dicer - class "Dicer()" LEDs and buttons
5858

59-
Midi Fighter 64 - class "MidiFighter64" EXPERIMENTAL; LEDs and buttons
59+
Midi Fighter 64 - class "MidiFighter64" LEDs and buttons
6060

6161

6262
> PRO MK3 USERS:
@@ -109,6 +109,9 @@ Successfully tested with Ubuntu 18.04-LTS+. Requires compiling your own PyGame t
109109
- updated ButtonStateXY() for the Pro Mk3, incl "classic" and "Pro" mode
110110
- added character and string scrolling for Midi Fighter 64
111111
- added stupid Midi Fighter text scrolling demo
112+
- added MF64 LED-mode settings: brightness, toggling, flashing and animation settings
113+
- updated MF64 LedCtrlRaw() to accept LED-mode settings
114+
- updated MF64 LedAllOn() to optionally accept LED-mode settings
112115

113116

114117
### CHANGES 2020/05/XX:
@@ -1147,7 +1150,8 @@ Functions requiring a color code have a "...ByCode" naming style.
11471150

11481151
### LED functions
11491152

1150-
LedCtrlRaw( number, color)
1153+
LedCtrlRaw( number, color, [mode] )
1154+
LedCtrlRawMode( number, mode )
11511155
LedCtrlXY( x, y, color )
11521156
LedAllOn( [color] )
11531157
LedCtrlChar( char, color, [offsx], [offsy], [coloroff] )
@@ -1163,7 +1167,7 @@ Functions requiring a color code have a "...ByCode" naming style.
11631167
### Color codes
11641168

11651169
The Midi Fighter 64 only supports a color table.
1166-
There is no possibility to control the RGB LEDs individually.yle.
1170+
There is no possibility to control the RGB LEDs individually.
11671171

11681172
![RGB color palette](/images/mf64_colorcodes.png)
11691173

@@ -2293,18 +2297,56 @@ There is no possibility to control the RGB LEDs individually.yle.
22932297
<value> >0 = pressed; 0 = released
22942298

22952299

2296-
### LedCtrlRaw( <led>, <colorcode> )
2300+
### LedCtrlRaw( led, colorcode, [mode] )
22972301

22982302
Controls an LED via its number <button> and <colorcode>.
22992303
See table with button number at the end of this document.
23002304
Color codes are somewhere above (see image).
2305+
The optional <mode> parameter selects the brightness, toggling, flashing
2306+
or animation setting of the LED.
2307+
This also needs to be used to turn an LED comnpletely off.
2308+
2309+
Values for mode:
2310+
18..33: set brightness of the LED (0..15)
2311+
34..41: set toggling speed from every 16 beats down to 1/8 beat
2312+
42..49: set pulsing speed from every 32 beats down to 1/8 beat (*)
2313+
50: animation set to square
2314+
51: animation set to circle
2315+
52: animation set to star
2316+
53: animation set to triangle
2317+
2318+
(*) This might be an error in the manual, as it does not contain an 1/4 setting
2319+
and starts at 1/32. Need to check ...
23012320

23022321
PARAMS: <led> 36..99; number of the LED to control
23032322
<colorcode> 0..127; color code
2323+
<mode> [OPTIONAL] 18..53, see above
23042324
RETURN:
23052325

23062326

2307-
### LedCtrlXY( <x>, <y>, <colorcode> )
2327+
### LedCtrlRawMode( led, mode )
2328+
2329+
Controls the mode of an LED via its number <button> and <mode>.
2330+
See table with button number at the end of this document.
2331+
The <mode> parameter can be set to:
2332+
2333+
18..33: set brightness of the LED (0..15)
2334+
34..41: set toggling speed from every 16 beats down to 1/8 beat
2335+
42..49: set pulsing speed from every 32 beats down to 1/8 beat (*)
2336+
50: animation set to square
2337+
51: animation set to circle
2338+
52: animation set to star
2339+
53: animation set to triangle
2340+
2341+
(*) This might be an error in the manual, as it does not contain an 1/4 setting
2342+
and starts at 1/32. Need to check ...
2343+
2344+
PARAMS: <led> 36..99; number of the LED to control
2345+
<mode> 18..53; see above
2346+
RETURN:
2347+
2348+
2349+
### LedCtrlXY( x, y, colorcode )
23082350

23092351
Controls an LED via its coordinates <x>/<y> and a <colorcode>.
23102352
See table with coordinates at the end of this document.
@@ -2316,7 +2358,7 @@ There is no possibility to control the RGB LEDs individually.yle.
23162358
RETURN:
23172359

23182360

2319-
### LedCtrlChar( char, color, offsx = 0, offsy = 0, coloroff = 0 )
2361+
### LedCtrlChar( char, color, [offsx = 0], [offsy = 0], [coloroff = 0] )
23202362

23212363
Displays character <char> with a color of <color> and a
23222364
lateral offset of <offsx> (-8..8) on the Midi Fighter.
@@ -2345,7 +2387,7 @@ There is no possibility to control the RGB LEDs individually.yle.
23452387
time.wait( 100 ) # from PyGame (from pygame import time)
23462388

23472389

2348-
### LedCtrlString( string, color, coloroff = 0, direction = 0, waitms = 150 )
2390+
### LedCtrlString( string, color, [coloroff = 0], [direction = 0], [waitms = 150] )
23492391

23502392
Scrolls <string> across the Midi Fighter's 8x8 matrix.
23512393
<color> specifies the color of the string and <coloroff> the background.
@@ -2367,11 +2409,22 @@ There is no possibility to control the RGB LEDs individually.yle.
23672409
RETURN:
23682410

23692411

2370-
### LedAllOn( <colorcode> )
2412+
### LedAllOn( [colorcode], [mode] )
2413+
2414+
Quickly sets all LEDs to white or an optional color of <colorcode>
2415+
and a mode setting of <mode>.
2416+
To turn the LEDs off, set their brightness to "0" via the <mode> parameter:
2417+
2418+
18..33: set brightness of the LED (0..15)
2419+
34..41: set toggling speed from every 16 beats down to 1/8 beat
2420+
42..49: set pulsing speed from every 32 beats down to 1/8 beat (*)
2421+
50: animation set to square
2422+
51: animation set to circle
2423+
52: animation set to star
2424+
53: animation set to triangle
23712425

2372-
Quickly sets all LEDs to white or a given <colorcode>.
2373-
Notice that it is not (yet) possible to turn the LEDs off.
2374-
The Midi Fighter's color table does not include "black" or off.
2426+
(*) This might be an error in the manual, as it does not contain an 1/4 setting
2427+
and starts at 1/32. Need to check ...
23752428

23762429
PARAMS: <colorcode> 0..127; color code
23772430
RETURN:

launchpad_py/launchpad.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2865,8 +2865,9 @@ def Check( self, number = 0, name = "Fighter 64" ):
28652865
#-- Controls a grid LED by its <number> and a <color>.
28662866
#-- <number> 36..99
28672867
#-- <color> 0..127 from color table
2868+
#-- <mode> 18..53 for brightness, toggling and animation
28682869
#-------------------------------------------------------------------------------------
2869-
def LedCtrlRaw( self, number, color ):
2870+
def LedCtrlRaw( self, number, color, mode = None ):
28702871

28712872
if number < 36 or number > 99:
28722873
return
@@ -2875,6 +2876,28 @@ def LedCtrlRaw( self, number, color ):
28752876

28762877
self.midi.RawWrite( 146, number, color )
28772878

2879+
# faster than calling LedCtrlRawMode()
2880+
if mode is not None and mode > 17 and mode < 54:
2881+
self.midi.RawWrite( 147, number - 3*12, mode )
2882+
2883+
2884+
#-------------------------------------------------------------------------------------
2885+
#-- Controls a the mode of a grid LED by its <number> and the mode <mode> of the LED.
2886+
#-- <number> 36..99
2887+
#-- <mode> 18..53 for brightness, toggling and animation
2888+
#-- Internal LED numbers are 3 octaves lower than the color numbers.
2889+
#-- The mode must be sent over channel 4
2890+
#-------------------------------------------------------------------------------------
2891+
def LedCtrlRawMode( self, number, mode ):
2892+
2893+
# uses the original button numbers for usability
2894+
if number < 36 or number > 99:
2895+
return
2896+
if mode < 18 or mode > 53:
2897+
return
2898+
2899+
self.midi.RawWrite( 147, number - 3*12, mode )
2900+
28782901

28792902
#-------------------------------------------------------------------------------------
28802903
#-- Controls a grid LED by its <x>/<y> coordinates and a <color>.
@@ -2972,9 +2995,9 @@ def LedCtrlString( self, string, colorcode, coloroff=0, direction = None, waitms
29722995
#-- Sets all LEDs to the same color, specified by <color>.
29732996
#-- If color is omitted, the LEDs are set to white (code 3)
29742997
#-------------------------------------------------------------------------------------
2975-
def LedAllOn( self, color = 3 ):
2998+
def LedAllOn( self, color = 3, mode = None ):
29762999
for i in range(64):
2977-
self.LedCtrlRaw( i+36, color )
3000+
self.LedCtrlRaw( i+36, color, mode )
29783001

29793002

29803003
#-------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)