I’d like to get something to use in C, maybe based on the Adafruit code.
From the Python code I’ve added comments by cross-referencing the terminology in the ISSI spec sheet which helps us understand it a bit better. The controller has 8 images it can display either as a static picture or as an animation - these are referred to as ‘frames’ but the Python code calls them ‘banks’. The special, Function Register, accessed by setting the frame to 11 (0x0b). The 75 LEDS are mapped to some of the 144 supported (it seems defined in the enable_pattern). What’s also confusing to me is why there are 28 pixel addresses defined in the RGBMatrix5x5 lookup (matching the 84 ones in the binary enable_pattern) .
Any answers or corrections welcome.
//****COMMAND REGISTER (frame to receive data: 0-7 or function:11) *******
_BANK_ADDRESS = 0xfd
//FRAME REGISTER OFFSETS***
// “ENABLE” -is LED ON/OFF 144 bits in 18x 8bit bytes; “COLOR” IS PWM 0-255 144 8bit bytes
_ENABLE_OFFSET = 0x00
_BLINK_OFFSET = 0x12
_COLOR_OFFSET = 0x24
//**** FUNCTION ‘FRAME’ OFFSETS******
_MODE_REGISTER = 0x00
_FRAME_REGISTER = 0x01
_AUTOPLAY1_REGISTER = 0x02
_AUTOPLAY2_REGISTER = 0x03
_BLINK_REGISTER = 0x05
_AUDIOSYNC_REGISTER = 0x06
_BREATH1_REGISTER = 0x08
_BREATH2_REGISTER = 0x09
_SHUTDOWN_REGISTER = 0x0a
_GAIN_REGISTER = 0x0b
_ADC_REGISTER = 0x0c
//**** COMMAND REGISTER VALUE FOR FUNCTION REGISTER (SPECIAL FRAME 11)
_CONFIG_BANK = 0x0b
//**** DISPLAY MODES FOR USE IN _MODE_REGISTER
_PICTURE_MODE = 0x00
_AUTOPLAY_MODE = 0x08
_AUDIOPLAY_MODE = 0x18
UPDATE (26th April):
I’ve modified the begin() function of a new derived class (shown below) along with its own drawPixel() method and lednumber lookup and will test later.
bool Pimoroni_IS31FL3731_5x5RGB::begin(uint8_t addr) {
Wire.begin();
Wire.setClock(400000);
_i2caddr = addr;
_frame = 0;
// A basic scanner, see if it ACK’s
Wire.beginTransmission(_i2caddr);
if (Wire.endTransmission () != 0) {
return false;
}
// shutdown
writeRegister8(ISSI_BANK_FUNCTIONREG, ISSI_REG_SHUTDOWN, 0x00);
delay(10);
// out of shutdown
writeRegister8(ISSI_BANK_FUNCTIONREG, ISSI_REG_SHUTDOWN, 0x01);
// picture mode
writeRegister8(ISSI_BANK_FUNCTIONREG, ISSI_REG_CONFIG, ISSI_REG_CONFIG_PICTUREMODE);
displayFrame(_frame);
// all LEDs on & 0 PWM
clear(); // set each led to 0 PWM
//define which of the 144 led addresses are valid for 5x5 RGB
uint8_t enable_pattern[18] = {
0b00000000, 0b10111111,
0b00111110, 0b00111110,
0b00111111, 0b10111110,
0b00000111, 0b10000110,
0b00110000, 0b00110000,
0b00111111, 0b10111110,
0b00111111, 0b10111110,
0b01111111, 0b11111110,
0b01111111, 0b00000000,
};
for (uint8_t f = 0; f < 8; f++) {
for (uint8_t i = 0; i <= 0x11; i++)
writeRegister8(f, i, enable_pattern[i]); // only the RGB LEDs in 5x5 array
}
audioSync(false);
return true;
}