Skip to content
Snippets Groups Projects
web.cpp 30.9 KiB
Newer Older
David Gauchard's avatar
David Gauchard committed

    HeapSelectIram abc;
    configurations = ESPUI.addControl(ControlType::Tab, "Configurations", "Configurations");
    new_syringe = ESPUI.addControl(ControlType::Tab, "Nouvelle Seringue", "Nouvelle seringue");
    features = ESPUI.addControl(ControlType::Tab, "Caracteristiques du pousse-seringue", "Caracteristiques du pousse-seringue");
    //***Syringe-pump***//
    status_syringe_pump = ESPUI.label("Etat du pousse-seringue :", ControlColor::None, "A l'arrêt");

    stop_syringe_pump = ESPUI.addControl(ControlType::Button, "Mise en marche", "\u26D4", ControlColor::None, status_syringe_pump, stop_syringe_pump_callback, (void*)19);
    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);

    ESPUI.addControl(ControlType::Separator, "", "", ControlColor::None);

    //***Limit-switch***//
    status_limit_switch = ESPUI.label("Etat du capteur de fin de course:", ControlColor::None, "Off");
    calibration = ESPUI.button("Callibration", calibration_callback, ControlColor::None, "\u21E4");
    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);
Malaurie Bernard's avatar
Malaurie Bernard committed
    //Exchange_values_wanted
    initial_volume_mL_label =ESPUI.addControl( ControlType::Label, "Caractéristiques de la seringue : ", "Volume initial contenu dans la seringue : ", ControlColor::None, syringe_volume_mL);
    initial_volume_mL =  ESPUI.addControl( ControlType::Number, "Volume initial contenu dans la seringue : ", "0", ControlColor::None, syringe_volume_mL, initial_volume_mL_callback, (void*)19);


Malaurie Bernard's avatar
Malaurie Bernard committed
    volume_exchange_mL_label = ESPUI.addControl(ControlType::Label, "Configuration de l'échange", "Volume à échanger en mL", ControlColor::None);
    volume_exchange_mL = ESPUI.addControl(ControlType::Number,"Configuration de l'échange", "", ControlColor::None, volume_exchange_mL_label, volume_exchange_mL_callback, (void*)19);
Malaurie Bernard's avatar
Malaurie Bernard committed
    exchange_throughtput_uL_per_sec_label = ESPUI.addControl(ControlType::Label, "Configuration de l'échange", "Débit de l'échange en uL/sec", ControlColor::None, volume_exchange_mL_label);
    exchange_throughtput_uL_per_sec = ESPUI.addControl(ControlType::Number,"Configuration de l'échange", "", ControlColor::None, volume_exchange_mL_label, exchange_throughtput_uL_per_sec_callback, (void*)19);
Malaurie Bernard's avatar
Malaurie Bernard committed
    label_push_pull_choice = ESPUI.addControl(ControlType::Label, "Injection ou Aspiration", "Injection", ControlColor::None, volume_exchange_mL_label);
    switch_push_pull_choice = ESPUI.addControl(ControlType::Switcher, "Injection ou Aspiration", "Injection", ControlColor::None, volume_exchange_mL_label, switch_push_pull_choice_callback, (void*)19);
    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);


Malaurie Bernard's avatar
Malaurie Bernard committed
    //Remaning_values
    label_remaining_volume_mL = ESPUI.label("Caractéristiques de l'échange en cours", ControlColor::None, "Volume restant en mL");
    remaining_volume_mL = ESPUI.addControl(ControlType::Slider, "Volume", "0", ControlColor::None, label_remaining_volume_mL, remaining_volume_mL_callback, (void*)19);
    label_remaining_time_sec = ESPUI.addControl( ControlType::Label, "Caractéristiques de l'échange en cours", "Temps restant en sec", ControlColor::None, label_remaining_volume_mL);
    remaining_time_sec = ESPUI.addControl(ControlType::Slider, "Temps", "0", ControlColor::None, label_remaining_volume_mL, remaining_time_sec_callback, (void*)19);



    ESPUI.sliderContinuous = true;


    //Configurations
    //Choice_of_syringe_model
    syringe_selection = ESPUI.addControl(ControlType::Select, "Choix de la seringue :", "", ControlColor::None, configurations, syringe_selection_callback);
    select_syringe_maj(configurations);
    syringe_volume_mL_value = 5;
    syringe_volume_mL_string = "Volume total: " + std::to_string(syringe_volume_mL_value) + "mL";
    syringe_volume_mL =ESPUI.addControl( ControlType::Label, "Caractéristiques de la seringue : ", syringe_volume_mL_string.c_str() , ControlColor::None, configurations);

    syringe_diameter_mm_value = 5;
Malaurie Bernard's avatar
Malaurie Bernard committed
    syringe_diameter_mm_string = "internal diameter : " + std::to_string(syringe_diameter_mm_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", "\u2714", ControlColor::None, syringe_selection, choose_syringe_callback, (void*)19);
    ESPUI.addControl(ControlType::Separator, "", "", ControlColor::None, configurations);
Malaurie Bernard's avatar
Malaurie Bernard committed
   
    //New_syringe
    name_new_syringe_label = ESPUI.addControl(ControlType::Label, "Nouvelle seringue", "Nom de la seringue :", ControlColor::None, new_syringe);
    name_new_syringe = ESPUI.addControl(ControlType::Text, "Nouvelle seringue", "", ControlColor::None, name_new_syringe_label, name_new_syringe_callback);
    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);
    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);

    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);
    syringe_pump_length_mm_value  = ESPUI.addControl(ControlType::Number, "Longueur totale du pousse-seringue", "50", ControlColor::None, features, syringe_pump_length_mm_callback);
Malaurie Bernard's avatar
Malaurie Bernard committed
    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);
Malaurie Bernard's avatar
Malaurie Bernard committed
    ESPUI.updateSwitcher(clockwise_equals_push, true); //set "Horaire = Injection" at the beginning
    ESPUI.begin("ESPUI Control");
Malaurie Bernard's avatar
Malaurie Bernard committed
/************CALLBACK_METHODS****************/
Malaurie Bernard's avatar
Malaurie Bernard committed
//GENERAL CALLBACKS//
void number_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.
***/
    Serial.println("Type: number");
    Serial.println(String("Value: ") + String(sender->value));
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");
David Gauchard's avatar
David Gauchard committed

David Gauchard's avatar
David Gauchard committed

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.
***/
{(void)param; //Avoid the unused Warning
    Serial.println("Syringe_pump stopped");
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");

void syringe_filled_placement_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 filled status(placed or not) and the actions.
***/
{(void)param; //Avoid the unused Warning
David Gauchard's avatar
David Gauchard committed
    {
        syringe_filled_placement_off();
    Serial.println("Syringe_filled_placement");
    Serial.println(String("Value: ") + String(sender->value));
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");
Malaurie Bernard's avatar
Malaurie Bernard committed
void calibration_callback (Control *sender, int type) 
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return   : /
Malaurie Bernard's avatar
Malaurie Bernard committed
-Action   : Enable the syringe-pump calibration and change the style appropriately.
        syringe_filled.go_to_zero();
        ESPUI.print(status_syringe_pump, "En marche");
        style (status_syringe_pump, 1);
    
    Serial.println("Calibration");
    Serial.println(String("Value: ") + String(sender->type));
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");
void fast_backward_callback (Control *sender, int type) 
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return   : /
-Action   : 
***/
{
    switch (type)
    {
    case B_DOWN:

        syringe_filled.reset_position();
        syringe_filled.move_to_mm(-50);

    Serial.println("Fast_backward");
    Serial.println(String("Value: ") + String(sender->type));
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");

}

void fast_forward_callback (Control *sender, int type) 
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return   : /
-Action   : 
***/
{

    switch (type)
    {
    case B_DOWN:

        Serial.printf("Forward 10 steps"); 
        syringe_filled.reset_position();
        syringe_filled.move_to_mm(50);

    Serial.println("Fast_forward");
    Serial.println(String("Value: ") + String(sender->type));
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");

}

void slow_backward_callback (Control *sender, int type) 
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return   : /
-Action   : 
***/
{
    switch (type)
    {
    case B_DOWN:

        syringe_filled.reset_position();
        syringe_filled.move_to_mm(-50);

    Serial.println("Slow_backward");
    Serial.println(String("Value: ") + String(sender->type));
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");

}

void slow_forward_callback (Control *sender, int type) 
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return   : /
-Action   : 
***/
{
    switch (type)
    {
    case B_DOWN:

        syringe_filled.reset_position();
        syringe_filled.move_to_mm(50);
    
    Serial.println("Slow_forward");
    Serial.println(String("Value: ") + String(sender->type));
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");
void volume_exchange_mL_callback (Control* sender, int value, void* param)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return   : /
-Action   : Enable to choose the volume that woud be exchanged.
***/
{(void)param; //Avoid the unused Warning
    syringe_filled.set_exchange_volume_mL(atof(sender->value.c_str()));
    syringe_filled.write_Json ();

    Serial.println("Volume_exchange (sender->value)");
    Serial.println(String("Value: ") + String(sender->value));
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");
    Serial.println("Volume_exchange (json value)");
    Serial.println(String("Value: ") + String(syringe_filled.get_exchange_volume_mL()));
    Serial.println("");
    
void exchange_throughtput_uL_per_sec_callback (Control* sender, int value, void* param)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return   : /
-Action   : Enable to choose the volume that woud be exchanged.
***/
{(void)param; //Avoid the unused Warning
    syringe_filled.set_exchange_throughput_uL_per_sec(atof(sender->value.c_str()));
    syringe_filled.write_Json ();

    Serial.println("Exchange_throughtput (sender->value)");
    Serial.println(String("Value: ") + String(sender->value));
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");
    Serial.println("Exchange_throughtput (json value)");
    Serial.println(String("Value: ") + String(syringe_filled.get_exchange_throughput_uL_per_sec()));
    Serial.println("");

void switch_push_pull_choice_callback (Control* sender, int value, void* param)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return   : /
-Action   : Change the label_push_pull_choice to display the choice.
            Change the style of the controller involved.
***/
{(void)param; //Avoid the unused Warning
        syringe_filled.set_push(true);
        
Malaurie Bernard's avatar
Malaurie Bernard committed
        ESPUI.print(label_push_pull_choice, "Injection");
        style (initial_volume_mL, 1);
        style (initial_volume_mL_label, 1);
        style (volume_exchange_mL_label, 1);
        style (volume_exchange_mL, 1); 
        style (exchange_throughtput_uL_per_sec_label, 1);
        style (exchange_throughtput_uL_per_sec, 1);
        style (label_push_pull_choice, 1);
        style (switch_push_pull_choice, 1);
        
        break;

    case S_INACTIVE:

        syringe_filled.set_push(false);

Malaurie Bernard's avatar
Malaurie Bernard committed
        ESPUI.print(label_push_pull_choice, "Aspiration");
        style (initial_volume_mL, 1);
        style (initial_volume_mL_label, 1);
        style (volume_exchange_mL_label, 2);
        style (volume_exchange_mL, 2); 
        style (exchange_throughtput_uL_per_sec_label, 2);
        style (exchange_throughtput_uL_per_sec, 2);
        style (label_push_pull_choice, 2);
        style (switch_push_pull_choice, 2);
    syringe_filled.write_Json();

    Serial.println("Push_pull_choice (sender->value)");
    Serial.println(String("Value: ") + String(sender->value));
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");
    Serial.println("Push_pull_choice (json value)");
    Serial.println(String("Value: ") + String(syringe_filled.get_push()));
    Serial.println("");
void remaining_volume_mL_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 display with the current volume remaining.
***/
{(void)param; //Avoid the unused Warning
    ESPUI.updateSlider(remaining_volume_mL, syringe_filled.get_remaining_volume_mL());
Malaurie Bernard's avatar
Malaurie Bernard committed

void remaining_time_sec_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 display with the current time remaining for the exchange.
***/
{(void)param; //Avoid the unused Warning
Malaurie Bernard's avatar
Malaurie Bernard committed
    float remaining_time_sec_value = syringe_filled.get_remaining_volume_mL()/syringe_filled.get_exchange_throughput_uL_per_sec();
    ESPUI.updateSlider(remaining_time_sec, remaining_time_sec_value);
}

void start_exchange_callback (Control* sender, int value, void* param)
{(void)param; //Avoid the unused Warning

    Serial.println("Exchange start");
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");
//configurations  = Configurations
void initial_volume_mL_callback (Control* sender, int value, void* param)
{(void)param; //Avoid the unused Warning
    syringe_filled.set_remaining_volume_mL((sender->value).toFloat());

    Serial.println("syringe_initial_volume (sender->value)");
    Serial.println(String("Value: ") + String(sender->value));
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");
    Serial.println("syringe_initial_volume (json value)");
    Serial.println(String("Value: ") + String(syringe_filled.get_remaining_volume_mL()));
    Serial.println("");


void choose_syringe_callback (Control* sender, int value, void* param)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return   : /
-Action   : Print the value of the button state via the serial port.
***/
{(void)param; //Avoid the unused Warning

        //syringe_volume_mL_value = 2; //Mettre la valeur associé au nom choisit du select
        syringe_volume_mL_value = syringe.get_syringe_database()[select_value]["total_volume_mL"];
        syringe_volume_mL_string = "Volume total: " + std::to_string(syringe_volume_mL_value) + "mL";
        ESPUI.print(syringe_volume_mL, syringe_volume_mL_string.c_str());

        //syringe_diameter_mm_value = 1; //Mettre la valeur associé au nom choisit du select
        syringe_diameter_mm_value = syringe.get_syringe_database()[select_value]["internal_diameter_mm"];
Malaurie Bernard's avatar
Malaurie Bernard committed
        syringe_diameter_mm_string = "internal diameter : " + std::to_string(syringe_diameter_mm_value) + "mm";
        ESPUI.print(syringe_diameter_mm, syringe_diameter_mm_string.c_str());


    Serial.println("choose_syringe");
    Serial.println(String("Value: ") + String(sender->value));
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");
    Serial.println("name_new_syringe (json value)");
    Serial.println(String("Value: ") + syringe_filled.get_name_syringe());
    Serial.println("");    
    Serial.println("Volume_total (json value)");
    Serial.println(String("Value: ") + String((syringe.get_syringe_database()[syringe_filled.get_name_syringe()]["total_volume_mL"]).as<const char*>()));
    Serial.println("");
    Serial.println("internal_diameter (json value)");
    Serial.println(String("Value: ") + String(syringe.get_syringe_database()[syringe_filled.get_name_syringe()]["internal_diameter"].as<const char*>()));
    Serial.println("");
void name_new_syringe_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 new syringe name chosen via the serial port.
***/
    Serial.println("name_new_syringe (sender->value)");
    Serial.println(String("Value: ") + String(sender->type));
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");

}

void total_volume_mL_new_syringe_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 new syringe name chosen via the serial port.
***/
{
    total_volume_mL_new_syringe_value = sender->value;
    Serial.println("total_volume_new_syringe");
    Serial.println(String("Value: ") + String(sender->type));
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");
}

void internal_diameter_mm_new_syringe_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 new syringe name chosen via the serial port.
***/
{
    internal_diameter_mm_new_syringe_value = sender->value,
    Serial.println("internal_diameter_new_syringe");
    Serial.println(String("Value: ") + String(sender->type));
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");
}

void add_syringe_callback (Control* sender, int value,  void* param)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return   : /
-Action   : Print the value of the button state via the serial port.
            Enable to save data in the syringe_json file.
***/
{(void)param; //Avoid the unused Warning
        syringe.set_syringe(name_new_syringe_value, total_volume_mL_new_syringe_value.toFloat(), internal_diameter_mm_new_syringe_value.toFloat());
        ESPUI.addControl(ControlType::Option, name_new_syringe_value.c_str(), name_new_syringe_value.c_str(), ControlColor::None, syringe_selection);
    Serial.println("add_syringe");
    Serial.println(String("Value: ") + String(sender->value));
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");
//features : Configurations avancées
Malaurie Bernard's avatar
Malaurie Bernard committed
void syringe_pump_length_mm_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.
***/
{
    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_mm()));
void clockwise_equals_push_callback(Control* sender, int value)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return   : /
-Action   : Print the value of the convention chosen via the serial port.
            Change the clockwise_equals_push_label to display the information.
***/
{
    switch (value)
    {
    case S_ACTIVE:
        syringe_filled.set_clockwise_equals_push(true);
Malaurie Bernard's avatar
Malaurie Bernard committed
        ESPUI.print(clockwise_equals_push_label, "Horaire = Injection");
        syringe_filled.set_clockwise_equals_push(false);
Malaurie Bernard's avatar
Malaurie Bernard committed
        ESPUI.print(clockwise_equals_push_label, "Horaire = Aspiration");
    Serial.println("clockwise_equals_push (sender->value)");
    Serial.println(String("Value: ") + String(sender->value));
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");
    Serial.println("clockwise_equals_push (json value)");
    Serial.println(String("Value: ") + String(syringe_filled.get_clockwise_equals_push()));
    Serial.println("");
void syringe_selection_callback(Control* sender, int value)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return   : /
-Action   : Print the value of the syringe name chosen via the serial port.
***/
{
    syringe_filled.set_name_syringe(select_value);

    Serial.println("syringe_selection (sender->value)");
    Serial.println(String("Value: ") + String(sender->value));
    Serial.println(String("ID: ") + sender->id);
    Serial.println("");
void syringe_pump_on_off()
/***
-Argument : /
-Return   : /
-Action   : Update the display of the syringe-pump status to match when the motor runs or not (so when we initialize, it stop by itself)
***/
{
    if (syringe_filled.is_running())
    {
/***
-Argument : /
-Return   : /
-Action   : Change the status_syringe_pump label to display the information.
            Change the style of the controller involved.
            Causes the movement of the syringe pump.
***/
    ESPUI.print(status_syringe_pump, "En marche");
    style (status_syringe_pump, 1);
void syringe_pump_off()
/***
-Argument : /
-Return   : /
-Action   : Change the status_syringe_pump label to display the information.
            Change the style of the controller involved.
            Causes the stop of the syringe pump.
***/
    ESPUI.print(status_syringe_pump, "A l'arrêt");
    style (status_syringe_pump, 2);
void syringe_filled_placement_on()
/***
-Argument : /
-Return   : /
-Action   : Change the status_syringe_filled label to display the information.
            Change the style of the controller involved.
Malaurie Bernard's avatar
Malaurie Bernard committed
            Disable the calibration.
    ESPUI.print(status_syringe_filled, "En place");
    style (status_syringe_filled, 1);
    style (syringe_filled_placement, 1);
    
Malaurie Bernard's avatar
Malaurie Bernard committed
    ESPUI.setEnabled(calibration, false);
    style (calibration, 2);
void syringe_filled_placement_off()
/***
-Argument : /
-Return   : /
-Action   : Change the status_syringe_filled label to display the information.
            Change the style of the controller involved.
Malaurie Bernard's avatar
Malaurie Bernard committed
            Enable the calibration.
    ESPUI.print(status_syringe_filled, "Enlevée");
    style (status_syringe_filled, 2);
    style (syringe_filled_placement, 2);
Malaurie Bernard's avatar
Malaurie Bernard committed
    ESPUI.setEnabled(calibration, true);
    style (calibration, 1);
/*************OTHER_METHODS****************/

/***
-Argument : The controller id and the style wanted.
-Return   : /
-Action   : Change style (1 is active, green; 2 is inactive, red; 3 is neutral, brown)
***/
{

    switch (style)
    {
    case 1:
        ESPUI.setPanelStyle(id, couleurs[0]);
        ESPUI.setElementStyle(id, couleurs[1]);
        break;

    case 2:
        ESPUI.setPanelStyle(id, couleurs[2]);
        ESPUI.setElementStyle(id, couleurs[3]);
        break;

    case 3:
        ESPUI.setPanelStyle(id, couleurs[4]);
        ESPUI.setElementStyle(id, couleurs[5]);
        break;

    }

}

void set_init_style()
/***
-Argument : /
-Return   : /
-Action   : Set up the initial style of every controller.
    //***ABOVE***//
    
    style (status_syringe_pump, 2);

    style (status_syringe_filled, 2);
    style (syringe_filled_placement, 2);

    style (fast_forward, 3);
    style (fast_backward, 3);
    style (slow_forward, 3);
    style (slow_backward, 3);

    style (initial_volume_mL, 1);
    style (initial_volume_mL_label, 1);
    style (volume_exchange_mL_label, 1);
    style (volume_exchange_mL, 1); 
    style (exchange_throughtput_uL_per_sec_label, 1);
    style (exchange_throughtput_uL_per_sec, 1);
Malaurie Bernard's avatar
Malaurie Bernard committed
    style (label_push_pull_choice, 1);
    style (switch_push_pull_choice, 1);
    style (label_remaining_volume_mL, 3);
Malaurie Bernard's avatar
Malaurie Bernard committed
    style (remaining_volume_mL, 3);
Malaurie Bernard's avatar
Malaurie Bernard committed
    style (label_remaining_time_sec, 3);
    style (remaining_time_sec, 3);

Malaurie Bernard's avatar
Malaurie Bernard committed
    
Malaurie Bernard's avatar
Malaurie Bernard committed
    //configurations
    style (syringe_volume_mL, 3);
    style (syringe_diameter_mm, 3);
    style (choose_syringe, 3);

    style (name_new_syringe, 3);
    style (internal_diameter_mm_new_syringe, 3);
    style (total_volume_mL_new_syringe, 3);
    style (add_syringe, 3);
    style (name_new_syringe_label, 3);
    style (internal_diameter_mm_new_syringe_label, 3);
    style (total_volume_mL_new_syringe_label, 3);
Malaurie Bernard's avatar
Malaurie Bernard committed
    //features
    style (syringe_pump_length_mm_value, 3);
Malaurie Bernard's avatar
Malaurie Bernard committed
    style (lead_screw_pitch_mm, 3);
    style (clockwise_equals_push_label, 3);
    style (clockwise_equals_push, 3);

/***
-Argument : Integer defining the theme wanted.
-Return   : /
-Action   : Change the interface theme for dark, light of colorful theme.
***/
{
    if (theme ==1)
    {
    //Creation des différents styles

    //Les verts pour la mise en mrche de la seringue
    sprintf(couleur1, "background-color: #%06X;", (unsigned int) 0xb2dbbf);
    sprintf(couleur2, "background-color: #%06X;", (unsigned int) 0x5a8668);

    //Le rouge pour la seringue a l'arrêt
    sprintf(couleur3, "background-color: #%06X;", (unsigned int) 0xc97064);
    sprintf(couleur4, "background-color: #%06X;", (unsigned int) 0x762419);

    //Les marrons pour la config des seringues
    sprintf(couleur5, "background-color: #%06X;", (unsigned int) 0xce9f6f);
    sprintf(couleur6, "background-color: #%06X;", (unsigned int) 0x926448);

    //Pas utilisé pour le moment
    sprintf(couleur7, "background-color: #%06X;", (unsigned int) 0x0a7477);
    sprintf(couleur8, "background-color: #%06X;", (unsigned int) 0x052a38);
    sprintf(couleur9, "background-color: #%06X;", (unsigned int) 0x044365);
    sprintf(couleur10, "background-color: #%06X;", (unsigned int) 0x58b8c3);


        
    }
}
void select_syringe_maj(uint16_t tab)
/***
-Argument : The page on which the info must display.
-Return   : /
-Action   : Read the syringe_json file so it get/recover all the syringe models registered.
***/
{
    JsonObject root = syringe.get_syringe_database_object();

    for (JsonPair kv : root) 
    {
        uint16_t choice = ESPUI.addControl(ControlType::Option, kv.key().c_str(), kv.key().c_str(), ControlColor::None, syringe_selection);
        style (choice, 3);
Malaurie Bernard's avatar
Malaurie Bernard committed

//WEB_LOOP//
Malaurie Bernard's avatar
Malaurie Bernard committed
void web_loop ()
	if(millis() > last_time + 500) {
		last_time = millis();
        ESPUI.updateSlider(remaining_volume_mL, syringe_filled.step_to_mm(syringe_filled.where_step()*100/syringe_filled.get_syringe_pump_length_mm()));
        if (syringe_filled.is_running())
        syringe_pump_on();
        else
        syringe_pump_off();
David Gauchard's avatar
David Gauchard committed
}