mixer: use an enum for airmode

This commit is contained in:
Beat Küng
2018-12-13 09:50:07 +01:00
parent 9406fa5246
commit 19ccab28bb
11 changed files with 33 additions and 26 deletions
+10 -4
View File
@@ -140,6 +140,12 @@
class __EXPORT Mixer
{
public:
enum class Airmode : int32_t {
disabled = 0,
roll_pitch = 1,
roll_pitch_yaw = 2
};
/** next mixer in a list */
Mixer *_next;
@@ -223,7 +229,7 @@ public:
*
* @param[in] airmode Select airmode type (0 = disabled, 1 = roll/pitch, 2 = roll/pitch/yaw)
*/
virtual void set_airmode(int32_t airmode) {};
virtual void set_airmode(Airmode airmode) {};
protected:
/** client-supplied callback used when fetching control values */
@@ -419,7 +425,7 @@ public:
*/
void set_thrust_factor(float val) override;
void set_airmode(int32_t airmode) override;
void set_airmode(Airmode airmode) override;
private:
Mixer *_first; /**< linked list of mixers */
@@ -667,7 +673,7 @@ public:
*/
void set_thrust_factor(float val) override { _thrust_factor = val; }
void set_airmode(int32_t airmode) override;
void set_airmode(Airmode airmode) override;
union saturation_status {
struct {
@@ -694,7 +700,7 @@ private:
float _delta_out_max;
float _thrust_factor;
uint32_t _airmode;
Airmode _airmode;
void update_saturation_status(unsigned index, bool clipping_high, bool clipping_low);
saturation_status _saturation_status;
+1 -1
View File
@@ -188,7 +188,7 @@ MixerGroup::set_thrust_factor(float val)
}
void
MixerGroup::set_airmode(int32_t airmode)
MixerGroup::set_airmode(Airmode airmode)
{
Mixer *mixer = _first;
+3 -3
View File
@@ -72,7 +72,7 @@ MultirotorMixer::MultirotorMixer(ControlCallback control_cb,
_idle_speed(-1.0f + idle_speed * 2.0f), /* shift to output range here to avoid runtime calculation */
_delta_out_max(0.0f),
_thrust_factor(0.0f),
_airmode(0),
_airmode(Airmode::disabled),
_rotor_count(_config_rotor_count[(MultirotorGeometryUnderlyingType)geometry]),
_rotors(_config_index[(MultirotorGeometryUnderlyingType)geometry]),
_outputs_prev(new float[_rotor_count])
@@ -214,7 +214,7 @@ MultirotorMixer::mix(float *outputs, unsigned space)
boost = 1.0f - ((max_out - thrust) * roll_pitch_scale + thrust);
}
if (_airmode == 0) {
if (_airmode == Airmode::disabled) {
// disable positive boosting if not in air-mode
// boosting can only be positive when min_out < 0.0
// roll_pitch_scale is reduced accordingly
@@ -425,7 +425,7 @@ MultirotorMixer::update_saturation_status(unsigned index, bool clipping_high, bo
}
void
MultirotorMixer::set_airmode(int32_t airmode)
MultirotorMixer::set_airmode(Airmode airmode)
{
_airmode = airmode;
}