tk's docs describe the mask functions better than i could... generally, we are using a mask to determine which bit in a byte to use for a column ok, for starters i think this will toggle the blue correctly. however if you are not using tk's blm example code, i think there may be an issue with the handler being called before blm_button_column being set (i vaguely remember sm_example doing this...) also, you may want to switch red and green so the rgb values are in order... anywayz you can try and see. afterwards, i'll look at the midi handler.
// enable this code (turn #if 0 into #if 1) if buttons should change the LED colour directly
// disable it when LEDs should only be controlled via MIDI
#if 1
// cycle colour whenever button has been pressed (value == 0)
if( !value ) {
mask = MIOS_HLP_GetBitORMask(blm_button_column);
if ( blm_row_green[blm_button_row] & mask )
{
if ( blm_row_red[blm_button_row] & mask )
blm_row_blue[blm_button_row] ^= mask; //if red is changing to 0, toggle blue
blm_row_red[blm_button_row] ^= mask; //if green is changing to 0, toggle red
}
blm_row_green[blm_button_row] ^= mask; //green toggles every time
}
/*
&= (Bitwise AND EQUALS)
Performs a bitwise AND and sets the original value to the result.
^= (Bitwise Exclusive OR EQUALS)
Performs a bitwise exclusive OR and sets the original value to the result.
|= (Bitwise OR EQUALS)
Performs a bitwise OR and sets the original value to the result.
*/
#endif