Attach Function Question #98
Replies: 1 comment
-
|
Hello @Schlappo22. I agree, these functions can get repetitive. One workaround would be to get rid of the parameter void increase_variable() {
uint8_t focused_line_index = menu.get_focusedLine();
// Convert the line's index to the variable's index:
uint8_t variable_index = focused_line_index; // in case they match
if (variables[variable_index][0] < variables[variable_index][1]) {
// ...
}But I don't know if this will be worth it, it's counterintuitive and error prone. The other way involves improving the library itself. The function pointer used in the library, expects a function with the signature: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I have been playing around with this library for some time now and improved my code further and further.
One thing that I can't seem to figure out is if there is another way of passing my function to X.attach_function. I have to go implement an extra step, which seems a bit unnecessary. Please see a snip of my example below. Is there a way to get rid of the very repetitive functions
void increase_variable_0etc. and instead pass theincrease_variable(0)directly to theX.attach_functionBeta Was this translation helpful? Give feedback.
All reactions