Firmware
Public Member Functions | Static Public Member Functions | List of all members
SimpleMixer Class Reference

Simple summing mixer. More...

#include <mixer.h>

Inheritance diagram for SimpleMixer:
Mixer

Public Member Functions

 SimpleMixer (ControlCallback control_cb, uintptr_t cb_handle, mixer_simple_s *mixinfo)
 Constructor. More...
 
unsigned mix (float *outputs, unsigned space) override
 Perform the mixing function. More...
 
uint16_t get_saturation_status (void) override
 Get the saturation status. More...
 
void groups_required (uint32_t &groups) override
 Analyses the mix configuration and updates a bitmask of groups that are required. More...
 
int check ()
 Check that the mixer configuration as loaded is sensible. More...
 
unsigned set_trim (float trim) override
 Set trim offset for this mixer. More...
 
unsigned get_trim (float *trim) override
 Get trim offset for this mixer. More...
 
- Public Member Functions inherited from Mixer
 Mixer (ControlCallback control_cb, uintptr_t cb_handle)
 Constructor. More...
 
virtual void set_max_delta_out_once (float delta_out_max)
 Empty method, only implemented for MultirotorMixer and MixerGroup class. More...
 
virtual void set_thrust_factor (float val)
 
virtual void set_airmode (Airmode airmode)
 Set airmode. More...
 

Static Public Member Functions

static SimpleMixerfrom_text (Mixer::ControlCallback control_cb, uintptr_t cb_handle, const char *buf, unsigned &buflen)
 Factory method with full external configuration. More...
 
static SimpleMixerpwm_input (Mixer::ControlCallback control_cb, uintptr_t cb_handle, unsigned input, uint16_t min, uint16_t mid, uint16_t max)
 Factory method for PWM/PPM input to internal float representation. More...
 

Additional Inherited Members

- Public Types inherited from Mixer
enum  Airmode : int32_t { disabled = 0, roll_pitch = 1, roll_pitch_yaw = 2 }
 
typedef int(* ControlCallback) (uintptr_t handle, uint8_t control_group, uint8_t control_index, float &control)
 Fetch a control value. More...
 
- Public Attributes inherited from Mixer
Mixer_next
 next mixer in a list
 
- Protected Member Functions inherited from Mixer
float get_control (uint8_t group, uint8_t index)
 Invoke the client callback to fetch a control value. More...
 
- Static Protected Member Functions inherited from Mixer
static float scale (const mixer_scaler_s &scaler, float input)
 Perform simpler linear scaling. More...
 
static int scale_check (struct mixer_scaler_s &scaler)
 Validate a scaler. More...
 
static const char * findtag (const char *buf, unsigned &buflen, char tag)
 Find a tag. More...
 
static char findnexttag (const char *buf, unsigned buflen)
 Find next tag and return it (0 is returned if no tag is found) More...
 
static const char * skipline (const char *buf, unsigned &buflen)
 Skip a line. More...
 
static bool string_well_formed (const char *buf, unsigned &buflen)
 Check wether the string is well formed and suitable for parsing.
 
- Protected Attributes inherited from Mixer
ControlCallback _control_cb
 client-supplied callback used when fetching control values
 
uintptr_t _cb_handle
 

Detailed Description

Simple summing mixer.

Collects zero or more inputs and mixes them to a single output.

Constructor & Destructor Documentation

§ SimpleMixer()

SimpleMixer::SimpleMixer ( ControlCallback  control_cb,
uintptr_t  cb_handle,
mixer_simple_s mixinfo 
)

Constructor.

Parameters
mixinfoMixer configuration. The pointer passed becomes the property of the mixer and will be freed when the mixer is deleted.

Member Function Documentation

§ check()

int SimpleMixer::check ( )

Check that the mixer configuration as loaded is sensible.

Note that this function will call control_cb, but only cares about error returns, not the input value.

Returns
Zero if the mixer makes sense, nonzero otherwise.

§ from_text()

SimpleMixer * SimpleMixer::from_text ( Mixer::ControlCallback  control_cb,
uintptr_t  cb_handle,
const char *  buf,
unsigned &  buflen 
)
static

Factory method with full external configuration.

Given a pointer to a buffer containing a text description of the mixer, returns a pointer to a new instance of the mixer.

Parameters
control_cbThe callback to invoke when fetching a control value.
cb_handleHandle passed to the control callback.
bufBuffer containing a text description of the mixer.
buflenLength of the buffer in bytes, adjusted to reflect the bytes consumed.
Returns
A new SimpleMixer instance, or nullptr if the text format is bad.

§ get_saturation_status()

uint16_t SimpleMixer::get_saturation_status ( void  )
overridevirtual

Get the saturation status.

Returns
Integer bitmask containing saturation_status from multirotor_motor_limits.msg.

Implements Mixer.

§ get_trim()

unsigned SimpleMixer::get_trim ( float *  trim)
overridevirtual

Get trim offset for this mixer.

Returns
the number of outputs this mixer feeds to

Implements Mixer.

§ groups_required()

void SimpleMixer::groups_required ( uint32_t &  groups)
overridevirtual

Analyses the mix configuration and updates a bitmask of groups that are required.

Parameters
groupsA bitmask of groups (0-31) that the mixer requires.

Implements Mixer.

§ mix()

unsigned SimpleMixer::mix ( float *  outputs,
unsigned  space 
)
overridevirtual

Perform the mixing function.

Parameters
outputsArray into which mixed output(s) should be placed.
spaceThe number of available entries in the output array;
Returns
The number of entries in the output array that were populated.

Implements Mixer.

§ pwm_input()

SimpleMixer * SimpleMixer::pwm_input ( Mixer::ControlCallback  control_cb,
uintptr_t  cb_handle,
unsigned  input,
uint16_t  min,
uint16_t  mid,
uint16_t  max 
)
static

Factory method for PWM/PPM input to internal float representation.

Parameters
control_cbThe callback to invoke when fetching a control value.
cb_handleHandle passed to the control callback.
inputThe control index used when fetching the input.
minThe PWM/PPM value considered to be "minimum" (gives -1.0 out)
midThe PWM/PPM value considered to be the midpoint (gives 0.0 out)
maxThe PWM/PPM value considered to be "maximum" (gives 1.0 out)
Returns
A new SimpleMixer instance, or nullptr if one could not be allocated.

§ set_trim()

unsigned SimpleMixer::set_trim ( float  trim)
overridevirtual

Set trim offset for this mixer.

Returns
the number of outputs this mixer feeds to

Implements Mixer.


The documentation for this class was generated from the following files: