diff --git a/Core/Inc/pse_stepper_planer.h b/Core/Inc/pse_stepper_planer.h index c9b9f11..66462de 100644 --- a/Core/Inc/pse_stepper_planer.h +++ b/Core/Inc/pse_stepper_planer.h @@ -17,7 +17,7 @@ void pse_sp_start_axis(pse_stepper_conf* conf); void pse_sp_stop_axis(pse_stepper_conf* conf); void pse_sp_set_dir(pse_stepper_conf* conf, int dir); -//int pse_sp_get_dir(pse_stepper_conf* conf); +int pse_sp_get_dir(pse_stepper_conf* conf); void pse_stepper_planer_tick(pse_unit* units, uint8_t units_num); void pse_sp_start_all(pse_unit* units, int unit_num); diff --git a/Core/Src/home_screen.c b/Core/Src/home_screen.c index e30b85e..abd3c61 100644 --- a/Core/Src/home_screen.c +++ b/Core/Src/home_screen.c @@ -70,7 +70,7 @@ static void unit_home_handler(lv_event_t * e){ pse_stepper_conf* c = unit->stepper_conf; c->stopAtHome = 1; c->step_max = 1; - pse_sp_set_dir(c, 1); + pse_sp_set_dir(c, 0); pse_sp_start_axis(c); } } diff --git a/Core/Src/pse_stepper_planer.c b/Core/Src/pse_stepper_planer.c index b477fff..508321a 100644 --- a/Core/Src/pse_stepper_planer.c +++ b/Core/Src/pse_stepper_planer.c @@ -29,10 +29,10 @@ void pse_stepper_planer_tick(pse_unit* units, uint8_t units_num){ } c->tick_counter++; HAL_GPIO_WritePin(c->STEP_GPIO_Port, c->STEP_GPIO_Pin, state); - /*c->steps_counter += (pse_sp_get_dir(c)?1:-1) * (state?1:0); + c->steps_counter += (pse_sp_get_dir(c)?1:-1) * (state?1:0); if(c->stopAtHome && c->steps_counter == 0){ pse_sp_stop_axis(c); - }*/ + } } } @@ -58,9 +58,9 @@ void pse_sp_set_dir(pse_stepper_conf* conf, int dir){ HAL_GPIO_WritePin(conf->DIR_GPIO_Port, conf->DIR_GPIO_Pin, dir); } -/*int pse_sp_get_dir(pse_stepper_conf* conf){ +int pse_sp_get_dir(pse_stepper_conf* conf){ return HAL_GPIO_ReadPin(conf->DIR_GPIO_Port, conf->DIR_GPIO_Pin); -}*/ +} void pse_stepper_planer_compute_sps(pse_unit* unit){ pse_stepper_conf* c = unit->stepper_conf; @@ -73,21 +73,22 @@ void pse_stepper_planer_compute_sps(pse_unit* unit){ void pse_sp_start_all(pse_unit* units, int units_num){ HAL_TIM_Base_Start_IT(htim); - units_running = units_num; for(int i = 0; i < units_num; i++){ - if(units[i].enabled) + if(units[i].enabled){ pse_sp_start_axis(units[i].stepper_conf); + units_running++; + } } } void pse_sp_stop_all(pse_unit* units, int units_num){ - HAL_TIM_Base_Stop_IT(htim); - units_running = 0; - for(int i = 0; i < units_num; i++){ if(units[i].enabled) pse_sp_stop_axis(units[i].stepper_conf); } + + HAL_TIM_Base_Stop_IT(htim); + units_running = 0; } void pse_sp_set_timer(TIM_HandleTypeDef* tim){