mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 17:58:52 +08:00
mixer: delete unused SimpleMixer::pwm_input()
This commit is contained in:
@@ -239,68 +239,6 @@ out:
|
||||
return sm;
|
||||
}
|
||||
|
||||
SimpleMixer *
|
||||
SimpleMixer::pwm_input(Mixer::ControlCallback control_cb, uintptr_t cb_handle, unsigned input, uint16_t min,
|
||||
uint16_t mid, uint16_t max)
|
||||
{
|
||||
SimpleMixer *sm = nullptr;
|
||||
mixer_simple_s *mixinfo = nullptr;
|
||||
|
||||
mixinfo = (mixer_simple_s *)malloc(MIXER_SIMPLE_SIZE(1));
|
||||
|
||||
if (mixinfo == nullptr) {
|
||||
debug("could not allocate memory for mixer info");
|
||||
goto out;
|
||||
}
|
||||
|
||||
mixinfo->control_count = 1;
|
||||
|
||||
/*
|
||||
* Always pull from group 0, with the input value giving the channel.
|
||||
*/
|
||||
mixinfo->controls[0].control_group = 0;
|
||||
mixinfo->controls[0].control_index = input;
|
||||
|
||||
/*
|
||||
* Conversion uses both the input and output side of the mixer.
|
||||
*
|
||||
* The input side is used to slide the control value such that the min argument
|
||||
* results in a value of zero.
|
||||
*
|
||||
* The output side is used to apply the scaling for the min/max values so that
|
||||
* the resulting output is a -1.0 ... 1.0 value for the min...max range.
|
||||
*/
|
||||
mixinfo->controls[0].scaler.negative_scale = 1.0f;
|
||||
mixinfo->controls[0].scaler.positive_scale = 1.0f;
|
||||
mixinfo->controls[0].scaler.offset = -mid;
|
||||
mixinfo->controls[0].scaler.min_output = -(mid - min);
|
||||
mixinfo->controls[0].scaler.max_output = (max - mid);
|
||||
|
||||
mixinfo->output_scaler.negative_scale = 500.0f / (mid - min);
|
||||
mixinfo->output_scaler.positive_scale = 500.0f / (max - mid);
|
||||
mixinfo->output_scaler.offset = 0.0f;
|
||||
mixinfo->output_scaler.min_output = -1.0f;
|
||||
mixinfo->output_scaler.max_output = 1.0f;
|
||||
|
||||
sm = new SimpleMixer(control_cb, cb_handle, mixinfo);
|
||||
|
||||
if (sm != nullptr) {
|
||||
mixinfo = nullptr;
|
||||
debug("PWM input mixer for %d", input);
|
||||
|
||||
} else {
|
||||
debug("could not allocate memory for PWM input mixer");
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
if (mixinfo != nullptr) {
|
||||
free(mixinfo);
|
||||
}
|
||||
|
||||
return sm;
|
||||
}
|
||||
|
||||
unsigned
|
||||
SimpleMixer::mix(float *outputs, unsigned space)
|
||||
{
|
||||
|
||||
@@ -86,22 +86,6 @@ public:
|
||||
static SimpleMixer *from_text(Mixer::ControlCallback control_cb, uintptr_t cb_handle, const char *buf,
|
||||
unsigned &buflen);
|
||||
|
||||
/**
|
||||
* Factory method for PWM/PPM input to internal float representation.
|
||||
*
|
||||
* @param control_cb The callback to invoke when fetching a
|
||||
* control value.
|
||||
* @param cb_handle Handle passed to the control callback.
|
||||
* @param input The control index used when fetching the input.
|
||||
* @param min The PWM/PPM value considered to be "minimum" (gives -1.0 out)
|
||||
* @param mid The PWM/PPM value considered to be the midpoint (gives 0.0 out)
|
||||
* @param max The PWM/PPM value considered to be "maximum" (gives 1.0 out)
|
||||
* @return A new SimpleMixer instance, or nullptr if one could not be
|
||||
* allocated.
|
||||
*/
|
||||
static SimpleMixer *pwm_input(Mixer::ControlCallback control_cb, uintptr_t cb_handle, unsigned input, uint16_t min,
|
||||
uint16_t mid, uint16_t max);
|
||||
|
||||
unsigned mix(float *outputs, unsigned space) override;
|
||||
|
||||
void groups_required(uint32_t &groups) override;
|
||||
|
||||
@@ -51,7 +51,7 @@ int load_mixer_file(const char *fname, char *buf, unsigned maxlen)
|
||||
/* open the mixer definition file */
|
||||
fp = fopen(fname, "r");
|
||||
|
||||
if (fp == NULL) {
|
||||
if (fp == nullptr) {
|
||||
printf("file not found\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ int load_mixer_file(const char *fname, char *buf, unsigned maxlen)
|
||||
/* get a line, bail on error/EOF */
|
||||
line[0] = '\0';
|
||||
|
||||
if (fgets(line, sizeof(line), fp) == NULL) {
|
||||
if (fgets(line, sizeof(line), fp) == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user