stop at set volume
This commit is contained in:
parent
bf08fc69ff
commit
ffaa78798e
@ -14,37 +14,42 @@
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
// syringe definition
|
||||
typedef struct{
|
||||
char name[16]; // brand / name
|
||||
uint16_t diameter; // diameter (in µm)
|
||||
} pse_syringe;
|
||||
|
||||
// Ports available
|
||||
typedef enum {PORT_X, PORT_Y, PORT_Z, PORT_E} pse_ports;
|
||||
|
||||
// stepper controller definitions
|
||||
typedef struct{
|
||||
uint16_t tim_presc;
|
||||
uint16_t tim_period;
|
||||
uint16_t tim_presc; // timer prescaler
|
||||
uint16_t tim_period; // timer period
|
||||
|
||||
uint32_t tick_counter;
|
||||
int32_t steps_counter;
|
||||
uint8_t stopAtHome;
|
||||
uint8_t stop_at_limit; // boolean to stop at stop_steps
|
||||
int32_t stop_steps; // position to stop at
|
||||
|
||||
GPIO_TypeDef* EN_GPIO_Port;
|
||||
GPIO_TypeDef* EN_GPIO_Port; // Pin definitions
|
||||
uint16_t EN_GPIO_Pin;
|
||||
GPIO_TypeDef* DIR_GPIO_Port;
|
||||
uint16_t DIR_GPIO_Pin;
|
||||
GPIO_TypeDef* STEP_GPIO_Port;
|
||||
uint16_t STEP_GPIO_Pin;
|
||||
|
||||
TIM_HandleTypeDef* tim;
|
||||
TIM_HandleTypeDef* tim; // timer assigned to this unit
|
||||
} pse_stepper_conf;
|
||||
|
||||
// readout widgets associated with this unit
|
||||
typedef struct{
|
||||
lv_obj_t* flow;
|
||||
lv_obj_t* volume;
|
||||
lv_obj_t* enabled;
|
||||
} pse_home_display;
|
||||
|
||||
// unit definition
|
||||
typedef struct{
|
||||
uint8_t enabled;
|
||||
pse_ports port; // physical port on which this unit is connected
|
||||
|
@ -36,6 +36,13 @@ static void back_button_handler(lv_event_t * e){
|
||||
// compute volume delivered per steps
|
||||
pse_unit_compute_volume_per_step(c_pse_unit);
|
||||
|
||||
// set limit if volume defined
|
||||
if(c_pse_unit->set_volume != 0){
|
||||
c_pse_unit->stepper_conf->stop_at_limit = 1;
|
||||
c_pse_unit->stepper_conf->stop_steps = (uint64_t)1000 * c_pse_unit->set_volume / c_pse_unit->nL_per_step; }
|
||||
else
|
||||
c_pse_unit->stepper_conf->stop_at_limit = 0;
|
||||
|
||||
// go back to the main menu
|
||||
Home_Screen_Gen(c_pse_units, c_pse_units_num, true);
|
||||
}
|
||||
|
@ -96,7 +96,8 @@ static void unit_home_handler(lv_event_t * e){
|
||||
pse_unit* unit = lv_event_get_user_data(e);
|
||||
pse_stepper_conf* c = unit->stepper_conf;
|
||||
if(c->steps_counter == 0) return;
|
||||
c->stopAtHome = 1;
|
||||
c->stop_at_limit = 1;
|
||||
c->stop_steps = 0;
|
||||
pse_sp_jog_speed(c, 1);
|
||||
pse_sp_set_dir(c, c->steps_counter < 0);
|
||||
pse_sp_start_axis(c);
|
||||
|
@ -18,13 +18,15 @@ void pse_stepper_planer_tick(pse_unit* unit){
|
||||
|
||||
HAL_GPIO_TogglePin(c->STEP_GPIO_Port, c->STEP_GPIO_Pin);
|
||||
c->steps_counter += (pse_sp_get_dir(c)?1:-1) * HAL_GPIO_ReadPin(c->STEP_GPIO_Port, c->STEP_GPIO_Pin);
|
||||
if(c->stopAtHome && c->steps_counter == 0){
|
||||
if(c->stop_at_limit && c->steps_counter == c->stop_steps){
|
||||
pse_sp_jog_speed(c, 0);
|
||||
pse_sp_stop_axis(c);
|
||||
}
|
||||
}
|
||||
|
||||
void pse_sp_start_axis(pse_stepper_conf* conf){
|
||||
if(conf->stop_at_limit && conf->steps_counter == conf->stop_steps) return;
|
||||
|
||||
HAL_GPIO_WritePin(conf->EN_GPIO_Port, conf->EN_GPIO_Pin, GPIO_PIN_RESET);
|
||||
HAL_TIM_Base_Start_IT(conf->tim);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user