13
0

push2: fully init and de-init buttons and pads at startup and shutdown

This commit is contained in:
Paul Davis 2022-08-31 10:22:24 -06:00
parent 681ca38848
commit 253dac007d

View File

@ -245,6 +245,12 @@ Push2::stop_using_device ()
init_buttons (false); init_buttons (false);
strip_buttons_off (); strip_buttons_off ();
for (auto & pad : _xy_pad_map) {
pad->set_color (LED::Black);
pad->set_state (LED::NoTransition);
write (pad->state_msg());
}
_vblank_connection.disconnect (); _vblank_connection.disconnect ();
session_connections.drop_connections (); session_connections.drop_connections ();
@ -405,26 +411,24 @@ Push2::init_buttons (bool startup)
in ardour related (loosely, sometimes) to their illuminated label. in ardour related (loosely, sometimes) to their illuminated label.
*/ */
if (startup) {
ButtonID buttons[] = { Mute, Solo, Master, Up, Right, Left, Down, Note, Session, Mix, AddTrack, Delete, Undo, ButtonID buttons[] = { Mute, Solo, Master, Up, Right, Left, Down, Note, Session, Mix, AddTrack, Delete, Undo,
Metronome, Shift, Select, Play, RecordEnable, Automate, Repeat, Note, Session, Metronome, Shift, Select, Play, RecordEnable, Automate, Repeat, Note, Session,
Quantize, Duplicate, Browse, PageRight, PageLeft, OctaveUp, OctaveDown, Layout, Scale, Quantize, Duplicate, Browse, PageRight, PageLeft, OctaveUp, OctaveDown, Layout, Scale,
Stop Stop
}; };
for (size_t n = 0; n < sizeof (buttons) / sizeof (buttons[0]); ++n) { for (size_t n = 0; n < sizeof (buttons) / sizeof (buttons[0]); ++n) {
boost::shared_ptr<Button> b = _id_button_map[buttons[n]]; boost::shared_ptr<Button> b = _id_button_map[buttons[n]];
if (startup) {
b->set_color (LED::White); b->set_color (LED::White);
} else { b->set_state (LED::NoTransition);
b->set_color (LED::Black);
}
b->set_state (LED::OneShot24th);
write (b->state_msg()); write (b->state_msg());
} }
if (startup) {
/* all other buttons are off (black) */ /* all other buttons are off (black) */
ButtonID off_buttons[] = { TapTempo, Setup, User, Convert, New, FixedLength, Clip, ButtonID off_buttons[] = { TapTempo, Setup, User, Convert, New, FixedLength, Clip,
@ -438,9 +442,9 @@ Push2::init_buttons (bool startup)
b->set_state (LED::OneShot24th); b->set_state (LED::OneShot24th);
write (b->state_msg()); write (b->state_msg());
} }
}
if (!startup) { } else {
if (_current_layout) { if (_current_layout) {
_current_layout->hide (); _current_layout->hide ();
} }
@ -452,6 +456,12 @@ Push2::init_buttons (bool startup)
pad->set_state (LED::OneShot24th); pad->set_state (LED::OneShot24th);
write (pad->state_msg()); write (pad->state_msg());
} }
for (auto & b : _id_button_map) {
b.second->set_color (LED::Black);
b.second->set_state (LED::NoTransition);
write (b.second->state_msg());
}
} }
} }
@ -1953,4 +1963,3 @@ Push2::lower_button_by_column (uint32_t col)
/*NOTREACHED*/ /*NOTREACHED*/
return boost::shared_ptr<Push2::Button>(); return boost::shared_ptr<Push2::Button>();
} }