Permalink
Browse files

use non visual MIDI message to reset rapid update pointer before chan…

…ge_all
  • Loading branch information...
1 parent 012d623 commit 7b7defeb7a758c7c60d97741c964336ba5e02820 Thomas Jachmann committed Nov 21, 2009
Showing with 14 additions and 6 deletions.
  1. +1 −0 README.rdoc
  2. +3 −2 lib/launchpad/device.rb
  3. +6 −0 lib/launchpad/midi_codes.rb
  4. +4 −4 test/test_device.rb
View
@@ -72,6 +72,7 @@ For more details, see the examples. examples/color_picker.rb is the most complex
== Changelog
+* don't update grid button 0,0 before change_all (in order to reset rapid update pointer), use MIDI message without visual effect
* (at least) doubled the speed of change_all by not sending each message individually but sending them in one go (as an array)
=== v0.1.1
View
@@ -157,8 +157,9 @@ def change_all(*colors)
# ensure that colors is at least and most 80 elements long
colors = colors.flatten[0..79]
colors += [0] * (80 - colors.size) if colors.size < 80
- # HACK switch off first grid LED to reset rapid LED change pointer
- output(Status::ON, 0, 0)
+ # send normal MIDI message to reset rapid LED change pointer
+ # in this case, set mapping mode to x-y layout (the default)
+ output(Status::CC, Status::NIL, GridLayout::XY)
# send colors in slices of 2
messages = []
colors.each_slice(2) do |c1, c2|
@@ -44,6 +44,12 @@ module Velocity
TEST_LEDS = 0x7C
end
+ # Module defining MIDI data 2 codes for selecting the grid layout.
+ module GridLayout
+ XY = 0x01
+ DRUM_RACK = 0x02
+ end
+
end
end
View
@@ -416,14 +416,14 @@ def stub_input(device, *args)
assert_nil @device.change_all([0])
end
- should 'fill colors with 0, set grid 0,0 to 0 and flush colors' do
- expects_output(@device, 0x90, 0, 0)
+ should 'fill colors with 0, set grid layout to XY and flush colors' do
+ expects_output(@device, 0xB0, 0, 0x01)
expects_output(@device, *([[0x92, 17, 17]] * 20 + [[0x92, 12, 12]] * 20))
@device.change_all([5] * 40)
end
- should 'cut off exceeding colors, set grid 0,0 to 0 and flush colors' do
- expects_output(@device, 0x90, 0, 0)
+ should 'cut off exceeding colors, set grid layout to XY and flush colors' do
+ expects_output(@device, 0xB0, 0, 0x01)
expects_output(@device, *([[0x92, 17, 17]] * 40))
@device.change_all([5] * 100)
end

0 comments on commit 7b7defe

Please sign in to comment.