1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/c++/rgb-assembler/commands/Sleep.h Sat Dec 23 23:42:46 2017 +0100
1.3 @@ -0,0 +1,25 @@
1.4 +#pragma once
1.5 +
1.6 +#include <wchar.h>
1.7 +#include <chrono>
1.8 +#include <thread>
1.9 +
1.10 +#include "../Command.h"
1.11 +
1.12 +using namespace std;
1.13 +
1.14 +namespace commands {
1.15 +
1.16 +class Sleep : public Command {
1.17 +public:
1.18 +
1.19 + void process(octet_t* memory, address_t& index) override {
1.20 + sleep_t delay = read<sleep_t>(memory, index);
1.21 + wprintf(L"SLEEP %*d ms\n", 4, delay);
1.22 + this_thread::sleep_for(chrono::milliseconds(delay));
1.23 + }
1.24 +private:
1.25 +
1.26 +};
1.27 +
1.28 +}
2.1 --- a/c++/rgb-assembler/nbproject/configurations.xml Sat Dec 23 23:34:21 2017 +0100
2.2 +++ b/c++/rgb-assembler/nbproject/configurations.xml Sat Dec 23 23:42:46 2017 +0100
2.3 @@ -6,6 +6,7 @@
2.4 projectFiles="true">
2.5 <itemPath>Command.h</itemPath>
2.6 <itemPath>commands/Goto.h</itemPath>
2.7 + <itemPath>commands/Sleep.h</itemPath>
2.8 <itemPath>memory.h</itemPath>
2.9 <itemPath>types.h</itemPath>
2.10 </logicalFolder>
2.11 @@ -48,6 +49,8 @@
2.12 </item>
2.13 <item path="commands/Goto.h" ex="false" tool="3" flavor2="0">
2.14 </item>
2.15 + <item path="commands/Sleep.h" ex="false" tool="3" flavor2="0">
2.16 + </item>
2.17 <item path="memory.h" ex="false" tool="3" flavor2="0">
2.18 </item>
2.19 <item path="rgb-assembler.cpp" ex="false" tool="1" flavor2="0">
2.20 @@ -80,6 +83,8 @@
2.21 </item>
2.22 <item path="commands/Goto.h" ex="false" tool="3" flavor2="0">
2.23 </item>
2.24 + <item path="commands/Sleep.h" ex="false" tool="3" flavor2="0">
2.25 + </item>
2.26 <item path="memory.h" ex="false" tool="3" flavor2="0">
2.27 </item>
2.28 <item path="rgb-assembler.cpp" ex="false" tool="1" flavor2="0">
3.1 --- a/c++/rgb-assembler/rgb-assembler.cpp Sat Dec 23 23:34:21 2017 +0100
3.2 +++ b/c++/rgb-assembler/rgb-assembler.cpp Sat Dec 23 23:42:46 2017 +0100
3.3 @@ -4,13 +4,12 @@
3.4 #include <locale.h>
3.5 #include <cstring>
3.6 #include <unordered_map>
3.7 -#include <chrono>
3.8 -#include <thread>
3.9
3.10 #include "types.h"
3.11 #include "memory.h"
3.12 #include "Command.h"
3.13 #include "commands/Goto.h"
3.14 +#include "commands/Sleep.h"
3.15
3.16 using namespace std;
3.17
3.18 @@ -114,6 +113,7 @@
3.19
3.20 unordered_map<command_t, shared_ptr < Command>> commands = {
3.21 {CMD_GOTO, make_shared<commands::Goto>()},
3.22 + {CMD_SLEEP, make_shared<commands::Sleep>()},
3.23 };
3.24
3.25 for (address_t i = 0; i < MEMORY_SIZE;) {
3.26 @@ -131,13 +131,6 @@
3.27 }
3.28
3.29 switch (command) {
3.30 - case CMD_SLEEP:
3.31 - {
3.32 - sleep_t delay = read<sleep_t>(memory, i);
3.33 - wprintf(L"SLEEP %*d ms\n", 4, delay);
3.34 - this_thread::sleep_for(chrono::milliseconds(delay));
3.35 - break;
3.36 - }
3.37 case CMD_COLOR:
3.38 {
3.39 led_t led = read<led_t>(memory, i);