Skip to content

Commit 569d53c

Browse files
authored
Merge pull request #446 from rosflight/ptt/move_pwm
Move sending of PWM from the mixer to the main loop.
2 parents 995cc5c + de7dae2 commit 569d53c

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

include/mixer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ class Mixer : public ParamListenerInterface
284284
void param_change_callback(uint16_t param_id) override;
285285
void set_new_aux_command(aux_command_t new_aux_command);
286286
inline const float * get_outputs() const { return raw_outputs_; }
287-
287+
float * raw_outputs() { return raw_outputs_; } // board pwm write does not expect a const value.
288+
288289
void calculate_mixer_values();
289290
void mix_multirotor();
290291
void mix_fixedwing();

src/mixer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,6 @@ void Mixer::mix_output()
700700
raw_outputs_[i] = value;
701701
}
702702
}
703-
RF_.board_.pwm_write_multi(raw_outputs_, NUM_TOTAL_OUTPUTS);
704703
}
705704

706705
} // namespace rosflight_firmware

src/rosflight.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,15 @@ void ROSflight::run()
106106
/*********************/
107107
/*** Control Loop ***/
108108
/*********************/
109-
uint64_t start = board_.clock_micros();
110-
109+
111110
got_flags got = sensors_.run(); // IMU, GNSS, Baro, Mag, Pitot, SONAR, Battery
112111

113112
if (got.imu) {
113+
uint64_t start = board_.clock_micros();
114114
estimator_.run();
115115
controller_.run();
116116
mixer_.mix_output();
117+
board_.pwm_write_multi(mixer_.raw_outputs(), Mixer::NUM_TOTAL_OUTPUTS);
117118
loop_time_us = board_.clock_micros() - start;
118119
}
119120

0 commit comments

Comments
 (0)