Uneven / odd sized LED matrix (6x17) with 2x Max7219 - remapping

Hi guys,

I'm new to arduino. Only previous coding experience is css, html and a bit of php.

I'm building a word clock. I've successfully built a circuit, using a pro mini and two Max7219 with a DS3231 RTC.
My LED matrix is 6x17 (102 LEDs). The problem is addressing the matrix easily.
I've drawn my matrix (in paint, sorry at work presently).
It's divided in two. One matrix of 6 rows x 8 columns.
The other matrix has 6 rows x 9 columns - its wired with the same 6 rows x 8 columns with the 9th 'column' being wired as a 7th row.

All the LEDs light up fine. I can get text to scroll across both matrixes ok, but of course the code doesn't know I've got my LEDs laid out as 6x17, as far as it's concerned it's 2x8x8. So the 9th column is lit up as if it were the 7th row. All expected behaviour.
The problem is I can't work out how to remap / readdress the matrix or commands.
using Ledcontrol library.

I'd like to remap the matrix so that I can address it in 6 rows of 17 (makes most sense to me). e.g. SetLed (1,15).
I've spent hours googling and looking through this forum without a solution. I've found references to being able to have an irregular shaped / sized matrix that you just address differently via code, but can't find any code to actually do this.

It seems logically quite simple that I should be able to make up an address table such that:
e.g. LED (1,3) corresponds to LED (0,0,2)
e.g. LED (4,12) corresponds to LED (1,3,4)

With my clock I want to be able to:
Similar to: Arduino WordClock - Exhibition / Gallery - Arduino Forum
Display the time (via the letters on the faceplate)
Display temp (make large digits with combination of leds)
Scroll text.

Any help is much appreciated.

So having a bit of a play:

//We always have to include the library
#include "LedControl.h"

int a = 0;
int b = 2;
int c = 2;
char D = 0,3,3;

/*
 Now we need a LedControl to work with.
 ***** These pin numbers will probably not work with your hardware *****
 pin 12 is connected to the DataIn 
 pin 11 is connected to the CLK 
 pin 10 is connected to LOAD 
 We have only a single MAX72XX.
 */
LedControl lc=LedControl(4,2,3,2);

/* we always wait a bit between updates of the display */
unsigned long delaytime=100;

void setup() {
  /*
   The MAX72XX is in power-saving mode on startup,
   we have to do a wakeup call
   */
  lc.shutdown(0,false);
  /* Set the brightness to a medium values */
  lc.setIntensity(0,8);
  /* and clear the display */
  lc.clearDisplay(0);
    lc.shutdown(1,false);
  /* Set the brightness to a medium values */
  lc.setIntensity(0,8);
  /* and clear the display */
  lc.clearDisplay(0);
}

void loop()
{
/* 
 * Switch all Leds on the display off. 
 * Params:
 * int addr The address of the display to control
 */
void clearDisplay(int addr);

lc.setLed(D,true);   

}

It works if I have:

lc.setLed(a,b,c,true);

but not if I have

lc.setLed(D,true);

Max7219_basic:7: error: expected unqualified-id before numeric constant
Max7219_basic.ino: In function 'void loop()':
Max7219_basic:50: error: no matching function for call to 'LedControl::setLed(char&, int)'

I'm struggling to find a way to pass commas in a variable. Obviously I want to keep the number of variables to a minimum (not 306!)

I'm struggling to find a way to pass commas in a variable.

That is because you can't. Variables hold values a comma is not a value. You can generate a string by doing:-

char D[6] ="0,3,3";

but then what will you do with it because the lc.setLed function will not accept a string.

You could use a hash define so that when the compiler encounters your character it will substitute that string, like
#define D 0,3,3

I have tried to compile you code with a hash define in it but there seems to be something wrong withe the LED control library.

What version of the IDE are you running?

This seems to be an old library inside the 1.0.5 Arduino that can not possibly run.

Mike,

Thanks for your help.
I'm using 1.0.5

Define works for me. The following code turns on the leds in the top row one by one at 500msec delay.

//We always have to include the library
#include "WordClock6x17.h"

#define A1 0,0,0
#define A2 0,0,1
#define A3 0,0,2
#define A4 0,0,3
#define A5 0,0,4
#define A6 0,0,5
#define A7 0,0,6
#define A8 0,0,7
#define A9 0,6,7
#define A10 1,0,0
#define A11 1,0,1
#define A12 1,0,2
#define A13 1,0,3
#define A14 1,0,4
#define A15 1,0,5
#define A16 1,0,6
#define A17 1,0,7


/*
 Now we need a LedControl to work with.
 ***** These pin numbers will probably not work with your hardware *****
 pin 12 is connected to the DataIn 
 pin 11 is connected to the CLK 
 pin 10 is connected to LOAD 
 We have only a single MAX72XX.
 */
LedControl lc=LedControl(4,2,3,2);

/* we always wait a bit between updates of the display */
unsigned long delaytime=100;

void setup() {
  /*
   The MAX72XX is in power-saving mode on startup,
   we have to do a wakeup call
   */
  lc.shutdown(0,false);
  /* Set the brightness to a medium values */
  lc.setIntensity(0,8);
  /* and clear the display */
  lc.clearDisplay(0);
  lc.shutdown(1,false);
  /* Set the brightness to a medium values */
  lc.setIntensity(1,8);
  /* and clear the display */
  lc.clearDisplay(1);
}

void loop()
{
/* 
 * Switch all Leds on the display off. 
 * Params:
 * int addr The address of the display to control
 */
void clearDisplay(int addr);

/*switch on the led in the 3'rd row 8'th column
 and remember that indices start at 0!  */
lc.setLed(A1,true);
delay(500);
lc.setLed(A2,true);
delay(500);
lc.setLed(A3,true);
delay(500);
lc.setLed(A4,true);
delay(500);
lc.setLed(A5,true);
delay(500);
lc.setLed(A6,true);
delay(500);
lc.setLed(A7,true);
delay(500);
lc.setLed(A8,true);
delay(500);
lc.setLed(A9,true);
delay(500);
lc.setLed(A10,true);
delay(500);
lc.setLed(A11,true);
delay(500);
lc.setLed(A12,true);
delay(500);
lc.setLed(A13,true);
delay(500);
lc.setLed(A14,true);
delay(500);
lc.setLed(A15,true);
delay(500);
lc.setLed(A16,true);
delay(500);
lc.setLed(A17,true);
}

I suspect this is not going to work with text scrolling etc...

#define worked fine for making LED locations human readable, and therefore easy to code the simple word clock.
However I couldn't find a way to truly remap the locations such that scrolling etc would work.

I ended up changed to a 6x16 matrix and have decent code working.
Based on Riva's wordclock

Clock_v6006_mod_20.ino (45.1 KB)