Skip to content

Задание относительных координат в SetTarget #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/GyverPlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,16 @@ class GPlanner {
}

// установить цель в шагах и начать движение. ~100 us
bool setTarget(int32_t target[], GS_posType type = ABSOLUTE) {
bool setTarget(const int32_t target[], GS_posType type = ABSOLUTE) {
if (changeSett) { // применяем настройки
setMaxSpeed(nV);
changeSett = 0;
}

S = 0; // путь
for (uint8_t i = 0; i < _AXLES; i++) { // для всех осей
if (type == RELATIVE) target[i] += steppers[i]->pos; // если относительное смещение - прибавляем текущий pos
tar[i] = target[i]; // запоминаем цель
if (type == RELATIVE) tar[i] += steppers[i]->pos; // если относительное смещение - прибавляем текущий pos
dS[i] = abs(tar[i] - steppers[i]->pos); // модуль ошибки по оси
steppers[i]->dir = (steppers[i]->pos < tar[i]) ? 1 : -1;// направление движения по оси
if (dS[i] > S) S = dS[i]; // ищем максимальное отклонение
Expand Down Expand Up @@ -246,7 +246,7 @@ class GPlanner {
return 1;
}

bool setTarget(int16_t target[], GS_posType type = ABSOLUTE) {
bool setTarget(const int16_t target[], GS_posType type = ABSOLUTE) {
int32_t tar[_AXLES];
for (uint8_t i = 0; i < _AXLES; i++) tar[i] = target[i];
return setTarget(tar, type);
Expand Down Expand Up @@ -400,4 +400,4 @@ class GPlanner {
bool changeSett = 0; // флаг, что изменились настройки
Stepper<_DRV>* steppers[_AXLES];
};
#endif
#endif