Optimize step/dir callback

This commit is contained in:
Unknown
2020-07-26 16:16:10 -04:00
parent aa73bc907e
commit 88b3ed4260
4 changed files with 11 additions and 13 deletions
+3 -3
View File
@@ -3,7 +3,7 @@
{
"name": "Win32",
"includePath": [
"${workspaceRoot}/**"
"${workspaceFolder}/**"
],
"defines": [
"STM32F405xx",
@@ -24,7 +24,7 @@
{
"name": "Linux",
"includePath": [
"${workspaceRoot}/**"
"${workspaceFolder}/**"
],
"defines": [
"STM32F405xx",
@@ -44,7 +44,7 @@
{
"name": "Mac",
"includePath": [
"${workspaceRoot}/**"
"${workspaceFolder}/**"
],
"defines": [
"STM32F405xx",
+4 -6
View File
@@ -118,12 +118,10 @@ bool Axis::wait_for_current_meas() {
// step/direction interface
void Axis::step_cb() {
if (step_dir_active_) {
GPIO_PinState dir_pin = HAL_GPIO_ReadPin(dir_port_, dir_pin_);
float dir = (dir_pin == GPIO_PIN_SET) ? 1.0f : -1.0f;
controller_.input_pos_ += dir * config_.counts_per_step;
controller_.input_pos_updated();
}
const GPIO_PinState dir_pin = (GPIO_PinState)(dir_port_->IDR & dir_pin_);
const int32_t dir = (1 - 2 * (int32_t)dir_pin) * step_dir_active_;
controller_.input_pos_ += dir * config_.counts_per_step;
controller_.input_pos_updated();
};
void Axis::load_default_step_dir_pin_config(
-3
View File
@@ -26,9 +26,6 @@ void Controller::set_error(Error error) {
// Command Handling
//--------------------------------
void Controller::input_pos_updated() {
input_pos_updated_ = true;
}
bool Controller::select_encoder(size_t encoder_num) {
if (encoder_num < AXIS_COUNT) {
+4 -1
View File
@@ -52,7 +52,10 @@ public:
void reset();
void set_error(Error error);
void input_pos_updated();
constexpr void input_pos_updated() {
input_pos_updated_ = true;
}
bool select_encoder(size_t encoder_num);
// Trajectory-Planned control