diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2015-11-24 21:10:22 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-11-24 21:10:22 -0500 |
commit | 8765359db2ba3f655009c1248155862dd60b89c5 (patch) | |
tree | b4b41fdbae7ca09f059615edd8e86072f6ccee79 /libs/surfaces | |
parent | 84ebad120e5320be93d9cd1a2c34f6b3455f1dbf (diff) |
faderport: after connecting, turn off all lights, then party with them, then turn them all off
Diffstat (limited to 'libs/surfaces')
-rw-r--r-- | libs/surfaces/faderport/faderport.cc | 40 | ||||
-rw-r--r-- | libs/surfaces/faderport/faderport.h | 7 |
2 files changed, 43 insertions, 4 deletions
diff --git a/libs/surfaces/faderport/faderport.cc b/libs/surfaces/faderport/faderport.cc index 11aefa0566..fc8d42f4cb 100644 --- a/libs/surfaces/faderport/faderport.cc +++ b/libs/surfaces/faderport/faderport.cc @@ -17,11 +17,12 @@ */ -#include <stdint.h> - +#include <cstdlib> #include <sstream> #include <algorithm> +#include <stdint.h> + #include <glibmm/fileutils.h> #include <glibmm/miscutils.h> @@ -167,10 +168,34 @@ FaderPort::~FaderPort () tear_down_gui (); } +void +FaderPort::all_lights_out () +{ + for (ButtonMap::iterator b = buttons.begin(); b != buttons.end(); ++b) { + b->second.set_led_state (_output_port, false); + g_usleep (1000); + } +} + +void +FaderPort::party () +{ + for (int n = 0; n < 5; ++n) { + for (ButtonMap::iterator b = buttons.begin(); b != buttons.end(); ++b) { + b->second.set_led_state (_output_port, random() % 3); + g_usleep (1000); + } + g_usleep (250000); + } + + all_lights_out (); +} + + FaderPort::ButtonInfo& FaderPort::button_info (ButtonID id) const { - map<ButtonID,ButtonInfo>::const_iterator b = buttons.find (id); + ButtonMap::const_iterator b = buttons.find (id); assert (b != buttons.end()); return const_cast<ButtonInfo&>(b->second); } @@ -240,6 +265,10 @@ FaderPort::sysex_handler (MIDI::Parser &p, MIDI::byte *buf, size_t sz) native[2] = 0x64; _output_port->write (native, 3, 0); + + g_usleep (10000); + all_lights_out (); + party (); } } @@ -524,6 +553,11 @@ FaderPort::ButtonInfo::set_led_state (boost::shared_ptr<MIDI::Port> port, int on return; } + if (out < 0) { + /* fader button ID - no LED */ + return; + } + MIDI::byte buf[3]; buf[0] = 0xa0; buf[1] = out; diff --git a/libs/surfaces/faderport/faderport.h b/libs/surfaces/faderport/faderport.h index 570a4f3c18..82006a3507 100644 --- a/libs/surfaces/faderport/faderport.h +++ b/libs/surfaces/faderport/faderport.h @@ -239,8 +239,13 @@ class FaderPort : public ARDOUR::ControlProtocol { } on_release; }; - std::map<ButtonID,ButtonInfo> buttons; + typedef std::map<ButtonID,ButtonInfo> ButtonMap; + + ButtonMap buttons; ButtonInfo& button_info (ButtonID) const; + + void all_lights_out (); + void party (); }; } |