13
0

added trackcolors to X-Touch, added _is_xtouch to device info as condition for trackcolors

This commit is contained in:
alex 2023-03-06 00:08:38 +01:00
parent bc1ed2e256
commit 777c7c6c03
5 changed files with 105 additions and 1 deletions

View File

@ -62,6 +62,7 @@ DeviceInfo::DeviceInfo()
, _is_qcon(false)
, _is_platformMp(false)
, _is_proG2(false)
, _is_xtouch(false)
, _has_qcon_second_lcd(false)
, _has_qcon_master_meters(false)
, _has_meters (true)
@ -340,6 +341,12 @@ DeviceInfo::set_state (const XMLNode& node, int /* version */)
} else {
_is_qcon = false;
}
if ((child = node.child ("IsXTouch")) != 0) {
child->get_property ("value", _is_xtouch);
} else {
_is_xtouch = false;
}
if ((child = node.child ("IsPlatformMp")) != 0) {
child->get_property ("value", _is_platformMp);
@ -523,6 +530,11 @@ bool DeviceInfo::is_proG2 () const
return _is_proG2;
}
bool DeviceInfo::is_xtouch () const
{
return _is_xtouch;
}
bool
DeviceInfo::has_qcon_second_lcd () const
{

View File

@ -83,6 +83,7 @@ class DeviceInfo
bool is_qcon() const;
bool is_platformMp() const;
bool is_proG2() const;
bool is_xtouch() const;
bool has_qcon_second_lcd() const;
bool has_qcon_master_meters() const;
bool has_meters() const;
@ -118,6 +119,7 @@ class DeviceInfo
bool _is_qcon;
bool _is_platformMp;
bool _is_proG2;
bool _is_xtouch;
bool _has_qcon_second_lcd;
bool _has_qcon_master_meters;
bool _has_meters;

View File

@ -1190,6 +1190,11 @@ Surface::map_stripables (const vector<boost::shared_ptr<Stripable> >& stripables
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Mapping %1 stripables to %2 strips\n", stripables.size(), strips.size()));
bool xtouch = _mcp.device_info().is_xtouch();
XTouchColors colors[] { Off, Off, Off, Off, Off, Off, Off, Off };
uint8_t i = 0;
for (r = stripables.begin(); r != stripables.end() && s != strips.end(); ++s) {
/* don't try to assign stripables to a locked strip. it won't
@ -1198,15 +1203,21 @@ Surface::map_stripables (const vector<boost::shared_ptr<Stripable> >& stripables
*/
if (!(*s)->locked()) {
if(xtouch){
colors[i] = static_cast<XTouchColors>(convert_color_to_xtouch_value((*r)->presentation_info().color()));
++i;
}
(*s)->set_stripable (*r);
++r;
}
}
for (; s != strips.end(); ++s) {
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("strip %1 being set to null stripable\n", (*s)->index()));
(*s)->set_stripable (boost::shared_ptr<Stripable>());
}
if(xtouch){
_port->write(display_colors_on_xtouch(colors)); //write colors to strips for xtouch
}
}
static char
@ -1623,3 +1634,68 @@ Surface::display_message_for (string const& msg, uint64_t msecs)
(*s)->block_screen_display_for (msecs);
}
}
/** display @p color_values on the 8 scribble strips of the X-Touch
*
* @param color_values is assumed to be an array with a color value for each of the 8 scribble strips
*/
MidiByteArray
Surface::display_colors_on_xtouch(const XTouchColors color_values[]) const
{
MidiByteArray midi_msg;
midi_msg << sysex_hdr ();
midi_msg << 0x72;
uint8_t displaycount = 8;
for(uint8_t i = 0; i < displaycount; ++i){
midi_msg << color_values[i];
}
midi_msg << MIDI::eox;
return midi_msg;
}
/** takes trackcolor in 0xRRGGBBAA (Red, Green, Blue, Alpha) and converts it to suitable xtouch colors
* return value can be casted to enum XTouchColor
*/
uint8_t
Surface::convert_color_to_xtouch_value(uint32_t color) const
{
uint8_t red = color >> 24;
uint8_t green = (color >> 16) & 0xff;
uint8_t blue = (color >> 8) & 0xff;
uint8_t max = red;
if(max < green){
max = green;
}
if(max < blue){
max = blue;
}
if(max != 0){
//set the highest value to 0xFF to be brightness independent
float norm = 255.0/max;
red = static_cast<uint8_t>(red*norm);
green = static_cast<uint8_t>(green*norm);
blue = static_cast<uint8_t>(blue*norm);
uint8_t xcolor = 0;
if(red > 0x7f){
xcolor = xcolor | 0b001; //lowest bit is red
}
if(green > 0x7f){
xcolor = xcolor | 0b010; //second bit is green
}
if(blue > 0x7f){
xcolor = xcolor | 0b100; //third bit is blue
}
return xcolor;
}
else{
return White; //if it would be black (color = 0x000000) return white, because black means off
}
}

View File

@ -68,6 +68,17 @@ class Led;
class Surface : public PBD::ScopedConnectionList, public sigc::trackable
{
public:
enum XTouchColors {
Off,
Red,
Green,
Yellow,
Blue,
Purple,
Cyan,
White,
};
Surface (MackieControlProtocol&, const std::string& name, uint32_t number, surface_type_t stype);
virtual ~Surface();
@ -245,6 +256,8 @@ public:
bool is_qcon;
MidiByteArray display_line (std::string const& msg, int line_num);
MidiByteArray display_colors_on_xtouch(const XTouchColors color_values[]) const;
uint8_t convert_color_to_xtouch_value(uint32_t color) const;
public:
/* IP MIDI devices need to keep a handle on this and destroy it */

View File

@ -12,4 +12,5 @@
<JogWheel value="yes"/>
<TouchSenseFaders value="yes"/>
<HasSeparateMeters value="yes"/>
<IsXTouch value="yes"/>
</MackieProtocolDevice>