Skip to content

Commit

Permalink
reworked the way mixers were assigned to use the enums instead of the…
Browse files Browse the repository at this point in the history
… array of pointers
  • Loading branch information
JMoore5353 committed Dec 17, 2024
1 parent e0eee63 commit 1f01b73
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 80 deletions.
34 changes: 17 additions & 17 deletions include/mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class Mixer : public ParamListenerInterface

typedef struct
{
mixer_t* primary_mixer_ptr;
output_type_t (*output_type)[NUM_MIXER_OUTPUTS];
float (*default_pwm_rate)[NUM_MIXER_OUTPUTS];
float (*Fx)[NUM_MIXER_OUTPUTS];
Expand Down Expand Up @@ -121,12 +120,12 @@ class Mixer : public ParamListenerInterface
aux_command_t aux_command_;
output_type_t combined_output_type_[NUM_TOTAL_OUTPUTS];

void add_header_to_mixer(mixer_t* mixer);
void load_primary_mixer_values();
void load_secondary_mixer_values();
mixer_t invert_mixer(const mixer_t* mixer_to_invert);
mixer_t invert_mixer(const mixer_t mixer_to_invert);
float mix_multirotor_with_motor_parameters(Controller::Output commands);
float mix_multirotor_without_motor_parameters(Controller::Output commands);
void select_primary_or_secondary_mixer();

// clang-format off

Expand Down Expand Up @@ -254,20 +253,21 @@ class Mixer : public ParamListenerInterface
mixer_t secondary_mixer_;

mixer_selection_t mixer_to_use_;

const mixer_t* array_of_mixers_[NUM_MIXERS] = {
&esc_calibration_mixing,
&quadcopter_plus_mixing,
&quadcopter_x_mixing,
&hex_plus_mixing,
&hex_x_mixing,
&octocopter_plus_mixing,
&octocopter_x_mixing,
&Y6_mixing,
&X8_mixing,
&fixedwing_mixing,
&fixedwing_inverted_vtail_mixing,
&custom_mixing,
bool primary_mixer_is_selected_ = false;

const mixer_t array_of_mixers_[NUM_MIXERS] = {
esc_calibration_mixing,
quadcopter_plus_mixing,
quadcopter_x_mixing,
hex_plus_mixing,
hex_x_mixing,
octocopter_plus_mixing,
octocopter_x_mixing,
Y6_mixing,
X8_mixing,
fixedwing_mixing,
fixedwing_inverted_vtail_mixing,
custom_mixing,
};

// clang-format on
Expand Down
Loading

2 comments on commit 1f01b73

@avtoku
Copy link
Contributor

@avtoku avtoku commented on 1f01b73 Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think as-is it this doubles the memory storage for the pre-defined mixers. I think you can fix that by putting the values inside array_of_mixers_[] definition. Then you have to match the index with mixer_type_t. This is not really better than just keeping the code as it was. We should discuss this offline.

@JMoore5353
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I didn't think of the additional memory required.

Please sign in to comment.