# HG changeset patch # User František Kučera # Date 1513956070 -3600 # Node ID 2a4b8b3abe14415f87f3fe161007c485a3cf625f # Parent 1ecfa42ca0d284096551a111ad573898e5198f42 documentation + LED position diff -r 1ecfa42ca0d2 -r 2a4b8b3abe14 c++/rgb-assembler/rgb-assembler.cpp --- a/c++/rgb-assembler/rgb-assembler.cpp Fri Dec 22 16:10:56 2017 +0100 +++ b/c++/rgb-assembler/rgb-assembler.cpp Fri Dec 22 16:21:10 2017 +0100 @@ -13,16 +13,43 @@ typedef uint8_t command_t; typedef uint8_t sleep_t; typedef uint8_t color_t; +typedef uint8_t led_t; // TODO: strong typedefs http://www.boost.org/doc/libs/1_61_0/libs/serialization/doc/strong_typedef.html ? const address_t MEMORY_SIZE = 1024; +/** + * Skip to the given address. + * parameter: address_t + */ const command_t CMD_GOTO = 0x70; + +/** + * Wait given time in ms. + * parameter: sleep_t + */ const command_t CMD_SLEEP = 0xFF; + +/** + * Set RGB LED color. + * parameter: led_t LED number + * parameter: color_t red + * parameter: color_t green + * parameter: color_t blue + */ const command_t CMD_COLOR = 0xAA; + +/** + * Stop program. + */ const command_t CMD_END = 0xED; -const command_t CMD_INVALID = 0x1; // placeholder for unsupported command + +/** + * Placeholder for unsupported command. + * Just for testing. + */ +const command_t CMD_INVALID = 0x1; /** * Reads data on given position in memory and increments the index (position). @@ -67,6 +94,7 @@ write(memory, a, CMD_SLEEP); write(memory, a, 255); write(memory, a, CMD_COLOR); + write(memory, a, 23); write(memory, a, 0); write(memory, a, 200); write(memory, a, 255); @@ -94,10 +122,11 @@ } case CMD_COLOR: { + led_t led = read(memory, i); color_t r = read(memory, i); color_t g = read(memory, i); color_t b = read(memory, i); - wprintf(L"COLOR %02X %02X %02X\n", r, g, b); + wprintf(L"COLOR %02X %02X %02X → %d\n", r, g, b, led); break; } case CMD_END: