# HG changeset patch # User František Kučera # Date 1514071032 -3600 # Node ID 2b2f8a17d63a6094809b8c081a83eaf89488f219 # Parent 835bd4559e5c8222e000a3fb4173a3fef83872f8 move standard commands (codes) to a header file diff -r 835bd4559e5c -r 2b2f8a17d63a c++/rgb-assembler/commands.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c++/rgb-assembler/commands.h Sun Dec 24 00:17:12 2017 +0100 @@ -0,0 +1,59 @@ +#pragma once + +// Standard commands + +/** + * Skip to the given address. + * parameter: address_t + */ +const command_t CMD_GOTO = 0x70; + +/** + * Compare values on two addresses and go to one of given three addresses. + * parameter: address_t a + * parameter: address_t b + * parameter: address_t GOTO target when a == b + * parameter: address_t GOTO target when a > b + * parameter: address_t GOTO target when a < b + */ +const command_t CMD_GOTO_COMPARE = 0x80; + +/** + * 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; + +/** + * Increase value at given address + * parameter: address_t + */ +const command_t CMD_INCREMENT = 0x11; + +/** + * Decrease value at given address + * parameter: address_t + */ +const command_t CMD_DECREMENT = 0x12; + +/** + * Placeholder for unsupported command. + * Just for testing. + */ +const command_t CMD_INVALID = 0x1; + +// TODO: more commands, better numbers \ No newline at end of file diff -r 835bd4559e5c -r 2b2f8a17d63a c++/rgb-assembler/nbproject/configurations.xml --- a/c++/rgb-assembler/nbproject/configurations.xml Sun Dec 24 00:12:58 2017 +0100 +++ b/c++/rgb-assembler/nbproject/configurations.xml Sun Dec 24 00:17:12 2017 +0100 @@ -11,6 +11,7 @@ commands/GotoCompare.h commands/IncrementDecrement.h commands/Sleep.h + commands.h memory.h types.h @@ -51,6 +52,8 @@ + + @@ -93,6 +96,8 @@ + + diff -r 835bd4559e5c -r 2b2f8a17d63a c++/rgb-assembler/rgb-assembler.cpp --- a/c++/rgb-assembler/rgb-assembler.cpp Sun Dec 24 00:12:58 2017 +0100 +++ b/c++/rgb-assembler/rgb-assembler.cpp Sun Dec 24 00:17:12 2017 +0100 @@ -8,6 +8,7 @@ #include "types.h" #include "memory.h" #include "Command.h" +#include "commands.h" #include "commands/Goto.h" #include "commands/GotoCompare.h" #include "commands/Sleep.h" @@ -17,64 +18,6 @@ using namespace std; -// TODO: strong typedefs http://www.boost.org/doc/libs/1_61_0/libs/serialization/doc/strong_typedef.html ? - -/** - * Skip to the given address. - * parameter: address_t - */ -const command_t CMD_GOTO = 0x70; - -/** - * Compare values on two addresses and go to one of given three addresses. - * parameter: address_t a - * parameter: address_t b - * parameter: address_t GOTO target when a == b - * parameter: address_t GOTO target when a > b - * parameter: address_t GOTO target when a < b - */ -const command_t CMD_GOTO_COMPARE = 0x80; - -/** - * 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; - -/** - * Increase value at given address - * parameter: address_t - */ -const command_t CMD_INCREMENT = 0x11; - -/** - * Decrease value at given address - * parameter: address_t - */ -const command_t CMD_DECREMENT = 0x12; - -/** - * Placeholder for unsupported command. - * Just for testing. - */ -const command_t CMD_INVALID = 0x1; - -// TODO: more commands, better numbers - int main(int argc, char* argv[]) { setlocale(LC_ALL, ""); diff -r 835bd4559e5c -r 2b2f8a17d63a c++/rgb-assembler/types.h --- a/c++/rgb-assembler/types.h Sun Dec 24 00:12:58 2017 +0100 +++ b/c++/rgb-assembler/types.h Sun Dec 24 00:17:12 2017 +0100 @@ -8,3 +8,5 @@ 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 ?