BIN mode on PWM LED matrix
Steve Spielman 15 Feb 2015 16:04
The RGB Matrix r2 has full color (PWM) capability, but it is backward compatible with the 8-color mode (BIN). I tried out the BIN mode when I wanted a faster display update, by simply calling the generating function with:
#define MATRIX_TYPE RGB_MATRIX_PWM //RGB_MATRIX_BIN or RGB_MATRIX_PWM
#if MATRIX_TYPE==RGB_MATRIX_PWM
uint8_t buf[RGB_MATRIX_PWM_BUF];
#else
uint8_t buf[RGB_MATRIX_BIN_BUF];
#endif
RGB_Matrix matrix[MATRIX_ROWS][MATRIX_COLS] = {
RGB_Matrix((uint8_t)0x50, buf, MATRIX_TYPE),
RGB_Matrix((uint8_t)0x51, buf, MATRIX_TYPE),
RGB_Matrix((uint8_t)0x52, buf, MATRIX_TYPE),
RGB_Matrix((uint8_t)0x53, buf, MATRIX_TYPE)
};
But I got very chaotic results. On further testing, I found the columns were simply in reverse order for the green component. I worked around the problem by modifying one line of the library RGB_Matrix_Arduino.cpp:
} else {
//Serial.println("Setting BIN pixel");
(red) ? _buf[row] |= _BV(col) : _buf[row] &= ~_BV(col);
// (grn) ? _buf[row + 8] |= _BV(col) : _buf[row + 8] &= ~_BV(col);
(grn) ? _buf[row + 8] |= _BV(7-col) : _buf[row + 8] &= ~_BV(7-col); // srs 2015-02-14; green was going backwards
(blu) ? _buf[row + 16] |= _BV(col) : _buf[row + 16] &= ~_BV(col);
}
I don't know if that was the best place to make the change, but it seems to have worked. I would be interested to know if anyone else has seen the same thing.