PX4 Firmware
PX4 Autopilot Software http://px4.io
SimpleMixer Class Reference

Simple summing mixer. More...

#include <SimpleMixer.hpp>

Inheritance diagram for SimpleMixer:
Collaboration diagram for SimpleMixer:

Public Member Functions

 SimpleMixer (ControlCallback control_cb, uintptr_t cb_handle, mixer_simple_s *mixinfo)
 Constructor. More...
 
virtual ~SimpleMixer ()
 
 SimpleMixer (const SimpleMixer &)=delete
 
SimpleMixeroperator= (const SimpleMixer &)=delete
 
 SimpleMixer (SimpleMixer &&)=delete
 
SimpleMixeroperator= (SimpleMixer &&)=delete
 
unsigned mix (float *outputs, unsigned space) override
 Perform the mixing function. 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 ~Mixer ()=default
 
 Mixer (const Mixer &)=delete
 
Mixeroperator= (const Mixer &)=delete
 
 Mixer (Mixer &&)=delete
 
Mixeroperator= (Mixer &&)=delete
 
virtual uint16_t get_saturation_status ()
 Get the saturation status. 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...
 
virtual unsigned get_multirotor_count ()
 
- Public Member Functions inherited from ListNode< Mixer *>
void setSibling (Mixer * sibling)
 
const MixergetSibling () const
 

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 Private Member Functions

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 int parse_output_scaler (const char *buf, unsigned &buflen, mixer_scaler_s &scaler)
 
static int parse_control_scaler (const char *buf, unsigned &buflen, mixer_scaler_s &scaler, uint8_t &control_group, uint8_t &control_index)
 

Private Attributes

mixer_simple_s_pinfo
 

Additional Inherited Members

- Public Types inherited from Mixer
enum  Airmode : int32_t { Airmode::disabled = 0, Airmode::roll_pitch = 1, Airmode::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...
 
- 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 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. More...
 
- Protected Attributes inherited from Mixer
ControlCallback _control_cb
 client-supplied callback used when fetching control values More...
 
uintptr_t _cb_handle
 
- Protected Attributes inherited from ListNode< Mixer *>
Mixer_list_node_sibling
 

Detailed Description

Simple summing mixer.

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

Definition at line 68 of file SimpleMixer.hpp.

Constructor & Destructor Documentation

◆ SimpleMixer() [1/3]

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.

Definition at line 48 of file SimpleMixer.cpp.

Referenced by from_text().

Here is the caller graph for this function:

◆ ~SimpleMixer()

SimpleMixer::~SimpleMixer ( )
virtual

Definition at line 54 of file SimpleMixer.cpp.

References _pinfo.

◆ SimpleMixer() [2/3]

SimpleMixer::SimpleMixer ( const SimpleMixer )
delete

◆ SimpleMixer() [3/3]

SimpleMixer::SimpleMixer ( SimpleMixer &&  )
delete

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.

Definition at line 277 of file SimpleMixer.cpp.

References Mixer::_cb_handle, Mixer::_control_cb, _pinfo, mixer_simple_s::control_count, mixer_control_s::control_group, mixer_control_s::control_index, mixer_simple_s::controls, mixer_simple_s::output_scaler, scale_check(), and mixer_control_s::scaler.

Here is the call graph for this function:

◆ 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.

Definition at line 148 of file SimpleMixer.cpp.

References mixer_simple_s::control_count, mixer_control_s::control_group, mixer_control_s::control_index, mixer_simple_s::controls, debug, Mixer::findnexttag(), mixer_scaler_s::max_output, mixer_scaler_s::min_output, MIXER_SIMPLE_SIZE, mixer_scaler_s::negative_scale, mixer_scaler_s::offset, mixer_simple_s::output_scaler, parse_control_scaler(), parse_output_scaler(), mixer_scaler_s::positive_scale, mixer_control_s::scaler, SimpleMixer(), Mixer::skipline(), and Mixer::string_well_formed().

Referenced by MixerGroup::load_from_buf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_trim()

unsigned SimpleMixer::get_trim ( float *  trim)
overridevirtual

Get trim offset for this mixer.

Returns
the number of outputs this mixer feeds to

Reimplemented from Mixer.

Definition at line 67 of file SimpleMixer.cpp.

References _pinfo, mixer_scaler_s::offset, and mixer_simple_s::output_scaler.

◆ 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.

Reimplemented from Mixer.

Definition at line 269 of file SimpleMixer.cpp.

References _pinfo, mixer_simple_s::control_count, mixer_control_s::control_group, and mixer_simple_s::controls.

◆ 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.

Definition at line 241 of file SimpleMixer.cpp.

References Mixer::_cb_handle, Mixer::_control_cb, _pinfo, mixer_simple_s::control_count, mixer_control_s::control_group, mixer_control_s::control_index, mixer_simple_s::controls, mixer_simple_s::output_scaler, scale(), and mixer_control_s::scaler.

Here is the call graph for this function:

◆ operator=() [1/2]

SimpleMixer& SimpleMixer::operator= ( const SimpleMixer )
delete

◆ operator=() [2/2]

SimpleMixer& SimpleMixer::operator= ( SimpleMixer &&  )
delete

◆ parse_control_scaler()

int SimpleMixer::parse_control_scaler ( const char *  buf,
unsigned &  buflen,
mixer_scaler_s scaler,
uint8_t &  control_group,
uint8_t &  control_index 
)
staticprivate

Definition at line 110 of file SimpleMixer.cpp.

References debug, Mixer::findtag(), mixer_scaler_s::max_output, mixer_scaler_s::min_output, mixer_scaler_s::negative_scale, mixer_scaler_s::offset, mixer_scaler_s::positive_scale, and Mixer::skipline().

Referenced by from_text().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_output_scaler()

int SimpleMixer::parse_output_scaler ( const char *  buf,
unsigned &  buflen,
mixer_scaler_s scaler 
)
staticprivate

Definition at line 74 of file SimpleMixer.cpp.

References debug, Mixer::findtag(), mixer_scaler_s::max_output, mixer_scaler_s::min_output, mixer_scaler_s::negative_scale, mixer_scaler_s::offset, mixer_scaler_s::positive_scale, and Mixer::skipline().

Referenced by from_text().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scale()

float SimpleMixer::scale ( const mixer_scaler_s scaler,
float  input 
)
staticprivate

Perform simpler linear scaling.

Parameters
scalerThe scaler configuration.
inputThe value to be scaled.
Returns
The scaled value.

Definition at line 317 of file SimpleMixer.cpp.

References math::constrain(), f(), mixer_scaler_s::max_output, mixer_scaler_s::min_output, mixer_scaler_s::negative_scale, mixer_scaler_s::offset, and mixer_scaler_s::positive_scale.

Referenced by mix().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scale_check()

int SimpleMixer::scale_check ( struct mixer_scaler_s scaler)
staticprivate

Validate a scaler.

Parameters
scalerThe scaler to be validated.
Returns
Zero if good, nonzero otherwise.

Definition at line 332 of file SimpleMixer.cpp.

References mixer_scaler_s::max_output, mixer_scaler_s::min_output, and mixer_scaler_s::offset.

Referenced by check().

Here is the caller graph for this function:

◆ set_trim()

unsigned SimpleMixer::set_trim ( float  trim)
overridevirtual

Set trim offset for this mixer.

Returns
the number of outputs this mixer feeds to

Reimplemented from Mixer.

Definition at line 61 of file SimpleMixer.cpp.

References _pinfo, mixer_scaler_s::offset, and mixer_simple_s::output_scaler.

Member Data Documentation

◆ _pinfo

mixer_simple_s* SimpleMixer::_pinfo
private

Definition at line 146 of file SimpleMixer.hpp.

Referenced by check(), get_trim(), groups_required(), mix(), set_trim(), and ~SimpleMixer().


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