Pimoroni 5x5 RGB Matrix

I'm trying to use this 5x5 LED Matrix but realize that doing it in Arduino is almost impossible since there's no documentation on them. Looks like some people have had success in python, but that's just not going to work for my project. I see some code written to try and get it to work with Adafruit_IS31FL3741 which makes sense because it uses the IS31FL3741. I've even used some sample code and have gotten it to light up random lights. Can anyone actually make it work as its intended?

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_IS31FL3731.h>

// If you're using the full breakout...
//Adafruit_IS31FL3731 matrix = Adafruit_IS31FL3731();
// If you're using the FeatherWing version
//Adafruit_IS31FL3731_Wing matrix = Adafruit_IS31FL3731_Wing();
// Trying Pimoroni (Fails to compile here)
Pimoroni_IS31FL3731_5x5RGB matrix = Pimoroni_IS31FL3731_5x5RGB();

void setup() {

Serial.begin(9600);
Serial.println("ISSI manual animation test");
if (! matrix.begin()) {
Serial.println("IS31 not found");
while (1);
}
Serial.println("IS31 Found!");

}

void loop() {

matrix.clear();
matrix.drawPixel(1, 1, 128, 128, 128);
delay(500);

// }
}

Which 5x5 LED matrix?

Adafruit_IS31FL3731(uint8_t x = 16, uint8_t y = 9);

So the default monochrome matrix is 16x9. Have you tried using your 5x5 RGB as a 15x5 monochrome matrix?

Adafruit_IS31FL3731 matrix = Adafruit_IS31FL3731(15, 5);

5x5 RGB Matrix Breakout – Pimoroni I guess

The product page links to this data sheet https://www.lumissil.com/assets/pdf/core/IS31FL3731_DS.pdf

The datasheet shows two sets of 9 output pins that each drive an 8x9 array of Charlieplexed LEDs. You just have to figure out the mapping of the 16x9 array to the 5x5xRGB layout.

I would start by lighting each of the 16 columns one at a time and then lighting each of the 9 rows one at a time. That should make it easy enough to figure out the mapping.

Once you have the mapping you can write your own subclass (like Adafruit_IS31FL3731_Wing) with your own drawPixel() function to make the matrix easier to use.

Or see the Adafruit library for this chip.
is31fl3731-library

I would love to add my own subclass, I'm just not that skilled. Its coming along though. I was able to use the adafruit library to get the basic functionality I'm after. It just seems like a bad method for doing it all. I'd much rather take advantage of the entire adafruit library because there's so many great features to it. I opened up an issue to have them add support for these little boards. I hope that happens. These boards have the perfect 'feel' for my project. Kinda retro-old school dot matrix vibe going on.

It's not too hard. Start by stealing the Adafruit_IS31FL3731_Wing subclass. Then change the name. Then work on the .displayPixel() method until it does what you want.

#ifndef _PIMORONI_IS31FL3731_5X5RGB_H_
#define _PIMORONI_IS31FL3731_5X5RGB_H_

#include <Adafruit_IS31FL3731.h>

class Pimoroni_IS31FL3731_5x5RGB : public Adafruit_IS31FL3731
{
  public:
    Pimoroni_IS31FL3731_5x5RGB(void)
    : Adafruit_IS31FL3731(15, 5) {}
    
    void drawPixel(int16_t x, int16_t y, uint16_t color)
    {
      // check rotation, move pixel around if necessary
      switch (getRotation())
      {
        case 1:
          _swap_int16_t(x, y);
          x = 15 - x - 1;
          break;
        case 2:
          x = 15 - x - 1;
          y = 7 - y - 1;
          break;
        case 3:
          _swap_int16_t(x, y);
          y = 9 - y - 1;
          break;
      }

      // charlie wing is smaller:
      if ((x < 0) || (x >= 16) || (y < 0) || (y >= 7))
        return;

      if (x > 7)
      {
        x = 15 - x;
        y += 8;
      }
      else
      {
        y = 7 - y;
      }

      _swap_int16_t(x, y);

      if (color > 255)
        color = 255; // PWM 8bit max

      setLEDPWM(x + y * 16, color, _frame);
      return;
    }
}
#endif

I have a similar situation with the 11x7 matrix display. 11x7 LED Matrix Breakout – Pimoroni

It works for about half of the screen, but then any co-ordinates after that dont show. It almost seams as if the second half of the screen is rotated 90 compared to the first half.

Try this pixel map, translated from their Python library:

        const byte PIXEL_MAP[11][7] = {
            {6, 22, 38, 54, 70, 86, 14, 30, 46, 62, 78},
            {5, 21, 37, 53, 69, 85, 13, 29, 45, 61, 77},
            {4, 20, 36, 52, 68, 84, 12, 28, 44, 60, 76},
            {3, 19, 35, 51, 67, 83, 11, 27, 43, 59, 75},
            {2, 18, 34, 50, 66, 82, 10, 26, 42, 58, 74},
            {1, 17, 33, 49, 65, 81,  9, 25, 41, 57, 73},
            {0, 16, 32, 48, 64, 80,  8, 24, 40, 56, 72}
        };

Thanks a lot John!

Let me try and work this out with the library...

I worked out the offset and added it to my library for anyone else wanting this to work!

Tested on the left, and intended on the right. The values after 5 for y were wrong, so I added an if statement to capture those and offset x by +8 and y by -6.

void Adafruit_IS31FL3731::drawPixel(int16_t x, int16_t y, uint16_t color) {
  // check rotation, move pixel around if necessary
  switch (getRotation()) {
  case 1:
    _swap_int16_t(x, y);
    x = 16 - x - 1;
    break;
  case 2:
    x = 16 - x - 1;
    y = 9 - y - 1;
    break;
  case 3:
    _swap_int16_t(x, y);
    y = 9 - y - 1;
    break;
  }

  // if ((x < 0) || (x >= 16))
  //   return;
  // if ((y < 0) || (y >= 9))
  //   return;
  if (color > 255)
    color = 255; // PWM 8bit max
//added jack
    if (y>5) {
      x = x+8;
      y = y-6;
     }
//added jack end
  setLEDPWM(x + y * 16, color, _frame);
  return;
}