mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-05 22:24:47 +08:00
Add the ability to reset a mixer group. Report the remaining buffer size from load_from_buf.
This commit is contained in:
@@ -233,6 +233,11 @@ public:
|
||||
*/
|
||||
void add_mixer(Mixer *mixer);
|
||||
|
||||
/**
|
||||
* Remove all the mixers from the group.
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* Adds mixers to the group based on a text description in a buffer.
|
||||
*
|
||||
@@ -269,10 +274,11 @@ public:
|
||||
* R: <geometry> <roll scale> <pitch scale> <yaw scale> <deadband>
|
||||
*
|
||||
* @param buf The mixer configuration buffer.
|
||||
* @param buflen The length of the buffer.
|
||||
* @param buflen The length of the buffer, updated to reflect
|
||||
* bytes as they are consumed.
|
||||
* @return Zero on successful load, nonzero otherwise.
|
||||
*/
|
||||
int load_from_buf(const char *buf, unsigned buflen);
|
||||
int load_from_buf(const char *buf, unsigned &buflen);
|
||||
|
||||
private:
|
||||
Mixer *_first; /**< linked list of mixers */
|
||||
|
||||
@@ -64,14 +64,7 @@ MixerGroup::MixerGroup(ControlCallback control_cb, uintptr_t cb_handle) :
|
||||
|
||||
MixerGroup::~MixerGroup()
|
||||
{
|
||||
Mixer *mixer;
|
||||
|
||||
/* discard sub-mixers */
|
||||
while (_first != nullptr) {
|
||||
mixer = _first;
|
||||
_first = mixer->_next;
|
||||
delete mixer;
|
||||
}
|
||||
reset();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -88,6 +81,19 @@ MixerGroup::add_mixer(Mixer *mixer)
|
||||
mixer->_next = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
MixerGroup::reset()
|
||||
{
|
||||
Mixer *mixer;
|
||||
|
||||
/* discard sub-mixers */
|
||||
while (_first != nullptr) {
|
||||
mixer = _first;
|
||||
_first = mixer->_next;
|
||||
delete mixer;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned
|
||||
MixerGroup::mix(float *outputs, unsigned space)
|
||||
{
|
||||
@@ -114,7 +120,7 @@ MixerGroup::groups_required(uint32_t &groups)
|
||||
}
|
||||
|
||||
int
|
||||
MixerGroup::load_from_buf(const char *buf, unsigned buflen)
|
||||
MixerGroup::load_from_buf(const char *buf, unsigned &buflen)
|
||||
{
|
||||
int ret = -1;
|
||||
const char *end = buf + buflen;
|
||||
|
||||
Reference in New Issue
Block a user