Using 2 LED Matrix seperately on a 4 in 1 board (32 x 8)

Hi guys, so I am making a Bluetooth enabled turn signal for my scooter. I got myself a 32 x 8 led matrix with 4 MAX7219 controllers for each 8 x 8. Now I wanted to code an arrow symbol that would scroll across two 8 x 8 LED matrices. Any ideas on how to code it?

The following pictures is my current state with my arrows… I am looking to achieve as I’ve sketched…

I’ve also provided my current code that is running the lights.

Thanks in advance guys

code_for_lights.ino (5.66 KB)

You want the animation to scroll across all 4 displays?

Really all you need is one character...

B00001110,
B00011100,
B00111000,
B01110000,
B01110000,
B00111000,
B00011100,
B00001110

The repeat across the display. To make it scroll, shift the x-axis origin.
To do the opposite direction mirror around the vertical axis.

Are the modules fixed, or can they be rotated so the "rows" and actually vertical?
That would make the programming quite a lot easier.

Something like this probably…

char state;
uint8_t offset;
bool reverse;

uint32_t last_frame;
uint32_t period;

uint8_t arrow[] {
  B00001110,
  B00011100,
  B00111000,
  B01110000,
  B01110000,
  B00111000,
  B00011100,
  B00001110
};

uint8_t disp[4][8];

void outputDisplay()
{
  /*
  for (int row = 0; row < 8; row++) {
    lc.setRow(0, row, disp[0][row]);
    lc.setRow(1, row, disp[1][row]);
    lc.setRow(2, row, disp[2][row]);
    lc.setRow(3, row, disp[3][row]);
  }
  */

  // For debug - output to serial
  Serial.print("State:");
  Serial.println(state);
  for (uint8_t y = 0; y < 8; y++)
  {
    for (uint8_t x = 0; x < 32; x++)
    {
      uint8_t mask = 0x80 >> (x & 7);
      Serial.write(disp[x >> 3][y] & mask ? 'X' : ' ');
    }
    Serial.println();
  }
  Serial.println();
}

void plotPixel(uint8_t x, uint8_t y, bool c)
{
  x &= 31;
  y &= 7;
  uint8_t mask = 0x80 >> (x & 7);
  disp[x >> 3][y] &= ~mask;
  if (c) disp[x >> 3][y] |= mask;
}

bool getArrowPixel(uint8_t x, uint8_t y)
{
  x &= 7;
  y &= 7;
  if (reverse) x = 7 - x;
  uint8_t mask = 0x80 >> x;
  return (arrow[y] & mask) != 0;
}

void drawLeftRight()
{
  for (uint8_t x = 0; x < 32; x++)
  {
    for (uint8_t y = 0; y < 8; y++)
    {
      plotPixel(x, y, getArrowPixel(x+offset, y));
    }
  }
}

void drawIdle()
{
  for (uint8_t x = 0; x < 32; x++)
  {
    for (uint8_t y = 0; y < 8; y++)
    {
      plotPixel(x, y, offset & 1);
    }
  }
}

void drawClear()
{
  for (uint8_t x = 0; x < 32; x++)
  {
    for (uint8_t y = 0; y < 8; y++)
    {
      plotPixel(x, y, 0);
    }
  }
}

void setup()
{
  Serial.begin(57600);
}

void loop()
{
  if (Serial.available())
  {
    int c = Serial.read();
    if (c >= ' ')
    {
      state = c;
      offset = 0;
      period = 0;
    }
  }

  uint32_t now = millis();
  if (now - last_frame >= period)
  {
    switch (state)
    {
      case 'R':
        reverse = true;
        drawLeftRight();
        period = 250;
        offset--;
        break;
      case 'L':
        reverse = false;
        drawLeftRight();
        period = 250;
        offset++;
        break;
      case 'I':
        drawIdle();
        period = 1000;
        offset++;
        break;
      default:
        drawClear();
        period = 2000;
        break;
    }
    
    outputDisplay();

    last_frame = now;
  }
}

As I don’t have any displays I output the display to serial.

Some adjustment may be required, depending on which way the bits are in the display (LSB first or MSB).
Edit: I updated the sketch because I realised the MSB is probably left-hand most bit.

Thanks guys!!! Would definitely try them out

pcbbc:
You want the animation to scroll across all 4 displays?

Really all you need is one character...

B00001110,

B00011100,
B00111000,
B01110000,
B01110000,
B00111000,
B00011100,
B00001110



The repeat across the display. To make it scroll, shift the x-axis origin.
To do the opposite direction mirror around the vertical axis.

Are the modules fixed, or can they be rotated so the "rows" and actually vertical?
That would make the programming quite a lot easier.

Well the modules are fixed on a long pcb board but there's a MAX7219 controller for each 8 x 8 segment of the matrices. But i am thinking of using 2 pairs of the LED matrix for one arrow to scroll through each. Simply 1 arrow across 2 matrix.