documentation + LED position
authorFrantišek Kučera <franta-hg@frantovo.cz>
Fri, 22 Dec 2017 16:21:10 +0100
changeset 132a4b8b3abe14
parent 12 1ecfa42ca0d2
child 14 2ab3d7282249
documentation + LED position
c++/rgb-assembler/rgb-assembler.cpp
     1.1 --- a/c++/rgb-assembler/rgb-assembler.cpp	Fri Dec 22 16:10:56 2017 +0100
     1.2 +++ b/c++/rgb-assembler/rgb-assembler.cpp	Fri Dec 22 16:21:10 2017 +0100
     1.3 @@ -13,16 +13,43 @@
     1.4  typedef uint8_t command_t;
     1.5  typedef uint8_t sleep_t;
     1.6  typedef uint8_t color_t;
     1.7 +typedef uint8_t led_t;
     1.8  
     1.9  // TODO: strong typedefs http://www.boost.org/doc/libs/1_61_0/libs/serialization/doc/strong_typedef.html ?
    1.10  
    1.11  const address_t MEMORY_SIZE = 1024;
    1.12  
    1.13 +/**
    1.14 + * Skip to the given address.
    1.15 + * parameter: address_t
    1.16 + */
    1.17  const command_t CMD_GOTO = 0x70;
    1.18 +
    1.19 +/**
    1.20 + * Wait given time in ms.
    1.21 + * parameter: sleep_t
    1.22 + */
    1.23  const command_t CMD_SLEEP = 0xFF;
    1.24 +
    1.25 +/**
    1.26 + * Set RGB LED color.
    1.27 + * parameter: led_t LED number
    1.28 + * parameter: color_t red
    1.29 + * parameter: color_t green
    1.30 + * parameter: color_t blue
    1.31 + */
    1.32  const command_t CMD_COLOR = 0xAA;
    1.33 +
    1.34 +/**
    1.35 + * Stop program.
    1.36 + */
    1.37  const command_t CMD_END = 0xED;
    1.38 -const command_t CMD_INVALID = 0x1; // placeholder for unsupported command
    1.39 +
    1.40 +/**
    1.41 + * Placeholder for unsupported command.
    1.42 + * Just for testing.
    1.43 + */
    1.44 +const command_t CMD_INVALID = 0x1;
    1.45  
    1.46  /**
    1.47   * Reads data on given position in memory and increments the index (position).
    1.48 @@ -67,6 +94,7 @@
    1.49  		write<command_t>(memory, a, CMD_SLEEP);
    1.50  		write<sleep_t>(memory, a, 255);
    1.51  		write<command_t>(memory, a, CMD_COLOR);
    1.52 +		write<led_t>(memory, a, 23);
    1.53  		write<color_t>(memory, a, 0);
    1.54  		write<color_t>(memory, a, 200);
    1.55  		write<color_t>(memory, a, 255);
    1.56 @@ -94,10 +122,11 @@
    1.57  			}
    1.58  			case CMD_COLOR:
    1.59  			{
    1.60 +				led_t led = read<led_t>(memory, i);
    1.61  				color_t r = read<color_t>(memory, i);
    1.62  				color_t g = read<color_t>(memory, i);
    1.63  				color_t b = read<color_t>(memory, i);
    1.64 -				wprintf(L"COLOR  %02X %02X %02X\n", r, g, b);
    1.65 +				wprintf(L"COLOR  %02X %02X %02X → %d\n", r, g, b, led);
    1.66  				break;
    1.67  			}
    1.68  			case CMD_END: