From 70f348bdfd2b249ba09e13702b2394cdf1c5e5f2 Mon Sep 17 00:00:00 2001
From: Malaurie Bernard <mbernard@kinouby>
Date: Wed, 26 Jul 2023 14:22:34 +0200
Subject: [PATCH] Modification of the graphical interface (addition of small
 logos and change of switches to buttons)

---
 web.cpp | 84 ++++++++++++++++++++++++++++++++-------------------------
 web.h   | 11 +++++---
 2 files changed, 54 insertions(+), 41 deletions(-)

diff --git a/web.cpp b/web.cpp
index d95aaee..b639b2a 100644
--- a/web.cpp
+++ b/web.cpp
@@ -18,10 +18,10 @@ void web_setup ()
     //***Syringe-pump***//
     status_syringe_pump = ESPUI.label("Etat du pousse-seringue :", ControlColor::None, "A l'arrêt");
 
-    activation_syringe_pump = ESPUI.addControl(ControlType::Switcher, "Mise en marche", "Arrêt", ControlColor::None, status_syringe_pump, activation_syringe_pump_callback, (void*)19);
+    stop_syringe_pump = ESPUI.addControl(ControlType::Button, "Mise en marche", "\u26D4", ControlColor::None, status_syringe_pump, stop_syringe_pump_callback, (void*)19);
 
     //***Syringe-filled***//
-    status_syringe_filled = ESPUI.label("Etat de la seringue :", ControlColor::None, "Pas en place");
+    status_syringe_filled = ESPUI.label("Etat de la seringue :", ControlColor::None, "Enlevée");
 
     syringe_filled_placement = ESPUI.addControl(ControlType::Switcher, "Mise en marche", "Arrêt", ControlColor::None, status_syringe_filled, syringe_filled_placement_callback, (void*)19);
 
@@ -29,12 +29,12 @@ void web_setup ()
 
 
     //***Initialisation***//
-    calibration = ESPUI.button("Callibration", calibration_callback, ControlColor::None, "Lancer");
+    calibration = ESPUI.button("Callibration", calibration_callback, ControlColor::None, "\u21E4");
 
-    fast_backward = ESPUI.button("Initialisation", fast_backward_callback, ControlColor::None, "Reculer rapidement");
-    fast_forward = ESPUI.addControl(ControlType::Button, "Initialisation", "Avancer rapidement", ControlColor::None, fast_backward, fast_forward_callback);
-    slow_backward = ESPUI.addControl(ControlType::Button, "Initialisation", "Reculer doucement", ControlColor::None, fast_backward, slow_backward_callback);
-    slow_forward = ESPUI.addControl(ControlType::Button, "Initialisation", "Avancer doucement", ControlColor::None, fast_backward, slow_forward_callback);
+    fast_backward = ESPUI.button("Initialisation", fast_backward_callback, ControlColor::None, "\u2BC7 \u2BC7");
+    slow_backward = ESPUI.addControl(ControlType::Button, "Initialisation", "\u2BC7", ControlColor::None, fast_backward, slow_backward_callback);
+    slow_forward = ESPUI.addControl(ControlType::Button, "Initialisation", "\u2BC8", ControlColor::None, fast_backward, slow_forward_callback);
+    fast_forward =  ESPUI.addControl(ControlType::Button, "Initialisation", "\u2BC8 \u2BC8", ControlColor::None, fast_backward, fast_forward_callback);
 
     ESPUI.addControl(ControlType::Separator, "", "", ControlColor::None);
 
@@ -58,6 +58,9 @@ void web_setup ()
     ESPUI.updateSwitcher(switch_push_pull_choice, true); //pour mettre a "Injection" par défaut au début
 
 
+    start_exchange = ESPUI.addControl(ControlType::Button, "Start exchange", "\xF0\x9F\x8F\x81", ControlColor::None, volume_exchange_mL_label, start_exchange_callback, (void*)19);
+
+
     //Configurations
 
     //Choice_of_syringe_model
@@ -73,8 +76,13 @@ void web_setup ()
     syringe_diameter_mm_string = "internal diameter : " + std::to_string(syringe_volume_mL_value) + "mm";
     syringe_diameter_mm =ESPUI.addControl( ControlType::Label, "Caractéristiques de la seringue : ", syringe_diameter_mm_string.c_str(), ControlColor::None, syringe_volume_mL);
 
-    choose_syringe = ESPUI.addControl(ControlType::Button, "Choisir cette seringue", "Utiliser cette seringue", ControlColor::None, syringe_selection, choose_syringe_callback, (void*)19);
+    syringe_initial_volume_mL =  ESPUI.addControl( ControlType::Number, "Volume initial contenu dans la seringue : ", "0", ControlColor::None, syringe_volume_mL, syringe_initial_volume_mL_callback, (void*)19);
+
+    choose_syringe = ESPUI.addControl(ControlType::Button, "Choisir cette seringue", "\u2714", ControlColor::None, syringe_selection, choose_syringe_callback, (void*)19);
   
+
+
+
     ESPUI.addControl(ControlType::Separator, "", "", ControlColor::None, configurations);
    
 
@@ -84,11 +92,13 @@ void web_setup ()
     internal_diameter_mm_new_syringe_label =ESPUI.addControl(ControlType::Label, "Nouvelle seringue", "Diamètre interne de la seringue en mm :", ControlColor::None, name_new_syringe_label);
     internal_diameter_mm_new_syringe = ESPUI.addControl(ControlType::Number, "Diamètre interne de la seringue en mm", "5", ControlColor::None, name_new_syringe_label, internal_diameter_mm_new_syringe_callback);
     internal_diameter_mm_new_syringe_value = 5;
-    total_volume_mL_new_syringe_label =ESPUI.addControl(ControlType::Label, "Nouvelle seringue", "Volume total de la seringue en µL :", ControlColor::None, name_new_syringe_label);
-    total_volume_mL_new_syringe = ESPUI.addControl(ControlType::Number, "Volume total de la seringue en µL", "5", ControlColor::None, name_new_syringe_label, total_volume_mL_new_syringe_callback);
+    total_volume_mL_new_syringe_label =ESPUI.addControl(ControlType::Label, "Nouvelle seringue", "Volume total de la seringue en mL :", ControlColor::None, name_new_syringe_label);
+    total_volume_mL_new_syringe = ESPUI.addControl(ControlType::Number, "Volume total de la seringue en mL", "5", ControlColor::None, name_new_syringe_label, total_volume_mL_new_syringe_callback);
     total_volume_mL_new_syringe_value = 5;
-    add_syringe_label =ESPUI.addControl(ControlType::Label, "Nouvelle seringue", "Ajouter la seringue", ControlColor::None, name_new_syringe_label);
-    add_syringe = ESPUI.addControl(ControlType::Button, "Ajouter la seringue", "Valider", ControlColor::None, name_new_syringe_label, add_syringe_callback, (void*)19);
+
+    ESPUI.addControl(ControlType::Separator, "Je suis là", "", ControlColor::None, name_new_syringe_label);
+
+    add_syringe = ESPUI.addControl(ControlType::Button, "Ajouter la seringue", "\u2714", ControlColor::None, new_syringe, add_syringe_callback, (void*)19);
 
 
     //Features
@@ -122,28 +132,15 @@ void number_callback(Control* sender, int type)
 
 //***ABOVE***//
 
-void activation_syringe_pump_callback (Control* sender, int value, void* param)
+void stop_syringe_pump_callback (Control* sender, int value, void* param)
 /***
 -Argument : Pointer to the controller calling the function, integer according to the controller type.
 -Return   : /
 -Action   : Linking the switch of the syringe pump status and the actions.
 ***/
 {
+    syringe_pump_off();
 
-    Serial.println(String("param: ") + String(long(param)));
-    switch (value)
-    {
-    case S_ACTIVE:
-        syringe_pump_on();
-        break;
-
-    case S_INACTIVE:
-        syringe_pump_off();
-        break;
-    }
-
-    Serial.print(" ");
-    Serial.println(sender->id);
 }
 
 void syringe_filled_placement_callback (Control* sender, int value, void* param)
@@ -183,9 +180,8 @@ void calibration_callback (Control *sender, int type)
         Serial.print("Active:");
             
         ESPUI.print(status_syringe_pump, "En marche");
-        ESPUI.updateSwitcher(activation_syringe_pump, true);
         style (status_syringe_pump, 1);
-        style (activation_syringe_pump, 1);
+        style (stop_syringe_pump, 1);
     }
 }
 
@@ -379,9 +375,23 @@ void remaining_volume_mL_callback (Control* sender, int value, void* param)
     ESPUI.updateSlider(remaining_volume_mL, syringe_filled.get_remaining_volume_mL());
 }
 
+void start_exchange_callback (Control* sender, int value, void* param)
+{
+    syringe_pump_on();
+}
 
 //configurations  = Configurations
 
+
+void syringe_initial_volume_mL_callback (Control* sender, int value, void* param)
+{
+    syringe_filled.set_remaining_volume_mL((sender->value).toFloat());
+    Serial.print("Text: ID: ");
+    Serial.print(sender->id);
+    Serial.print(", Value: ");
+    Serial.println(sender->value);
+}
+
 void choose_syringe_callback (Control* sender, int value, void* param)
 /***
 -Argument : Pointer to the controller calling the function, integer according to the controller type.
@@ -555,9 +565,9 @@ void syringe_pump_on_off()
 {
     if (syringe_filled.is_running())
     {
-      ESPUI.updateControlValue(activation_syringe_pump, "1");
+      ESPUI.updateControlValue(status_syringe_pump, "1");
     }
-    ESPUI.updateControlValue(activation_syringe_pump, "0");
+    ESPUI.updateControlValue(status_syringe_pump, "0");
 }
 
 void syringe_pump_on()
@@ -570,9 +580,8 @@ void syringe_pump_on()
 ***/
 {
     ESPUI.print(status_syringe_pump, "En marche");
-    ESPUI.updateSwitcher(activation_syringe_pump, true);
     style (status_syringe_pump, 1);
-    style (activation_syringe_pump, 1);
+    style (stop_syringe_pump, 1);
 
     syringe_filled.move();
 }
@@ -587,9 +596,8 @@ void syringe_pump_off()
 ***/
 {
     ESPUI.print(status_syringe_pump, "A l'arrêt");
-    ESPUI.updateSwitcher(activation_syringe_pump, false);
     style (status_syringe_pump, 2);
-    style (activation_syringe_pump, 2);
+    style (stop_syringe_pump, 2);
 
     syringe_filled.stop();
 }
@@ -673,12 +681,12 @@ void set_init_style()
     //***ABOVE***//
     
     style (status_syringe_pump, 2);
-    style (activation_syringe_pump, 2);
+    style (stop_syringe_pump, 2);
 
     style (status_syringe_filled, 2);
     style (syringe_filled_placement, 2);
 
-    style (calibration, 2);
+    style (calibration, 1);
     style (fast_forward, 3);
     style (fast_backward, 3);
     style (slow_forward, 3);
@@ -691,6 +699,8 @@ void set_init_style()
     style (exchange_throughtput_uL_per_sec, 1);
     style (label_push_pull_choice, 1);
     style (switch_push_pull_choice, 1);
+    style (start_exchange, 1);
+
 
     style (label_remaining_volume_mL, 3);
     style (remaining_volume_mL, 3);
diff --git a/web.h b/web.h
index 50febad..2a329f0 100644
--- a/web.h
+++ b/web.h
@@ -20,21 +20,21 @@ uint16_t configurations, new_syringe, features;
 //***ABOVE***//
 
 int status_syringe_pump;
-uint16_t activation_syringe_pump;
+uint16_t stop_syringe_pump;
 
 int status_syringe_filled;
 uint16_t syringe_filled_placement;
 
 uint16_t calibration, fast_backward, fast_forward, slow_backward, slow_forward;
 
-uint16_t volume_exchange_mL_label, volume_exchange_mL, exchange_throughtput_uL_per_sec_label, exchange_throughtput_uL_per_sec, label_push_pull_choice, switch_push_pull_choice;
+uint16_t volume_exchange_mL_label, volume_exchange_mL, exchange_throughtput_uL_per_sec_label, exchange_throughtput_uL_per_sec, label_push_pull_choice, switch_push_pull_choice, start_exchange;
 
 uint16_t label_remaining_volume_mL;
 
 uint16_t remaining_volume_mL;
 
 //Configurations
-uint16_t syringe_selection, syringe_ref, syringe_brand, syringe_volume_mL, syringe_diameter_mm, choose_syringe;
+uint16_t syringe_selection, syringe_ref, syringe_brand, syringe_volume_mL, syringe_diameter_mm, syringe_initial_volume_mL, choose_syringe;
 
 float syringe_volume_mL_value, syringe_diameter_mm_value;
 
@@ -82,7 +82,7 @@ void number_callback(Control* sender, int type);
 //SPECIFIC CALLBACKS//
 
 //***ABOVE***//
-void activation_syringe_pump_callback (Control* sender, int value, void* param);
+void stop_syringe_pump_callback (Control* sender, int value, void* param);
 void syringe_filled_placement_callback (Control* sender, int value, void* param);
 void calibration_callback(Control* sender, int type);
 void fast_backward_callback (Control *sender, int type);
@@ -93,9 +93,12 @@ void volume_exchange_mL_callback (Control* sender, int value, void* param);
 void exchange_throughtput_uL_per_sec_callback (Control* sender, int value, void* param);
 void switch_push_pull_choice_callback (Control* sender, int value, void* param);
 void remaining_volume_mL_callback (Control* sender, int value, void* param);
+void start_exchange_callback (Control* sender, int value, void* param);
 
 //Configurations
 void choose_syringe_callback (Control* sender, int value, void* param);
+void syringe_initial_volume_mL_callback (Control* sender, int value, void* param);
+
 void name_new_syringe_callback(Control* sender, int type);
 void total_volume_mL_new_syringe_callback(Control* sender, int type);
 void internal_diameter_mm_new_syringe_callback(Control* sender, int type);
-- 
GitLab