Today I would like to speak in an unusual capacity for the Arduino hub and tell not about the device, but about the library. We will talk about the library LedMatrix ( Russian description ), which is able to manage 8x8 LED matrices on MAX7219 and MAX7221 chips.
I will not retell here a readme from a repository, and I will stop on the main features. ')
The underlying concept is that the code should adapt to the architecture of your installation, not the installation to the code .
So, what is my library can do?
1. She can programmatically rotate the matrix . Thus, you do not need to try to adjust the location of the matrices, so that the picture you conceived is displayed correctly. Such a problem really exists. And often rises on the forums.
2. She is able to combine matrices in cascades . Working with a cascade as a separate entity is much more convenient than with a simple array of individual matrices.
3. She can combine cascades into super cascades . The MAX7219 and MAX7221 chips impose a hardware limit on the cascade size of 8 matrices per cascade. But you can connect several cascades, combine them into one super cascade and work with it as with a single cascade. The super cascade is just a big cascade. There are no interface differences.
4. She is able to work both through hardware SPI and through software . You choose the method of connecting your device and, depending on your needs, choose which interface to work through.
5. It is equipped with a small portion of syntactic sugar in the form of iterators, convenient work with binary representations.
6. And of course, she knows everything that such a library should be able to do . This includes working with individual rows, columns, dots. Receiving, setting, inversion, shifts et cetera.
Well and in the conclusion, I will tell that the library has the verified and flexible interface written on a modern C ++.
Initially, my library was a fork of the LedControl library. I planned to make a few cosmetic edits and add the missing features to me, but in the end, I got carried away and completely rewrote the source library. There are literally a couple of lines from the original, which are now located in the src / CoreMax72xx.cpp file.
Currently, the Arduino IDE comes with built-in avr-g ++ version 4.8.1, which fully supports the C ++ 11 standard. So why do we see a depressing picture when most libraries are just C with classes. I think it's time to move on to modern standards. And I propose to support my initiative.