Arrays for LED matrix in Excel - easy!

I’m developing a device with information output to an LED matrix. Standard standard solution on MK STM8S105C6T6 + 74HC595.

image

And so, after running tests on simple pictures and lines, I ran into a problem, how to hammer these data arrays in the easiest way? After all, each pixel is either 1 or 0, and even in the smallest 8x8 matrix - there are as many as 64 of these pixels.



You can, of course, manually, using a notepad, type something like this:

image

But then you need to translate the array 0 and 1 into decimal or hexadecimal values ​​corresponding to rows or columns, for example, using an engineering calculator. But it is long and uninteresting. You can write a simple editor in C #, but I need to install and configure the environment at work. But there is Excel at hand! He copes with such tasks perfectly. So let's get started.

To begin with, we agree that the luminous pixel is “1”, and the non-luminous pixel is “0”. In order for Excel to show us “bulbs” instead of boring numbers, we use conditional formatting. Let all §, which is equal to and greater than 1, be a green circle, and all that is less - not painted over in white.

image

We get a circle on the left side of the cells that corresponds to the state of the cell. In the right we see the contents of the cell.

image

But why do we need to see “0” and “1”? We’ll hide them, for this we need to reduce the width of the cells so that only the “bulbs” remain visible. I did it with a column width = "2". Now the fun part. How to convert eight zeros and ones to one byte in Excel? To do this, take the school formula for translating binary to decimal.

For those who do not remember:

10110110 = (1 · 2 ^ 7) + (0 · 2 ^ 6) + (1 · 2 ^ 5) + (1 · 2 ^ 4) + (0 · 2 ^ 3) + ( 1 · 2 ^ 2) + (1 · 2 ^ 1) + (0 · 2 ^ 0) = 128 + 32 + 16 + 4 + 2 = 182

In the cell under the bulbs, the same formula is obtained:

= J14 * 2 ^ 7 + J13 * 2 ^ 6 + J12 * 2 ^ 5 + J11 * 2 ^ 4 + J10* 2 ^ 3 + J9 * 2 ^ 2 + J8 * 2 ^ 1 + J7 * 2 ^ 0

And finally, we want to get the array code so that we can immediately insert it into the program and check. To do this, combine the contents of the cells with a comma using the & "," & construction. The result is the formula:

AF16 & "," & AG16 & "," & AH16 & "," & AI16 & "," & AJ16 & "," & AK16 & "," & AL16 & "," & AM16 & "," & AN16 & "," & AO16 & "," & AP16 & "," & AQ16 & "," & AR16 & " , "& AS16 &", "& AT16 &", "& AU16 &", "& AV16 &", "& AW16 &", "& AX16 &", "& AY16 &", "& AZ16 &", "& BA16 &", "& BB16 &", "& BC16 &", "& BD16 &", " & BE16 & "," & BF16 & "," & BG16 & "};"

As a result, having filled the array with the values ​​“1” and “0”, we immediately see the result:

image




Also popular now: