Closed awonak closed 6 months ago
For me that would work for the workflow but would prevent this Feature from working when compiling with arduino IDE right?
Right, I need to reevaluate my approach here, this feels like I'm doing something wrong.
Two ideas I'm exploring:
1) Add new lib methods to call from the Arduino sketch to change behavior. Example:
void setup() {
// Initialize the A-RYTH-MATIK peripherials.
hw.Init();
#ifdef ROTATE_PANEL
hw.RotatePanel();
#endif
...
}
2) Introduce config flags to Init()
.
#ifdef ROTATE_PANEL
bool rotate_panel = true;
#else
bool rotate_panel = false;
#endif
...
void setup() {
// Initialize the A-RYTH-MATIK peripherials.
hw.Init(rotate_panel=rotate_panel);
...
}
Although, I'm not sure either of those are the right solution either because they do not affect the peripheral pin definition: https://github.com/awonak/libModulove/blob/main/arythmatik_peripherials.h
Similar to the idea in option #2, instead of args in Init()
, define a config struct and the sketch can set config values based on #define
flags.
Then, with flag definitions like #define CLK_PIN 11
and #define CLK_PIN_REVERSED 13
, use the config to initialize the pin with either CLK_PIN or CLK_PIN_REVERSED depending on the provided config.
void Arythmatik::InitInputs(Config config) {
if (config.reverse_panel) {
clk.Init(CLK_PIN_REVERSED);
rst.Init(RST_PIN_REVERSED);
} else {
clk.Init(CLK_PIN);
rst.Init(RST_PIN);
}
}
@modulove please take a look and let me know if this makes sense and if you have any feedback. Thanks!
Looks good to me. Only one thing that is missing is that the outputs 1 - 4, 2 -5 , 3 - 6 need to be swapped as well for the reversed panel.
I hope this will make the module even more usefull with the user prefered mounting direction.
Thanks for integrating this quickly into the lib even though the euclid fw does not support it yet.
Cheers Linus
One caveat with this implementation is that the ROTATE_PANEL is used in the arythmatik.cpp source file, not the header file, so adding #define ROTATE_PANEL in the .ino filea .ino sketch is not enough to make it visible at compile time. To properly compile the sketch with the flag visible to the library, it must be compiled with the flag set as a build property:arduino-cli compile -b lgt8fx:avr:328 --build-property "build.extra_flags=-DROTATE_PANEL" BitGarden.ino -u -p /dev/ttyUSB0UPDATE:
Added a struct with configuration settings for changing the behavior of the A-RYTH-MATIK module.
The config values can be set in the sketch's
setup()
method by checking preproc build flags: