jdbruijn / LedCube

Program to control an 8x8x8 RGB LED cube.
http://vidavidorra.github.io/LedCube-Documentation
GNU General Public License v3.0
0 stars 0 forks source link

LedCube Visualisation #6

Closed vidavidorra closed 8 years ago

vidavidorra commented 8 years ago

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

vidavidorra commented 8 years ago

Thought of a couple of different ways to send the data from the uC to the PC.

  1. Send the 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.
  2. Send a start transmission character and than send 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.

Data protocol

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.

Version info

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.

Cube LED data

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
vidavidorra commented 8 years ago

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``STX0.1.0ETB``EOT STX000F00ETB``STX010E01ETB``STX0D0E02ETB``STX0C0E03ETB``STX0B0E04ETB``STX010A05ETB``STX010906ETB``STX010807ETB

vidavidorra commented 8 years ago
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 STX00007FETB``STX01016EETB``STX02025DETB``STX03034CETB``STX04043BETB``STX05052AETB``STX060619ETB``STX070708ETB STX100F8FETB``STX110E9EETB``STX120DADETB``STX130CBCETB``STX140BCBETB``STX150ADAETB``STX1609E9ETB``STX1708F8ETB STX20007FETB``STX21016EETB``STX22025DETB``STX23034CETB``STX24043BETB``STX25052AETB``STX260619ETB``STX270708ETB STX300F8FETB``STX310E9EETB``STX320DADETB``STX330CBCETB``STX340BCBETB``STX350ADAETB``STX3609E9ETB``STX3708F8ETB STX40007FETB``STX41016EETB``STX42025DETB``STX43034CETB``STX44043BETB``STX45052AETB``STX460619ETB``STX470708ETB STX500F8FETB``STX510E9EETB``STX520DADETB``STX530CBCETB``STX540BCBETB``STX550ADAETB``STX5609E9ETB``STX5708F8ETB STX60007FETB``STX61016EETB``STX62025DETB``STX63034CETB``STX64043BETB``STX65052AETB``STX660619ETB``STX670708ETB STX700F8FETB``STX710E9EETB``STX720DADETB``STX730CBCETB``STX740BCBETB``STX750ADAETB``STX7609E9ETB``STX7708F8ETB ... EOT

vidavidorra commented 8 years ago

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.