Hi the 5x5 RGB Matrix Breakout (PIM435) is described as being compatable with Arduino.
Now a bit more detail would be very handy.
The Matrix uses the IS31FL3731 driver chip and there is an Adafruit Arduino library for this chip (the only one).
However all the Adafruit products that use this library are single colour and are either 15x7 or 9x16. Does the IS31FL3731 chip know how many LEDs are connected up and does it know that those LEDs are rgb? Anyone got any ideas?
Thanks
Andrew
I’m also having problems with 5x5 on Arduino.
Have you got it to work yet ?
It looks like the Adafruit library defines the sizes - the question I have is how the registers are mapped to RGB LEDs - do we assume that each LED has three registers (what are the addresses?) or is it using RGB565 for 16bit values across two registers? I2C is meant to send the I2C device address, then the register address and then one or more data values to put into the register bank (sequentially incrementing the address if more than one is sent). More comments in the Python code would also help.
Merged post:
It looks like the PWM register range is called COLOUR_OFFSET in the Python Script and for each frame is 0x24 to 0xB3. It’s how that space is mapped to each pixel that I’ve not figured yet (along with everything else that needs changing in the Adafruit library)
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;
}
I’ve no idea why, I wrote my own library for this a while ago and didn’t need the last three pixels. I wonder if that’s a hangover from potential alternative deisgns or something.
I’ve added a class for the pimoroni where drawPixel takes x and y and the rgb components as 0-255 and it works. How do I upload it here? It looks like it only accepts pictures.
Google Drive link
Here’s an example sketch:
#include <Adafruit_GFX.h>
#include <Adafruit_IS31FL3731.h>
#include <Wire.h>
Pimoroni_IS31FL3731_5x5RGB ledmatrix=Pimoroni_IS31FL3731_5x5RGB ();
void setup() {
Wire.begin();
ledmatrix.begin();
Serial.begin(115200);
}
void loop() {
for(unsigned char x = 0; x < 5; x++){
for(unsigned char y = 0; y < 5; y++){
Serial.print("x “);Serial.print(x);
Serial.print(” y ");Serial.println(y);
ledmatrix.drawPixel(x,y,255,255,255);
delay(200);
ledmatrix.drawPixel(x,y,0,0,0);
}
}
}
How do I upload it here? It looks like it only accepts pictures.
Usually people upload the code to Github and link that.
Thanks Shoe - that’s a good suggestion.
Updated files here
I added functions setBlink and fixed the axis so that drawPixel now takes coordinates 1-5 with 1,1 being bottom left and 5,5 beign top right.
I tried your updated files but I still can’t get it to work. When I compile it says
“Pimoroni_IS31FL3731_5x5RGB’ has not been declared”
Does anyone have a working example of arduino controlling the 5x5 matrix?