Skip to content

Commit 03310c2

Browse files
committed
Finished working on base plugin
1 parent 65b0edf commit 03310c2

File tree

8 files changed

+366
-209
lines changed

8 files changed

+366
-209
lines changed

.vscode/settings.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"files.associations": {
3+
"*.bak": "cpp",
4+
"array": "cpp",
5+
"atomic": "cpp",
6+
"*.tcc": "cpp",
7+
"cctype": "cpp",
8+
"cfenv": "cpp",
9+
"chrono": "cpp",
10+
"cinttypes": "cpp",
11+
"clocale": "cpp",
12+
"cmath": "cpp",
13+
"complex": "cpp",
14+
"condition_variable": "cpp",
15+
"cstdarg": "cpp",
16+
"cstddef": "cpp",
17+
"cstdint": "cpp",
18+
"cstdio": "cpp",
19+
"cstdlib": "cpp",
20+
"cstring": "cpp",
21+
"ctime": "cpp",
22+
"cwchar": "cpp",
23+
"cwctype": "cpp",
24+
"deque": "cpp",
25+
"list": "cpp",
26+
"unordered_map": "cpp",
27+
"vector": "cpp",
28+
"exception": "cpp",
29+
"algorithm": "cpp",
30+
"functional": "cpp",
31+
"iterator": "cpp",
32+
"map": "cpp",
33+
"memory": "cpp",
34+
"memory_resource": "cpp",
35+
"numeric": "cpp",
36+
"random": "cpp",
37+
"ratio": "cpp",
38+
"set": "cpp",
39+
"string": "cpp",
40+
"system_error": "cpp",
41+
"tuple": "cpp",
42+
"type_traits": "cpp",
43+
"utility": "cpp",
44+
"fstream": "cpp",
45+
"initializer_list": "cpp",
46+
"iosfwd": "cpp",
47+
"iostream": "cpp",
48+
"istream": "cpp",
49+
"limits": "cpp",
50+
"mutex": "cpp",
51+
"new": "cpp",
52+
"ostream": "cpp",
53+
"sstream": "cpp",
54+
"stdexcept": "cpp",
55+
"streambuf": "cpp",
56+
"thread": "cpp",
57+
"typeinfo": "cpp"
58+
}
59+
}

res/matrix-sequencer.svg

Lines changed: 144 additions & 102 deletions
Loading

src/matrix-sequencer.cpp

Lines changed: 70 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
Matrix_sequencer::Matrix_sequencer() : _current_step(0, 0, 0), _run(true), _reset(false)
55
{
6+
_sequence_algorithms = {
7+
new LeftRight_UpDown(),
8+
new SpiralSequence()
9+
};
10+
611
{
712
config(PARAMS_LEN, INPUTS_LEN, OUTPUTS_LEN, LIGHTS_LEN);
813
configParam(X1_Y1_KNOB_PARAM, -10.f, 10.f, 0.f, "(1; 1)", "V");
@@ -21,9 +26,11 @@ Matrix_sequencer::Matrix_sequencer() : _current_step(0, 0, 0), _run(true), _rese
2126
configParam(X2_Y4_KNOB_PARAM, -10.f, 10.f, 0.f, "(2; 4)", "V");
2227
configParam(X3_Y4_KNOB_PARAM, -10.f, 10.f, 0.f, "(3; 4)", "V");
2328
configParam(X4_Y4_KNOB_PARAM, -10.f, 10.f, 0.f, "(4; 4)", "V");
29+
configParam(ALGORITHM_KNOB_PARAM, 0.f, _sequence_algorithms.size() - 1, 0.f, "Algorithm");
2430
configInput(CLOCK_IN_INPUT, "Clock");
2531
configInput(RUN_IN_INPUT, "Start sequence");
2632
configInput(RESET_IN_INPUT, "Reset sequence");
33+
configInput(ALGORITHM_FM_INPUT, "Control algorithms");
2734
configOutput(Y1_OUT_OUTPUT, "Out Y:1");
2835
configOutput(Y2_OUT_OUTPUT, "Out Y:2");
2936
configOutput(Y3_OUT_OUTPUT, "Out Y:3");
@@ -34,6 +41,15 @@ Matrix_sequencer::Matrix_sequencer() : _current_step(0, 0, 0), _run(true), _rese
3441
configOutput(X4_OUT_OUTPUT, "Out X:4");
3542
configOutput(TOTAL_PITCH_OUT_OUTPUT, "Sequence output");
3643
}
44+
45+
paramQuantities[ALGORITHM_KNOB_PARAM]->snapEnabled = true;
46+
}
47+
48+
49+
Matrix_sequencer::~Matrix_sequencer()
50+
{
51+
for (auto alg_ptr : _sequence_algorithms)
52+
delete alg_ptr;
3753
}
3854

3955

@@ -59,7 +75,8 @@ void Matrix_sequencer::process(const ProcessArgs& args)
5975
lights[translateCoords()].setBrightness(0);
6076

6177
//------------ Current Step = chosen callback algorithm ------------//
62-
_current_step = static_cast<sequence_t>(SequnceAlgorithm_base(_current_step));
78+
// _current_step = static_cast<sequence_t>(SequnceAlgorithm_base(_current_step));
79+
_sequence_algorithms.at(params[ALGORITHM_KNOB_PARAM].getValue())->callback(_current_step);
6380
float param_voltage = params[translateCoords()].getValue();
6481

6582
outputs[_current_step.y].setVoltage(param_voltage);
@@ -78,7 +95,8 @@ inline uint8_t Matrix_sequencer::translateCoords()
7895
}
7996

8097

81-
Matrix_sequencerWidget::Matrix_sequencerWidget(Matrix_sequencer* module) {
98+
Matrix_sequencerWidget::Matrix_sequencerWidget(Matrix_sequencer* module)
99+
{
82100
setModule(module);
83101
setPanel(createPanel(asset::plugin(pluginInstance, "res/matrix-sequencer.svg")));
84102

@@ -87,53 +105,56 @@ Matrix_sequencerWidget::Matrix_sequencerWidget(Matrix_sequencer* module) {
87105
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
88106
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
89107

90-
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(35.56, 20.32)), module, Matrix_sequencer::X1_Y1_KNOB_PARAM));
91-
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(63.5, 20.32)), module, Matrix_sequencer::X2_Y1_KNOB_PARAM));
92-
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(91.44, 20.32)), module, Matrix_sequencer::X3_Y1_KNOB_PARAM));
93-
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(119.38, 20.32)), module, Matrix_sequencer::X4_Y1_KNOB_PARAM));
94-
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(35.56, 43.18)), module, Matrix_sequencer::X1_Y2_KNOB_PARAM));
95-
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(63.5, 43.18)), module, Matrix_sequencer::X2_Y2_KNOB_PARAM));
96-
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(91.44, 43.18)), module, Matrix_sequencer::X3_Y2_KNOB_PARAM));
97-
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(119.38, 43.18)), module, Matrix_sequencer::X4_Y2_KNOB_PARAM));
98-
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(35.56, 66.04)), module, Matrix_sequencer::X1_Y3_KNOB_PARAM));
99-
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(63.5, 66.04)), module, Matrix_sequencer::X2_Y3_KNOB_PARAM));
100-
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(91.44, 66.04)), module, Matrix_sequencer::X3_Y3_KNOB_PARAM));
101-
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(119.38, 66.04)), module, Matrix_sequencer::X4_Y3_KNOB_PARAM));
102-
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(35.56, 88.9)), module, Matrix_sequencer::X1_Y4_KNOB_PARAM));
103-
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(63.5, 88.9)), module, Matrix_sequencer::X2_Y4_KNOB_PARAM));
104-
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(91.44, 88.9)), module, Matrix_sequencer::X3_Y4_KNOB_PARAM));
105-
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(119.38, 88.9)), module, Matrix_sequencer::X4_Y4_KNOB_PARAM));
106-
107-
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(12.7, 25.4)), module, Matrix_sequencer::CLOCK_IN_INPUT));
108-
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(12.7, 43.18)), module, Matrix_sequencer::RUN_IN_INPUT));
109-
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(12.7, 60.96)), module, Matrix_sequencer::RESET_IN_INPUT));
110-
111-
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(137.16, 20.32)), module, Matrix_sequencer::Y1_OUT_OUTPUT));
112-
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(137.16, 43.18)), module, Matrix_sequencer::Y2_OUT_OUTPUT));
113-
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(137.16, 66.04)), module, Matrix_sequencer::Y3_OUT_OUTPUT));
114-
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(137.16, 88.9)), module, Matrix_sequencer::Y4_OUT_OUTPUT));
115-
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(35.56, 119.38)), module, Matrix_sequencer::X1_OUT_OUTPUT));
116-
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(63.5, 119.38)), module, Matrix_sequencer::X2_OUT_OUTPUT));
117-
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(91.44, 119.38)), module, Matrix_sequencer::X3_OUT_OUTPUT));
118-
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(119.38, 119.38)), module, Matrix_sequencer::X4_OUT_OUTPUT));
119-
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(137.16, 119.38)), module, Matrix_sequencer::TOTAL_PITCH_OUT_OUTPUT));
120-
121-
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(35.56, 31.75)), module, Matrix_sequencer::X1_Y1_LIGHT_LIGHT));
122-
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(63.5, 31.75)), module, Matrix_sequencer::X2_Y1_LIGHT_LIGHT));
123-
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(91.44, 31.75)), module, Matrix_sequencer::X3_Y1_LIGHT_LIGHT));
124-
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(119.38, 31.75)), module, Matrix_sequencer::X4_Y1_LIGHT_LIGHT));
125-
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(35.56, 54.61)), module, Matrix_sequencer::X1_Y2_LIGHT_LIGHT));
126-
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(63.5, 54.61)), module, Matrix_sequencer::X2_Y2_LIGHT_LIGHT));
127-
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(91.44, 54.61)), module, Matrix_sequencer::X3_Y2_LIGHT_LIGHT));
128-
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(119.38, 54.61)), module, Matrix_sequencer::X4_Y2_LIGHT_LIGHT));
129-
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(35.56, 77.47)), module, Matrix_sequencer::X1_Y3_LIGHT_LIGHT));
130-
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(63.5, 77.47)), module, Matrix_sequencer::X2_Y3_LIGHT_LIGHT));
131-
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(91.44, 77.47)), module, Matrix_sequencer::X3_Y3_LIGHT_LIGHT));
132-
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(119.38, 77.47)), module, Matrix_sequencer::X4_Y3_LIGHT_LIGHT));
133-
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(35.56, 100.33)), module, Matrix_sequencer::X1_Y4_LIGHT_LIGHT));
134-
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(63.5, 100.33)), module, Matrix_sequencer::X2_Y4_LIGHT_LIGHT));
135-
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(91.44, 100.33)), module, Matrix_sequencer::X3_Y4_LIGHT_LIGHT));
136-
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(119.38, 100.33)), module, Matrix_sequencer::X4_Y4_LIGHT_LIGHT));
108+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(43.18, 20.32)), module, Matrix_sequencer::X1_Y1_KNOB_PARAM));
109+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(71.12, 20.32)), module, Matrix_sequencer::X2_Y1_KNOB_PARAM));
110+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(99.06, 20.32)), module, Matrix_sequencer::X3_Y1_KNOB_PARAM));
111+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(127.0, 20.32)), module, Matrix_sequencer::X4_Y1_KNOB_PARAM));
112+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(43.18, 43.18)), module, Matrix_sequencer::X1_Y2_KNOB_PARAM));
113+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(71.12, 43.18)), module, Matrix_sequencer::X2_Y2_KNOB_PARAM));
114+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(99.06, 43.18)), module, Matrix_sequencer::X3_Y2_KNOB_PARAM));
115+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(127.0, 43.18)), module, Matrix_sequencer::X4_Y2_KNOB_PARAM));
116+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(43.18, 66.04)), module, Matrix_sequencer::X1_Y3_KNOB_PARAM));
117+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(71.12, 66.04)), module, Matrix_sequencer::X2_Y3_KNOB_PARAM));
118+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(99.06, 66.04)), module, Matrix_sequencer::X3_Y3_KNOB_PARAM));
119+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(127.0, 66.04)), module, Matrix_sequencer::X4_Y3_KNOB_PARAM));
120+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(43.18, 88.9)), module, Matrix_sequencer::X1_Y4_KNOB_PARAM));
121+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(71.12, 88.9)), module, Matrix_sequencer::X2_Y4_KNOB_PARAM));
122+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(99.06, 88.9)), module, Matrix_sequencer::X3_Y4_KNOB_PARAM));
123+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(127.0, 88.9)), module, Matrix_sequencer::X4_Y4_KNOB_PARAM));
124+
125+
addParam(createParamCentered<RoundHugeBlackKnob>(mm2px(Vec(20.32, 88.9)), module, Matrix_sequencer::ALGORITHM_KNOB_PARAM));
126+
127+
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(20.32, 25.4)), module, Matrix_sequencer::CLOCK_IN_INPUT));
128+
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(20.32, 43.18)), module, Matrix_sequencer::RUN_IN_INPUT));
129+
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(20.32, 60.96)), module, Matrix_sequencer::RESET_IN_INPUT));
130+
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(20.32, 73.66)), module, Matrix_sequencer::ALGORITHM_FM_INPUT));
131+
132+
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(144.78, 20.32)), module, Matrix_sequencer::Y1_OUT_OUTPUT));
133+
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(144.78, 43.18)), module, Matrix_sequencer::Y2_OUT_OUTPUT));
134+
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(144.78, 66.04)), module, Matrix_sequencer::Y3_OUT_OUTPUT));
135+
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(144.78, 88.9)), module, Matrix_sequencer::Y4_OUT_OUTPUT));
136+
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(43.18, 119.38)), module, Matrix_sequencer::X1_OUT_OUTPUT));
137+
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(71.12, 119.38)), module, Matrix_sequencer::X2_OUT_OUTPUT));
138+
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(99.06, 119.38)), module, Matrix_sequencer::X3_OUT_OUTPUT));
139+
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(127.0, 119.38)), module, Matrix_sequencer::X4_OUT_OUTPUT));
140+
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(144.78, 119.38)), module, Matrix_sequencer::TOTAL_PITCH_OUT_OUTPUT));
141+
142+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(43.18, 31.75)), module, Matrix_sequencer::X1_Y1_LIGHT_LIGHT));
143+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(71.12, 31.75)), module, Matrix_sequencer::X2_Y1_LIGHT_LIGHT));
144+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(99.06, 31.75)), module, Matrix_sequencer::X3_Y1_LIGHT_LIGHT));
145+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(127.0, 31.75)), module, Matrix_sequencer::X4_Y1_LIGHT_LIGHT));
146+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(43.18, 54.61)), module, Matrix_sequencer::X1_Y2_LIGHT_LIGHT));
147+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(71.12, 54.61)), module, Matrix_sequencer::X2_Y2_LIGHT_LIGHT));
148+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(99.06, 54.61)), module, Matrix_sequencer::X3_Y2_LIGHT_LIGHT));
149+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(127.0, 54.61)), module, Matrix_sequencer::X4_Y2_LIGHT_LIGHT));
150+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(43.18, 77.47)), module, Matrix_sequencer::X1_Y3_LIGHT_LIGHT));
151+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(71.12, 77.47)), module, Matrix_sequencer::X2_Y3_LIGHT_LIGHT));
152+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(99.06, 77.47)), module, Matrix_sequencer::X3_Y3_LIGHT_LIGHT));
153+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(127.0, 77.47)), module, Matrix_sequencer::X4_Y3_LIGHT_LIGHT));
154+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(43.18, 100.33)), module, Matrix_sequencer::X1_Y4_LIGHT_LIGHT));
155+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(71.12, 100.33)), module, Matrix_sequencer::X2_Y4_LIGHT_LIGHT));
156+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(99.06, 100.33)), module, Matrix_sequencer::X3_Y4_LIGHT_LIGHT));
157+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(127.0, 100.33)), module, Matrix_sequencer::X4_Y4_LIGHT_LIGHT));
137158
}
138159

139160

src/matrix-sequencer.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define MATRIX_SEQUNCER
33

44
#include "plugin.hpp"
5-
#include "sequence_algorithm.hpp"
5+
#include "sequence_algorithms.hpp"
66

77
struct Matrix_sequencer : Module {
88
enum ParamId {
@@ -22,13 +22,15 @@ struct Matrix_sequencer : Module {
2222
X2_Y4_KNOB_PARAM,
2323
X3_Y4_KNOB_PARAM,
2424
X4_Y4_KNOB_PARAM,
25+
ALGORITHM_KNOB_PARAM,
2526
PARAMS_LEN
2627
};
2728

2829
enum InputId {
2930
CLOCK_IN_INPUT,
3031
RUN_IN_INPUT,
3132
RESET_IN_INPUT,
33+
ALGORITHM_FM_INPUT,
3234
INPUTS_LEN
3335
};
3436

@@ -67,6 +69,8 @@ struct Matrix_sequencer : Module {
6769

6870
Matrix_sequencer();
6971

72+
~Matrix_sequencer();
73+
7074
void process(const ProcessArgs& args) override;
7175

7276
private:
@@ -77,6 +81,7 @@ struct Matrix_sequencer : Module {
7781
bool _reset;
7882
sequence_t _current_step;
7983
dsp::SchmittTrigger clockTrigger;
84+
std::vector<SequenceAlgorithm_base*> _sequence_algorithms;
8085
};
8186

8287
struct Matrix_sequencerWidget : ModuleWidget

src/sequence_algorithm.cpp

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/sequence_algorithm.hpp

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/sequence_algorithms.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include "sequence_algorithms.hpp"
2+
3+
void SequenceAlgorithm_base::callback(sequence_t &current_step)
4+
{
5+
throw std::runtime_error("Call of pure virtual function\n");
6+
}
7+
8+
void LeftRight_UpDown::callback(sequence_t &current_step)
9+
{
10+
uint8_t* direction = reinterpret_cast<uint8_t*>((&current_step.x) + (current_step.round & 1));
11+
uint8_t* shift = reinterpret_cast<uint8_t*>((&current_step.y) - (current_step.round & 1));
12+
13+
(*direction)++;
14+
if ((*direction) > 3)
15+
{
16+
(*direction) = 0;
17+
(*shift)++ ;
18+
}
19+
20+
if ((*shift) > 3)
21+
{
22+
(*shift) = 0;
23+
current_step.round++ ;
24+
}
25+
};
26+
27+
28+
void SpiralSequence::callback(sequence_t &current_step)
29+
{
30+
current_step.x++;
31+
if (current_step.x > 3)
32+
{
33+
current_step.x = 0;
34+
current_step.y++ ;
35+
}
36+
37+
if (current_step.y > 3)
38+
{
39+
current_step.y = 0;
40+
current_step.round++ ;
41+
}
42+
}

0 commit comments

Comments
 (0)