COLOR
authorFrantišek Kučera <franta-hg@frantovo.cz>
Fri, 22 Dec 2017 00:00:04 +0100
changeset 10efed38f454a0
parent 9 157bc062efa7
child 11 1d1cc6552542
COLOR
c++/rgb-assembler/rgb-assembler.cpp
     1.1 --- a/c++/rgb-assembler/rgb-assembler.cpp	Thu Dec 21 21:55:26 2017 +0100
     1.2 +++ b/c++/rgb-assembler/rgb-assembler.cpp	Fri Dec 22 00:00:04 2017 +0100
     1.3 @@ -12,11 +12,13 @@
     1.4  typedef uint16_t address_t;
     1.5  typedef uint8_t command_t;
     1.6  typedef uint8_t sleep_t;
     1.7 +typedef uint8_t color_t;
     1.8  
     1.9  const address_t MEMORY_SIZE = 1024;
    1.10  
    1.11  const command_t CMD_GOTO = 0x70;
    1.12  const command_t CMD_SLEEP = 0xFF;
    1.13 +const command_t CMD_COLOR = 0xAA;
    1.14  const command_t CMD_END = 0xED;
    1.15  
    1.16  /**
    1.17 @@ -61,6 +63,10 @@
    1.18  		write<command_t>(memory, a, 1);
    1.19  		write<command_t>(memory, a, CMD_SLEEP);
    1.20  		write<sleep_t>(memory, a, 255);
    1.21 +		write<command_t>(memory, a, CMD_COLOR);
    1.22 +		write<color_t>(memory, a, 50);
    1.23 +		write<color_t>(memory, a, 100);
    1.24 +		write<color_t>(memory, a, 150);
    1.25  		write<command_t>(memory, a, CMD_END);
    1.26  	}
    1.27  
    1.28 @@ -70,6 +76,10 @@
    1.29  		wprintf(L"%X\n", ch);
    1.30  
    1.31  		string command;
    1.32 +		
    1.33 +		color_t r;
    1.34 +		color_t g;
    1.35 +		color_t b;
    1.36  
    1.37  		switch (ch) {
    1.38  			case CMD_GOTO:
    1.39 @@ -80,6 +90,12 @@
    1.40  				command.append("SLEEP");
    1.41  				this_thread::sleep_for(chrono::milliseconds(read<sleep_t>(memory, i)));
    1.42  				break;
    1.43 +			case CMD_COLOR:
    1.44 +				command.append("COLOR");
    1.45 +				r = read<color_t>(memory, i);
    1.46 +				g = read<color_t>(memory, i);
    1.47 +				b = read<color_t>(memory, i);
    1.48 +				break;
    1.49  			case CMD_END:
    1.50  				command.append("END");
    1.51  				i = MEMORY_SIZE;