diff --git a/syringefilled.cpp b/syringefilled.cpp index aeaeacb69e0feac9dd6453865e8dae515efb0543..500091f37f30416563361df5a46d15ec6ee9c7aa 100644 --- a/syringefilled.cpp +++ b/syringefilled.cpp @@ -18,6 +18,7 @@ SyringeFilled :: SyringeFilled (MotorHardware_t& stepper): Motor(stepper) set_name_syringe("BD_10mL"); set_screw_thread_mm(4); set_clockwise_equals_push(true); + set_syringe_pump_length_mm(50); set_emergency(false); } @@ -58,6 +59,11 @@ void SyringeFilled :: set_clockwise_equals_push(bool clockwise_equals_push) syringe_filled_json["clockwise_equals_push"] = clockwise_equals_push; } +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_emergency(bool emergency) { syringe_filled_json["emergency"] = emergency; @@ -97,7 +103,12 @@ float SyringeFilled :: get_screw_thread_mm() bool SyringeFilled :: get_clockwise_equals_push() { - return syringe_filled_json["clockwise_equals_push"].as<float>(); + return syringe_filled_json["clockwise_equals_push"].as<bool>(); +} + +float SyringeFilled :: get_syringe_pump_length_mm() +{ + return syringe_filled_json["syringe_pump_length_mm"].as<float>(); } bool SyringeFilled :: get_emergency() @@ -176,11 +187,11 @@ void SyringeFilled :: move() if (where_step() == 0) //If we are putting the syringe for the first time { - move_to_mm(syringe_pump_length_mm - remaining_volume_mm3/section_mm2); + move_to_mm(get_syringe_pump_length_mm() - remaining_volume_mm3/section_mm2); } else { - float initial_position_mm = syringe_pump_length_mm - remaining_volume_mm3/section_mm2; + float initial_position_mm = get_syringe_pump_length_mm() - remaining_volume_mm3/section_mm2; if (get_push()) //If we want to deliver some liquid { diff --git a/syringefilled.h b/syringefilled.h index 3c590a977eff9ac724ddfccfc0cd97f3a87561fe..4a5e224f4ab3aded6f4a491fd069e1de72db3470 100644 --- a/syringefilled.h +++ b/syringefilled.h @@ -11,7 +11,6 @@ using InterruptLock = esp8266::InterruptLock; #include "common.h" -#define syringe_pump_length_mm 50 class SyringeFilled : public Motor { @@ -37,6 +36,7 @@ class SyringeFilled : public Motor //Syringe_Pump float _screw_thread_mm; bool _clockwise_equals_push; + float _syringe_pump_length_mm; //Limit_Switch bool _emergency; @@ -58,6 +58,7 @@ class SyringeFilled : public Motor void set_name_syringe(String name_syringe); void set_screw_thread_mm(float screw_thread_mm); void set_clockwise_equals_push(bool clockwise_equals_push); + void set_syringe_pump_length_mm(float syringe_pump_length_mm); void set_emergency(bool emergency); @@ -69,6 +70,7 @@ class SyringeFilled : public Motor String get_name_syringe(); float get_screw_thread_mm(); bool get_clockwise_equals_push(); + float get_syringe_pump_length_mm(); bool get_emergency(); const StaticJsonDocument<200>& get_syringe_filled_data(); diff --git a/web.cpp b/web.cpp index c22fd09b3fbebf6a7f3001e9e03dd06d10517b44..b1cfb33580dd83d07e88b5aa5d3db7df7e79db29 100644 --- a/web.cpp +++ b/web.cpp @@ -109,7 +109,7 @@ void web_setup () //Features - syringe_pump_length_mm_bis = ESPUI.addControl(ControlType::Number, "Longueur totale du pousse-seringue", "50", ControlColor::None, features, syringe_pump_length_mm_callback); + syringe_pump_length_mm_value = ESPUI.addControl(ControlType::Number, "Longueur totale du pousse-seringue", "50", ControlColor::None, features, syringe_pump_length_mm_callback); lead_screw_pitch_mm = ESPUI.addControl(ControlType::Number, "Avance par tour", "0.7", ControlColor::None, features, number_callback); clockwise_equals_push_label = ESPUI.addControl(ControlType::Label, "Sens de rotation du moteur", "Horaire = Injection", ControlColor::None, features); clockwise_equals_push = ESPUI.addControl(ControlType::Switcher, "Sens de rotation du moteur", "Horaire =", ControlColor::None, clockwise_equals_push_label, clockwise_equals_push_callback); @@ -602,12 +602,14 @@ void syringe_pump_length_mm_callback(Control* sender, int type) -Action : Print the value of the number controller via the serial port. ***/ { + syringe_filled.set_syringe_pump_length_mm(sender->type); + Serial.println("syringe_pump_lenggth (sender->value)"); Serial.println(String("Value: ") + String(sender->value)); Serial.println(String("ID: ") + sender->id); Serial.println(""); //Serial.println("syringe_pump_length (json value)"); - //Serial.println(String("Value: ") + String(syringe_filled.get_syringe_pump_length())); + //Serial.println(String("Value: ") + String(syringe_filled.get_syringe_pump_length_mm())); //Serial.println(""); } @@ -836,7 +838,7 @@ void set_init_style() //features - style (syringe_pump_length_mm_bis, 3); + style (syringe_pump_length_mm_value, 3); style (lead_screw_pitch_mm, 3); style (clockwise_equals_push_label, 3); style (clockwise_equals_push, 3); @@ -911,7 +913,7 @@ void web_loop () //UPDATES - ESPUI.updateSlider(remaining_volume_mL, syringe_filled.step_to_mm(syringe_filled.where_step()*100/syringe_pump_length_mm)); + ESPUI.updateSlider(remaining_volume_mL, syringe_filled.step_to_mm(syringe_filled.where_step()*100/syringe_filled.get_syringe_pump_length_mm())); //syringe_filled.update_remaining_volume(); diff --git a/web.h b/web.h index 33eb7a0d164533e854ac8aca55a3afda5cfc9792..36d6325735f2aba7676830245cb5ea45a4753042 100644 --- a/web.h +++ b/web.h @@ -12,7 +12,6 @@ #include <EEPROM.h> -#define syringe_pump_length_mm 50 //Create tabs uint16_t configurations, new_syringe, features; @@ -44,7 +43,7 @@ uint16_t name_new_syringe, name_new_syringe_label, internal_diameter_mm_new_syri String name_new_syringe_value, total_volume_mL_new_syringe_value, internal_diameter_mm_new_syringe_value; //Features -uint16_t syringe_pump_length_mm_bis; +uint16_t syringe_pump_length_mm_value; uint16_t lead_screw_pitch_mm, clockwise_equals_push_label, clockwise_equals_push;