Skip to content

Commit

Permalink
Merge pull request #11 from apaex/patch-1
Browse files Browse the repository at this point in the history
Задание относительных координат в SetTarget
  • Loading branch information
GyverLibs authored Nov 29, 2022
2 parents 8e42f0e + 4f7716a commit 31e4345
Showing 1 changed file with 4 additions and 4 deletions.
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

0 comments on commit 31e4345

Please sign in to comment.