Closed vidavidorra closed 8 years ago
Thought of a couple of different ways to send the data from the uC to the PC.
x, y, z
before sending red, green, blue
. The x, y and z range is 0-7, while the red, green, blue range is 0-15. So this would take quite a lot of data that needs to be send, but no mistakes could be made determining to which coordinate the colours belong.red, green, blue
for all the LEDs. This would reduce the amount of data that needs to be send, but it's easier to make mistakes in determining to which coordinate the colours belong.The data protocol I have chosen is the first one, since this is easier on the PC side and could be easily extended with, for example 5-bits BAM instead of 4-bits.
Note: The number of ASCII characters below is the minimal amount of ASCII characters needed for the transmission.
Description | start | version major + minor + patch | end | total |
---|---|---|---|---|
ASCII Characters | 1 | 5 | 1 | 7 |
ASCII Abbreveration | SOH | ASCII numbers and dot | EOT | |
ASCII Hexadecimal | 01 | 04 |
Example SOH
0
.
1
.
1
EOT
.
Optionally, in case the version number uses more than a single digits, it could be like SOH
15
.
8
.
1
EOT
.
Note: The number of ASCII characters below is the minimal amount of ASCII characters needed for the transmission. The total column specifies the total number of ASCII characters that would be needed to send the data of the complete LED cube, so the data for 512 LEDs.
Description | start | start of block | x-Coord | y-Coord | z-Coord | red | green | blue | end of block | ... | end | total |
---|---|---|---|---|---|---|---|---|---|---|---|---|
ASCII Characters | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | ... | 1 | 4098 |
ASCII Abbreveration | SOH | STX | 0-7 | 0-7 | 0-7 | 0-F | 0-F | 0-F | ETB | ... | EOT | |
ASCII Hexadecimal | 01 | 02 | 17 | ... | 04 |
Successfully tested the LedCubeVisualisation_sendVersion
and LedCubeVisualisation_sendRow
functions using the following code
LedCube_setPixel(0, 0, 0, 15, 0, 0);
LedCube_setPixel(0, 1, 0, 14, 0, 1);
LedCube_setPixel(0, 2, 0, 13, 0, 2);
LedCube_setPixel(0, 3, 0, 12, 0, 3);
LedCube_setPixel(0, 4, 0, 11, 0, 4);
LedCube_setPixel(0, 5, 0, 10, 0, 5);
LedCube_setPixel(0, 6, 0, 9, 0, 6);
LedCube_setPixel(0, 7, 0, 8, 0, 7);
LedCube_updateUsingCopy();
LedCubeVisualisation_sendVersion();
LCV_SEND_CHAR('\n');
LedCubeVisualisation_sendRow( 0, 0, pCubeControlData->pCubeDataRead );
output:
SOH``STX
0.1.0ETB``EOT
STX
000F00ETB``STX
010E01ETB``STX
0D0E02ETB``STX
0C0E03ETB``STX
0B0E04ETB``STX
010A05ETB``STX
010906ETB``STX
010807ETB
uint8_t z, x, y, t;
for(z = 0; z < 8; z++) {
for(x=0;x<8;x+=2) {
LedCube_setPixel(x, 0, z, 0, 7, 15);
LedCube_setPixel(x, 1, z, 1, 6, 14);
LedCube_setPixel(x, 2, z, 2, 5, 13);
LedCube_setPixel(x, 3, z, 3, 4, 12);
LedCube_setPixel(x, 4, z, 4, 3, 11);
LedCube_setPixel(x, 5, z, 5, 2, 10);
LedCube_setPixel(x, 6, z, 6, 1, 9 );
LedCube_setPixel(x, 7, z, 7, 0, 8 );
LedCube_setPixel(x+1, 0, z, 15, 8, 15);
LedCube_setPixel(x+1, 1, z, 14, 9, 14);
LedCube_setPixel(x+1, 2, z, 13, 10, 13);
LedCube_setPixel(x+1, 3, z, 12, 11, 12);
LedCube_setPixel(x+1, 4, z, 11, 12, 11);
LedCube_setPixel(x+1, 5, z, 10, 13, 10);
LedCube_setPixel(x+1, 6, z, 9, 14, 9 );
LedCube_setPixel(x+1, 7, z, 8, 15, 8 );
}
}
LedCube_updateUsingCopy();
LedCubeVisualisation_sendCubeData(pCubeControlData->pCubeDataRead);
This showed the following block for every layer. So this test was succesfull.
SOH
STX
00007FETB``STX
01016EETB``STX
02025DETB``STX
03034CETB``STX
04043BETB``STX
05052AETB``STX
060619ETB``STX
070708ETB
STX
100F8FETB``STX
110E9EETB``STX
120DADETB``STX
130CBCETB``STX
140BCBETB``STX
150ADAETB``STX
1609E9ETB``STX
1708F8ETB
STX
20007FETB``STX
21016EETB``STX
22025DETB``STX
23034CETB``STX
24043BETB``STX
25052AETB``STX
260619ETB``STX
270708ETB
STX
300F8FETB``STX
310E9EETB``STX
320DADETB``STX
330CBCETB``STX
340BCBETB``STX
350ADAETB``STX
3609E9ETB``STX
3708F8ETB
STX
40007FETB``STX
41016EETB``STX
42025DETB``STX
43034CETB``STX
44043BETB``STX
45052AETB``STX
460619ETB``STX
470708ETB
STX
500F8FETB``STX
510E9EETB``STX
520DADETB``STX
530CBCETB``STX
540BCBETB``STX
550ADAETB``STX
5609E9ETB``STX
5708F8ETB
STX
60007FETB``STX
61016EETB``STX
62025DETB``STX
63034CETB``STX
64043BETB``STX
65052AETB``STX
660619ETB``STX
670708ETB
STX
700F8FETB``STX
710E9EETB``STX
720DADETB``STX
730CBCETB``STX
740BCBETB``STX
750ADAETB``STX
7609E9ETB``STX
7708F8ETB
...
EOT
Removing the last two items from the list in the opening post because those are related to the LedCube Visualisation program, which is currently being rewritten to C++ with Qt by the way. So this closes this issue.
Intro
I have another project for visualizing this LED cube called LedCube-Visualisation. This project consists of a Windows program written in C# that currently visualizes a single layer of the LED cube. The link between this program is currently made using UART and could in the future be made using a Bluetooth connection.
Connection
The connection between the LedCube Visualisation program and the LedCube code should be done using a defined and efficient data protocol and using several functions to output the data.
Steps
Update the LedCube Visualisation program to be compatible with the newly defined data protocol.Test the code of outputting a single layer in combination with the LedCube Visualisation program.