fix reverse dir
This commit is contained in:
parent
65789dd269
commit
87e7f219dd
@ -113,7 +113,7 @@ static void unit_home_handler(lv_event_t * e){
|
|||||||
s->stop_at_limit = 1;
|
s->stop_at_limit = 1;
|
||||||
s->stop_steps = 0;
|
s->stop_steps = 0;
|
||||||
pse_sp_jog_speed(c, s, 1);
|
pse_sp_jog_speed(c, s, 1);
|
||||||
pse_sp_set_dir(c, s->steps_counter < 0);
|
pse_sp_set_dir(unit, s->steps_counter < 0);
|
||||||
pse_sp_start_axis(c, s);
|
pse_sp_start_axis(c, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,13 +38,13 @@ void pse_sp_stop_axis(pse_stepper_conf* conf){
|
|||||||
|
|
||||||
void pse_sp_set_dir(pse_unit* unit, int dir){
|
void pse_sp_set_dir(pse_unit* unit, int dir){
|
||||||
pse_stepper_conf* conf = unit->stepper_conf;
|
pse_stepper_conf* conf = unit->stepper_conf;
|
||||||
HAL_GPIO_WritePin(conf->DIR_GPIO_Port, conf->DIR_GPIO_Pin, unit->reversed?-dir:dir);
|
HAL_GPIO_WritePin(conf->DIR_GPIO_Port, conf->DIR_GPIO_Pin, unit->reversed?(!dir):dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
int pse_sp_get_dir(pse_unit* unit){
|
int pse_sp_get_dir(pse_unit* unit){
|
||||||
pse_stepper_conf* conf = unit->stepper_conf;
|
pse_stepper_conf* conf = unit->stepper_conf;
|
||||||
int val = HAL_GPIO_ReadPin(conf->DIR_GPIO_Port, conf->DIR_GPIO_Pin);
|
int val = HAL_GPIO_ReadPin(conf->DIR_GPIO_Port, conf->DIR_GPIO_Pin);
|
||||||
return (unit->reversed?-val:val);
|
return (unit->reversed?(!val):val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
|
// https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
|
||||||
|
Loading…
x
Reference in New Issue
Block a user