diff --git a/syringefilled.cpp b/syringefilled.cpp index 3750fd9f27eaea78ebfe6af0705ecb206443b54f..29b3fecb7fb59ad6dbf101876a5081f7eac2ec91 100644 --- a/syringefilled.cpp +++ b/syringefilled.cpp @@ -16,9 +16,11 @@ SyringeFilled :: SyringeFilled (MotorHardware_t& stepper): Motor(stepper) set_remaining_volume_mL(1); set_push(true); set_name_syringe("BD_10mL"); - set_screw_thread_mm(4); set_clockwise_equals_push(true); + set_lead_screw_pitch_mm(0.7); set_syringe_pump_length_mm(50); + set_microstep_configuration(16); + set_motor_steps(200); set_emergency(false); } @@ -45,13 +47,9 @@ void SyringeFilled :: set_push(bool push) syringe_filled_json["push"] = push; } -void SyringeFilled :: set_name_syringe(String name_syringe){ - syringe_filled_json["name_syringe"] = name_syringe; -} - -void SyringeFilled :: set_screw_thread_mm(float screw_thread_mm) +void SyringeFilled :: set_name_syringe(String name_syringe) { - syringe_filled_json["screw_thread_mm"] = screw_thread_mm; + syringe_filled_json["name_syringe"] = name_syringe; } void SyringeFilled :: set_clockwise_equals_push(bool clockwise_equals_push) @@ -64,6 +62,21 @@ void SyringeFilled :: set_syringe_pump_length_mm(float syringe_pump_length_mm) syringe_filled_json["syringe_pump_length_mm"] = syringe_pump_length_mm; } +void SyringeFilled :: set_lead_screw_pitch_mm(float lead_screw_pitch_mm) +{ + syringe_filled_json["lead_screw_pitch_mm"] = lead_screw_pitch_mm; +} + +void SyringeFilled :: set_microstep_configuration(int microstep_configuration) +{ + syringe_filled_json["microstep_configuration"] = microstep_configuration; +} + +void SyringeFilled :: set_motor_steps(int motor_steps) +{ + syringe_filled_json["motor_steps"] = motor_steps; +} + void SyringeFilled :: set_emergency(bool emergency) { syringe_filled_json["emergency"] = emergency; @@ -96,11 +109,6 @@ String SyringeFilled :: get_name_syringe() return syringe_filled_json["name_syringe"].as<String>(); } -float SyringeFilled :: get_screw_thread_mm() -{ - return syringe_filled_json["screw_thread_mm"].as<float>(); -} - bool SyringeFilled :: get_clockwise_equals_push() { return syringe_filled_json["clockwise_equals_push"].as<bool>(); @@ -111,6 +119,21 @@ float SyringeFilled :: get_syringe_pump_length_mm() return syringe_filled_json["syringe_pump_length_mm"].as<float>(); } +float SyringeFilled :: get_lead_screw_pitch_mm() +{ + return syringe_filled_json["lead_screw_pitch_mm"].as<float>(); +} + +int SyringeFilled :: get_microstep_configuration() +{ + return syringe_filled_json["microstep_configuration"].as<int>(); +} + +int SyringeFilled :: get_motor_steps() +{ + return syringe_filled_json["motor_steps"].as<int>(); +} + bool SyringeFilled :: get_emergency() { return syringe_filled_json["emergency"].as<bool>(); diff --git a/syringefilled.h b/syringefilled.h index 82b6c23c040a00056d56a0774c017ff999aef51b..8bef682fb2b0133cc484a81c4743a81b6438a4e0 100644 --- a/syringefilled.h +++ b/syringefilled.h @@ -37,6 +37,9 @@ class SyringeFilled : public Motor float _screw_thread_mm; bool _clockwise_equals_push; float _syringe_pump_length_mm; + float _lead_screw_pitch_mm; + int _microstep_configuration; + int _motor_steps; //Limit_Switch bool _emergency; diff --git a/web.cpp b/web.cpp index a06ab42dd4e68da1567f8b5aeb516c51d2962898..db4c0e34f571ae48f26349dba42f76454a114a1a 100644 --- a/web.cpp +++ b/web.cpp @@ -130,6 +130,10 @@ void web_setup () clockwise_equals_push = ESPUI.addControl(ControlType::Switcher, "Sens de rotation du moteur", "Horaire =", ControlColor::None, clockwise_equals_push_label, clockwise_equals_push_callback); ESPUI.updateSwitcher(clockwise_equals_push, true); //set "Horaire = Injection" at the beginning + microstep_configuration = ESPUI.addControl(ControlType::Number, "Configuration Hardware des microsteps", "16", ControlColor::None, features, microstep_configuration_callback); + + motor_steps = ESPUI.addControl(ControlType::Number, "Caractéristique du moteur (nombre de pas possibles ?)", "2000", ControlColor::None, features, motor_steps_callback); + @@ -636,6 +640,44 @@ void clockwise_equals_push_callback(Control* sender, int value) Serial.println(""); } +void microstep_configuration_callback(Control* sender, int type) +/*** +-Argument : Pointer to the controller calling the function, integer according to the controller type. +-Return : / +-Action : Print the value of the number controller via the serial port. + Change the microstep_configuration value. +***/ +{ + syringe_filled.set_microstep_configuration(sender->type); + syringe_filled.write_Json(); + + serial_print ("microstep_configuration (sender->value)", sender); + + Serial.println("microstep_configuration (json value)"); + Serial.println(String("Value: ") + String(syringe_filled.get_microstep_configuration())); + Serial.println(""); +} + +void motor_steps_callback(Control* sender, int type) +/*** +-Argument : Pointer to the controller calling the function, integer according to the controller type. +-Return : / +-Action : Print the value of the number controller via the serial port. + Change the motor_steps value. +***/ +{ + syringe_filled.set_motor_steps(sender->type); + syringe_filled.write_Json(); + + serial_print ("motor_steps (sender->value)", sender); + + Serial.println("motor_steps (json value)"); + Serial.println(String("Value: ") + String(syringe_filled.get_motor_steps())); + Serial.println(""); +} + + + // void syringe_selection_callback(Control* sender, int value) @@ -763,7 +805,8 @@ void set_initial_style() style (lead_screw_pitch_mm, 3); style (clockwise_equals_push_label, 3); style (clockwise_equals_push, 3); - + style (microstep_configuration, 3); + style (motor_steps, 3); // @@ -950,6 +993,17 @@ void web_loop () else style_syringe_pump_off(); + if (syringe_filled.get_emergency()) + { + ESPUI.print(status_syringe_pump, "On"); + style (status_limit_switch, 1); + } + else + { + ESPUI.print(status_syringe_pump, "Off"); + style (status_limit_switch, 2); + } + } } diff --git a/web.h b/web.h index a796389e524894dbc44aa50326b579c9342da7fb..e5d3d146848b8515226e2748491038ea6d46bb9e 100644 --- a/web.h +++ b/web.h @@ -46,7 +46,7 @@ String name_new_syringe_value, total_volume_mL_new_syringe_value, internal_diame //Features uint16_t syringe_pump_length_mm_value; -uint16_t lead_screw_pitch_mm, clockwise_equals_push_label, clockwise_equals_push; +uint16_t lead_screw_pitch_mm, clockwise_equals_push_label, clockwise_equals_push, microstep_configuration, motor_steps; //Other @@ -109,6 +109,8 @@ void add_syringe_callback (Control* sender, int value, void* param); //features : Configurations avancées void syringe_pump_length_mm_callback(Control* sender, int type); void clockwise_equals_push_callback(Control* sender, int value); +void microstep_configuration_callback(Control* sender, int type); +void motor_steps_callback(Control* sender, int type); // void syringe_selection_callback(Control* sender, int value);