📜 ⬆️ ⬇️

Array for LED matrix in Excel - easy!

I am developing a device with information output on an LED matrix. The standard typical solution on the MK STM8S105C6T6 + 74HC595.

image

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


')
You can, of course, manually, using a notepad to stuff something like this:

image

But then the array 0 and 1 must be converted to 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 at work I need to install and configure the environment. But there is Excel at hand! He does an excellent job with such tasks. So let's get started.

To begin with, let's agree that the luminous pixel is “1”, not luminous - “0”. In order for Excel to show us in the “light bulb” table instead of boring numbers, let's use conditional formatting. Let Vs§, which is equal to and greater than 1, be a green circle, and all that is less — not filled with white.

image

We obtain in the left part of the cells a circle 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 hide them, for this we need to reduce the width of the cells so that only the “light bulbs” are visible. I got it with the width of the column = "2". Now the fun part. How to turn eight zeros and units in one byte in Excel? To do this, take the school formula for converting a binary number to a 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 code of the array to immediately insert into the program and check. To do this, combine the contents of the cells separated by commas using the & &, "&." The result is the formula:

= "Unsigned char to_display [] = {" & B16 & "," & C16 & "," & D16 & "," & E16 & "," & F16 & "," & G16 & "," & H16 & "," & I16 & "," & J16 & "," & K16 & "," & L16 &, "& M16 &", "& N16 &", "& O16 &", "& P16 &", "& Q16 &", "& R16 &", "& S16 &", "& T16 &", "& U16 &", "& V16 &", "& W16 &", "& X16 &" , "& Y16 &", "& Z16 &", "& AA16 &", "& AB16 &", "& AC16 &", "& AD16 &", "& AE16 &", "& 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

And the generated code can be immediately inserted into the program and see the result:

Source: https://habr.com/ru/post/376089/


All Articles