Skip to content

Commit

Permalink
Updated to effector v6.1.3, which adds a check to see whether a chann…
Browse files Browse the repository at this point in the history
…el was configured.
  • Loading branch information
flybrianfly committed May 18, 2021
1 parent a83d2c6 commit 395b598
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## v4.0.5
- Updated to effector v6.1.3, which adds a check to see whether a channel was configured.

## v4.0.4
- throttle_en compared to zero instead of a cast to bool. Now, true if greater than zero.

Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (DEFINED MCU)
endif()
# Project information
project(Sbus
VERSION 4.0.4
VERSION 4.0.5
DESCRIPTION "SBUS encoder and decoder"
LANGUAGES C CXX
)
Expand All @@ -32,7 +32,7 @@ if (DEFINED MCU)
FetchContent_Declare(
effector
GIT_REPOSITORY https://github.com/bolderflight/effector.git
GIT_TAG v6.1.0
GIT_TAG v6.1.3
)
FetchContent_MakeAvailable(effector)
# Fetch polytools
Expand Down
43 changes: 23 additions & 20 deletions include/sbus/sbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,30 @@ class SbusTx {
void Cmd(std::span<const float> cmds) {
std::size_t len = std::min(cmds.size(), N);
for (std::size_t i = 0; i < len; i++) {
/* Saturation */
if (cmds[i] > config_.effectors[i].max) {
val_ = config_.effectors[i].max;
} else if (cmds[i] < config_.effectors[i].min) {
val_ = config_.effectors[i].min;
} else {
val_ = cmds[i];
/* Check whether the channel was configured */
if (config_.effectors[i].ch >=0) {
/* Saturation */
if (cmds[i] > config_.effectors[i].max) {
val_ = config_.effectors[i].max;
} else if (cmds[i] < config_.effectors[i].min) {
val_ = config_.effectors[i].min;
} else {
val_ = cmds[i];
}
/* Motor check */
if ((config_.effectors[i].type == MOTOR) && (!motors_enabled_)) {
val_ = config_.effectors[i].failsafe;
}
/* Servo check */
if ((config_.effectors[i].type == SERVO) && (!servos_enabled_)) {
val_ = config_.effectors[i].failsafe;
}
/* polyval */
std::span<float> coef{config_.effectors[i].poly_coef,
static_cast<std::size_t>(config_.effectors[i].num_coef)};
ch_[config_.effectors[i].ch] = static_cast<uint16_t>(
polyval<float>(coef, val_));
}
/* Motor check */
if ((config_.effectors[i].type == MOTOR) && (!motors_enabled_)) {
val_ = config_.effectors[i].failsafe;
}
/* Servo check */
if ((config_.effectors[i].type == SERVO) && (!servos_enabled_)) {
val_ = config_.effectors[i].failsafe;
}
/* polyval */
std::span<float> coef{config_.effectors[i].poly_coef,
static_cast<std::size_t>(config_.effectors[i].num_coef)};
ch_[config_.effectors[i].ch] = static_cast<uint16_t>(
polyval<float>(coef, val_));
}
}
void Write() {
Expand Down

0 comments on commit 395b598

Please sign in to comment.