MAX7219 setColumn data format

On the Arduino I used the lc.setColumn command from the “LedControl.h” library to display text, logos or animations on a 8x11 display. I used e.g. lc.setColumn(chip,column,B10101010) to switch on led 1,3,5,7 on a single column and run through a loop to display all 11 columns which are stored as:

byte Logos[11][11] = { {B00000000,B00000000,B00000000,B11111111,B10000001,B10101001,B10000001,B11111111,B00000000,B00000000,B00000000}, // Logo1

I tried to use the same set of logos on the Photon using the “LedControl-MAX7219-MAX7221.h” library but without success. The MAX7219 chips are working fine but my array with logos is causing “B00000000 was not declared in this scope errors”. When I enter the command setColumn(chip,column,B10101010) in the code I get the same error. If I use setColumn(chip,column,170) or setColumn(chip,column,0XAA) it is working fine but this makes it much more difficult to “draw” a logo compared to the led on/off way I could use on the Arduino.

Is there a way to store and use the data in the “B10101010” format or do I have to convert my matrices? I tried to understand the Photon library but I couldn’t figure out why it works on the Arduino and not on the Photon.

Hi @Maarten_CH

The “B00000000” syntax is not legal C/C++ and the Particle Wiring preprocessor does not handle it currently.

The best solution is to convert them all to C/C++ syntax which is “0b00000000”. That sounds a bit hard but search-and-replace can help you out:

“{B” --> “{0xb”
",B" --> “,0xb”

After that you could just look from the compile errors and fix up any stragglers.

Thanks for your reply @bko

The code compiles using 0xb instead of B, however I don’t get the output as expected.
I did a quick test:

byte Test = 0xb11111111;

This lights LED 4 and 8 instead of the expected 8 (when I use setColumn(0,3,255)).
I checked “Test” with Serial.println(Test,DEC) and got an output of 17. I then noticed that the columns are displayed upside-down as well. Led 1 and 5 would give 17…

I checked the upside-down thing with setLed(0,0,0,true) to find the first row and first column and that was indeed the other way around.

Do you have an idea what’s going wrong?

Hi @Maarten_CH

Glad you moved the ball forward a bit! I am not sure what is going on–can you provide a pointer to the library you are using? Is it in the web IDE?

There are some i2c problems on Photons right now that are being worked on by the team. It could also be related to 16-bit versus 32-bit int datatype difference between Arduino and Particle.

Hi @bko

I copied the Particle library I found in the web IDE from Github and included the library files in the offline Particle Dev.

I have the feeling that the communication between the Photon and the MAX7219 is fine. All commands are working as expected except the 0xb11111111 format.

This could very well be. I’m also still puzzled by the output of 17 from the Serial.println(Test,DEC) when byte Test = 0xb11111111

I have a quick read through the library and didn’t see anything obvious. Maybe @cloris who ported the library has some thoughts here?

I will take a look and let you know what I see.



Thanks a lot @bko & @cloris!

Do you have an idea when you have time to look at it? It would be great when I can use the setColumn and setRow commands again.