diff --git a/web.cpp b/web.cpp index 9f9665f6631cd1ed0ccfe58dbcdbfe942284ad00..b4b6aa16ed1859ce1c4181536ea7c51255048293 100644 --- a/web.cpp +++ b/web.cpp @@ -7,22 +7,19 @@ void web_setup () set_theme(1); - - - //Create tabs uint16_t tab1 = ESPUI.addControl(ControlType::Tab, "Configurations", "Configurations"); uint16_t tab3 = ESPUI.addControl(ControlType::Tab, "Nouvelle Seringue", "Nouvelle seringue"); uint16_t tab4 = ESPUI.addControl(ControlType::Tab, "Caracteristiques du pousse-seringue", "Caracteristiques du pousse-seringue"); - //***Above all***// + //***ABOVE***// //***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, syringe_pump_callback, (void*)19); - + activation_syringe_pump = ESPUI.addControl(ControlType::Switcher, "Mise en marche", "Arrêt", ControlColor::None, status_syringe_pump, activation_syringe_pump_callback, (void*)19); + //Style style (status_syringe_pump, 2); style (activation_syringe_pump, 2); @@ -101,7 +98,7 @@ void web_setup () //TAB3 : Nouvelle seringue uint16_t name_new_syringe_label = ESPUI.addControl(ControlType::Label, "Nouvelle seringue", "Nom de la seringue :", ControlColor::None, tab3); - name_new_syringe = ESPUI.addControl(ControlType::Text, "Nouvelle seringue", "", ControlColor::None, name_new_syringe_label, syringe_name_callback); + name_new_syringe = ESPUI.addControl(ControlType::Text, "Nouvelle seringue", "", ControlColor::None, name_new_syringe_label, name_new_syringe_callback); uint16_t internal_diameter_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_new_syringe = ESPUI.addControl(ControlType::Number, "Diamètre interne de la seringue en mm", "5", ControlColor::None, name_new_syringe_label, number_callback); uint16_t total_volume_new_syringe_label =ESPUI.addControl(ControlType::Label, "Nouvelle seringue", "Volume total de la seringue en µL :", ControlColor::None, name_new_syringe_label); @@ -140,43 +137,38 @@ void web_setup () //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(sender->value); } -//CALLBACKS// -void syringe_name_callback(Control* sender, int type) -{ - Serial.print("Text: ID: "); - Serial.print(sender->id); - Serial.print(", Value: "); - Serial.println(sender->value); -} +//SPECIFIC CALLBACKS// -void syringe_selection_callback(Control* sender, int value) -{ - Serial.print("Select: ID: "); - Serial.print(sender->id); - Serial.print(", Value: "); - Serial.println(sender->value); - select_value = sender->value; -} +//***ABOVE***// -void clockwise_equals_push_callback(Control* sender, int value) +void activation_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. +***/ { + + Serial.println(String("param: ") + String(long(param))); switch (value) { case S_ACTIVE: - Serial.print("Clockwise equals push"); - ESPUI.print(clockwise_equals_push_label, "Horaire = Delivrer"); - + syringe_pump_on(); break; case S_INACTIVE: - Serial.print("Clockwise equals pull"); - ESPUI.print(clockwise_equals_push_label, "Horaire = Récupérer"); + syringe_pump_off(); break; } @@ -184,18 +176,23 @@ void clockwise_equals_push_callback(Control* sender, int value) Serial.println(sender->id); } -void syringe_pump_callback (Control* sender, int value, void* param) +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. +***/ { Serial.println(String("param: ") + String(long(param))); switch (value) { case S_ACTIVE: - syringe_pump_on(); + syringe_filled_placement_on(); break; case S_INACTIVE: - syringe_pump_off(); + syringe_filled_placement_off(); break; } @@ -203,7 +200,43 @@ void syringe_pump_callback (Control* sender, int value, void* param) Serial.println(sender->id); } +void initialisation_callback (Control *sender, int type) +/*** +-Argument : Pointer to the controller calling the function, integer according to the controller type. +-Return : / +-Action : Enable the syringe-pump initialisation and change the style appropriately. +***/ +{ + if((type == B_UP)) { + Serial.printf("Go to zero"); + syringe_filled.go_to_zero(); + 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); + } +} +void position_choice_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. +***/ +{ + Serial.printf("val=%s\n", sender->value.c_str()); + syringe_filled.set_exchange_volume_mL(atof(sender->value.c_str())); + +} + 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. +***/ { Serial.println(String("param: ") + String(long(param))); @@ -220,6 +253,10 @@ void switch_push_pull_choice_callback (Control* sender, int value, void* param) case S_INACTIVE: ESPUI.print(label_push_pull_choice, "Recupérer"); + + style (position_choice, 2); + style (label_push_pull_choice, 2); + style (switch_push_pull_choice, 2); break; } @@ -227,45 +264,59 @@ void switch_push_pull_choice_callback (Control* sender, int value, void* param) Serial.println(sender->id); } -void syringe_pump_on_off() +void remaining_volume_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. +***/ { - if (syringe_filled.is_running()) - { - ESPUI.updateControlValue(activation_syringe_pump, "1"); - } - - ESPUI.updateControlValue(activation_syringe_pump, "0"); } -void initialisation_callback (Control *sender, int type) { - - if((type == B_UP)) { - Serial.printf("Go to zero"); - syringe_filled.go_to_zero(); - 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); - } -} +//TAB1 = Configurations -void remaining_volume_callback (Control* sender, int value, void* param) +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. +***/ { + switch (value) + { + case B_DOWN: + Serial.println("Button DOWN"); + break; + case B_UP: + Serial.println("Button UP"); + break; + } + } -void position_choice_callback (Control* sender, int value, void* param) +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.printf("val=%s\n", sender->value.c_str()); - syringe_filled.set_exchange_volume_mL(atof(sender->value.c_str())); - + Serial.print("Text: ID: "); + Serial.print(sender->id); + Serial.print(", Value: "); + Serial.println(sender->value); } 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. +***/ { switch (value) { @@ -282,18 +333,29 @@ void add_syringe_callback (Control* sender, int value, void* param) } -void syringe_filled_placement_callback (Control* sender, int value, void* param) -{ - Serial.println(String("param: ") + String(long(param))); + +//TAB4 : Configurations avancées + +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_placement_on(); + Serial.print("Clockwise equals push"); + ESPUI.print(clockwise_equals_push_label, "Horaire = Delivrer"); + break; case S_INACTIVE: - syringe_filled_placement_off(); + Serial.print("Clockwise equals pull"); + ESPUI.print(clockwise_equals_push_label, "Horaire = Récupérer"); break; } @@ -301,27 +363,48 @@ void syringe_filled_placement_callback (Control* sender, int value, void* param) Serial.println(sender->id); } -void choose_syringe_callback (Control* sender, int value, void* param) -{ - switch (value) - { - case B_DOWN: - Serial.println("Button DOWN"); - break; +// - case B_UP: - Serial.println("Button UP"); - break; - } - +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. +***/ +{ + Serial.print("Select: ID: "); + Serial.print(sender->id); + Serial.print(", Value: "); + Serial.println(sender->value); + select_value = sender->value; } +//ON_OFF METHODS -/*************ON/OFF_METHODS****************/ +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()) + { + ESPUI.updateControlValue(activation_syringe_pump, "1"); + } + ESPUI.updateControlValue(activation_syringe_pump, "0"); +} void syringe_pump_on() +/*** +-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"); ESPUI.updateSwitcher(activation_syringe_pump, true); @@ -332,6 +415,13 @@ void syringe_pump_on() } 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"); ESPUI.updateSwitcher(activation_syringe_pump, false); @@ -342,6 +432,13 @@ void syringe_pump_off() } 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. + Disable the initialisation. +***/ { ESPUI.print(status_syringe_filled, "En place"); style (status_syringe_filled, 1); @@ -353,6 +450,13 @@ void syringe_filled_placement_on() } 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. + Enable the initialisation. +***/ { ESPUI.print(status_syringe_filled, "Enlevée"); style (status_syringe_filled, 2); @@ -363,28 +467,16 @@ void syringe_filled_placement_off() } - - /*************OTHER_METHODS****************/ -void select_syringe_maj(uint16_t tab) -{ - - syringe_selection = ESPUI.addControl(ControlType::Select, "Choix de la seringue :", "", ControlColor::None, tab, syringe_selection_callback); - - JsonObject root = syringe.get_syringe_database_object(); - - for (JsonPair kv : root) - { - ESPUI.addControl(ControlType::Option, kv.key().c_str(), kv.key().c_str(), ControlColor::None, syringe_selection); - } - - style (syringe_selection, 3); -} void style (uint16_t id, int style) -//Change style (1 is active, green; 2 is inactive, red; 3 is neutral, brown) +/*** +-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) @@ -408,12 +500,22 @@ void style (uint16_t id, int style) } -void set_style() +void set_init_style() +/*** +-Argument : / +-Return : / +-Action : / +***/ { //Mettre le style initial } void set_theme(int theme) +/*** +-Argument : Integer defining the theme wanted. +-Return : / +-Action : Change the interface theme for dark, light of colorful theme. +***/ { if (theme ==1) { @@ -442,6 +544,26 @@ void set_theme(int theme) } } +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. +***/ +{ + + syringe_selection = ESPUI.addControl(ControlType::Select, "Choix de la seringue :", "", ControlColor::None, tab, syringe_selection_callback); + + JsonObject root = syringe.get_syringe_database_object(); + + for (JsonPair kv : root) + { + ESPUI.addControl(ControlType::Option, kv.key().c_str(), kv.key().c_str(), ControlColor::None, syringe_selection); + } + + style (syringe_selection, 3); + +} //WEB_LOOP// void web_loop () diff --git a/web.h b/web.h index b96833cc737786e65ee519e0da7235611f5fa688..b140b8af15cbdde9a29c49956b41436305540bb2 100644 --- a/web.h +++ b/web.h @@ -15,22 +15,39 @@ #define syringe_pump_length_mm 50 +//***ABOVE***// -int status_syringe_pump, status_syringe_filled; +int status_syringe_pump; +uint16_t activation_syringe_pump; -uint16_t activation_syringe_pump, syringe_filled_placement, initialisation, position_choice, label_push_pull_choice, switch_push_pull_choice, add_syringe, choose_syringe; +int status_syringe_filled; +uint16_t syringe_filled_placement; -uint16_t syringe_selection, syringe_ref, syringe_brand, syringe_volume, syringe_diameter, label_remaining_volume; +uint16_t initialisation; + +uint16_t position_choice, label_push_pull_choice, switch_push_pull_choice; + +uint16_t label_remaining_volume; -String select_value; +//TAB1 = Configurations +uint16_t choose_syringe; +//TAB3 : Nouvelle seringue +uint16_t name_new_syringe, internal_diameter_new_syringe, total_volume_new_syringe, add_syringe; -uint16_t name_new_syringe, internal_diameter_new_syringe, total_volume_new_syringe, add_syringe_label; +//TAB4 : Configurations avancées uint16_t worm_diameter, clockwise_equals_push_label, clockwise_equals_push; +//A trier encore + +uint16_t syringe_selection, syringe_ref, syringe_brand, syringe_volume, syringe_diameter; + +String select_value; + + char couleur1[30], couleur2[30], couleur3[30], couleur4[30], couleur5[30], couleur6[30], couleur7[30], couleur8[30], couleur9[30], couleur10[30]; @@ -51,50 +68,40 @@ const char* couleurs[] = { }; -void syringe_pump_on_off(); -//callback methods -void number_callback(Control* sender, int type); -void syringe_name_callback(Control* sender, int type); -void syringe_selection_callback(Control* sender, int value); -void clockwise_equals_push_callback(Control* sender, int value); +/************CALLBACK_METHODS****************/ +//GENERAL CALLBACKS// +void number_callback(Control* sender, int type); +//SPECIFIC CALLBACKS// +//***ABOVE***// +void activation_syringe_pump_callback (Control* sender, int value, void* param); void syringe_filled_placement_callback (Control* sender, int value, void* param); - -void choose_syringe_callback (Control* sender, int value, void* param); - - - -void syringe_pump_callback(Control* sender, int value, void* param); - - void initialisation_callback(Control* sender, int type); - - void position_choice_callback (Control* sender, int value, void* param); - - - void switch_push_pull_choice_callback (Control* sender, int value, void* param); +void remaining_volume_callback (Control* sender, int value, void* param); -void progress_move_callback (Control* sender, int value, void* param); - +//TAB1 = Configurations +void choose_syringe_callback (Control* sender, int value, void* param); +void name_new_syringe_callback(Control* sender, int type); void add_syringe_callback (Control* sender, int value, void* param); -void status_position_choice_callback (Control* sender, int value); - +//TAB4 : Configurations avancées +void clockwise_equals_push_callback(Control* sender, int value); +// +void syringe_selection_callback(Control* sender, int value); -void add_syringe_callback (Control* sender, int value, void* param); -void remaining_volume_callback (Control* sender, int value, void* param); +//ON_OFF METHODS +void syringe_pump_on_off(); -//onoff methods void syringe_pump_on(); void syringe_pump_off(); @@ -103,12 +110,10 @@ void syringe_filled_placement_off(); -//othermethods - -void select_syringe_maj(uint16_t tab); - +//OTHER_METHODS void style (uint16_t id, int style); +void set_init_style(); +void set_theme(int theme); +void select_syringe_maj(uint16_t tab); -void set_style(); -void set_theme(int theme);