Newer
Older
void web_setup ()
//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***//
//***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);
//Style
style (status_syringe_pump, 2);
style (activation_syringe_pump, 2);
//***Syringe-filled***//
status_syringe_filled = ESPUI.label("Etat de la seringue :", ControlColor::None, "Pas en place");
syringe_filled_placement = ESPUI.addControl(ControlType::Switcher, "Mise en marche", "Arrêt", ControlColor::None, status_syringe_filled, syringe_filled_placement_callback, (void*)19);
//Style
style (status_syringe_filled, 2);
style (syringe_filled_placement, 2);
//***Initialisation***//
initialisation = ESPUI.button("Initialisation", initialisation_callback, ControlColor::None, "");
//ESPUI.updateVisibility(initialisation, false);
style (initialisation, 2);
//Deplacement demandé du pousse-seringue
position_choice = ESPUI.number("Choix du volume à echanger", position_choice_callback, ControlColor::None, 0, 0, 50, (void*)19);
label_push_pull_choice = ESPUI.addControl(ControlType::Label, "Delivrer ou recupérer", "Délivrer", ControlColor::None, position_choice);
switch_push_pull_choice = ESPUI.addControl(ControlType::Switcher, "Delivrer ou recupérer", "Délivrer", ControlColor::None, position_choice, switch_push_pull_choice_callback, (void*)19);
Malaurie Bernard
committed
ESPUI.updateSwitcher(switch_push_pull_choice, true); //pour mettre a "Delivrer" par défaut au début
Malaurie Bernard
committed
//Style
style (position_choice, 3);
style (label_push_pull_choice, 3);
style (switch_push_pull_choice, 3);
//Volume restant
label_remaining_volume = ESPUI.label("Volume restant en mL", ControlColor::None, "Volume restant en mL");
ESPUI.addControl(ControlType::Slider, "Distance", "0", ControlColor::None, label_remaining_volume, remaining_volume_callback, (void*)19);
ESPUI.sliderContinuous = true;
Malaurie Bernard
committed
style (label_remaining_volume, 3);
//TAB1 = Configurations
//Choix de la seringue 1
ESPUI.addControl(ControlType::Separator, "Seringue 1", "", ControlColor::None, tab1);
uint16_t syringe_ref = ESPUI.addControl( ControlType::Label, "Caractéristiques de la seringue 1 : ", "Reférence : ? " , ControlColor::None, tab1);
uint16_t syringe_brand =ESPUI.addControl( ControlType::Label, "Caractéristiques de la seringue 1 : ", "Marque : ? " , ControlColor::None, syringe_ref);
uint16_t syringe_volume =ESPUI.addControl( ControlType::Label, "Caractéristiques de la seringue 1 : ", "Volume total = ? mL" , ControlColor::None, syringe_ref);
uint16_t syringe_diameter =ESPUI.addControl( ControlType::Label, "Caractéristiques de la seringue 1 : ", "Diamètre interne = ? mm" , ControlColor::None, syringe_ref);
style (syringe_ref, 3);
style (syringe_brand, 3);
style (syringe_volume, 3);
style (syringe_diameter, 3);
choose_syringe = ESPUI.addControl(ControlType::Button, "Choisir cette seringue", "Valider", ControlColor::None, syringe_selection, choose_syringe_callback, (void*)19);
Malaurie Bernard
committed
style (choose_syringe, 3);
//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);
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);
total_volume_new_syringe = ESPUI.addControl(ControlType::Number, "Volume total de la seringue en µL", "5", ControlColor::None, name_new_syringe_label, number_callback);
uint16_t 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);
Malaurie Bernard
committed
style (name_new_syringe, 3);
style (internal_diameter_new_syringe_label, 3);
style (internal_diameter_new_syringe, 3);
style (total_volume_new_syringe_label, 3);
style (total_volume_new_syringe, 3);
style (add_syringe_label, 3);
style (add_syringe, 3);
//TAB4 : Configurations avancées
//Diamètre de la vis
Malaurie Bernard
committed
worm_diameter = ESPUI.addControl(ControlType::Number, "Diamètre de la vis sans fin", "5", ControlColor::None, tab4, number_callback);
//Sens de rotation du moteur
Malaurie Bernard
committed
clockwise_equals_push_label = ESPUI.addControl(ControlType::Label, "Sens de rotation du moteur", "Horaire = Delivrer", ControlColor::None, tab4);
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); //pour mettre a "Horaire = Delivrer" par défaut au début
Malaurie Bernard
committed
style (worm_diameter, 3);
style (clockwise_equals_push_label, 3);
style (clockwise_equals_push, 3);
//Lancement
ESPUI.begin("ESPUI Control");
void number_callback(Control* sender, int type)
{
Serial.println(sender->value);
void syringe_name_callback(Control* sender, int type)
{
Serial.print("Text: ID: ");
Serial.print(sender->id);
Serial.print(", Value: ");
Serial.println(sender->value);
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;
Malaurie Bernard
committed
void clockwise_equals_push_callback(Control* sender, int value)
{
switch (value)
{
case S_ACTIVE:
Malaurie Bernard
committed
Serial.print("Clockwise equals push");
Malaurie Bernard
committed
ESPUI.print(clockwise_equals_push_label, "Horaire = Delivrer");
break;
case S_INACTIVE:
Malaurie Bernard
committed
Serial.print("Clockwise equals pull");
Malaurie Bernard
committed
ESPUI.print(clockwise_equals_push_label, "Horaire = Récupérer");
break;
}
Serial.print(" ");
Serial.println(sender->id);
void syringe_pump_callback (Control* sender, int value, void* param)
{
Serial.println(String("param: ") + String(long(param)));
switch (value)
break;
case S_INACTIVE:
Serial.print(" ");
Serial.println(sender->id);
}
void switch_push_pull_choice_callback (Control* sender, int value, void* param)
{
Serial.println(String("param: ") + String(long(param)));
switch (value)
{
case S_ACTIVE:
ESPUI.print(label_push_pull_choice, "Délivrer");
style (position_choice, 1);
style (label_push_pull_choice, 1);
style (switch_push_pull_choice, 1);
break;
case S_INACTIVE:
ESPUI.print(label_push_pull_choice, "Recupérer");
break;
}
Serial.print(" ");
Serial.println(sender->id);
}
{
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();
Malaurie Bernard
committed
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 remaining_volume_callback (Control* sender, int value, void* param)
}
void position_choice_callback (Control* sender, int value, void* param)
{
Serial.printf("val=%s\n", sender->value.c_str());
syringe_filled.set_exchange_volume_mL(atof(sender->value.c_str()));
}
void add_syringe_callback (Control* sender, int value, void* param)
{
switch (value)
{
case B_DOWN:
Serial.println("Button DOWN");
syringe.write_Json();
break;
case B_UP:
Serial.println("Button UP");
break;
}
}
void syringe_filled_placement_callback (Control* sender, int value, void* param)
{
Serial.println(String("param: ") + String(long(param)));
switch (value)
{
case S_ACTIVE:
syringe_filled_placement_on();
break;
case S_INACTIVE:
syringe_filled_placement_off();
break;
}
Serial.print(" ");
Serial.println(sender->id);
}
void choose_syringe_callback (Control* sender, int value, void* param)
{
Malaurie Bernard
committed
switch (value)
{
case B_DOWN:
Serial.println("Button DOWN");
break;
case B_UP:
Serial.println("Button UP");
break;
}
}
Malaurie Bernard
committed
/*************ON/OFF_METHODS****************/
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);
syringe_filled.move();
}
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);
syringe_filled.stop();
}
void syringe_filled_placement_on()
ESPUI.print(status_syringe_filled, "En place");
style (status_syringe_filled, 1);
style (syringe_filled_placement, 1);
Malaurie Bernard
committed
ESPUI.setEnabled(initialisation, false);
style (initialisation, 2);
void syringe_filled_placement_off()
{
ESPUI.print(status_syringe_filled, "Enlevée");
style (status_syringe_filled, 2);
style (syringe_filled_placement, 2);
Malaurie Bernard
committed
ESPUI.setEnabled(initialisation, true);
style (initialisation, 1);
}
/*************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);
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
void style (uint16_t id, int style)
//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;
}
}
//bool switchi = syringe.isRunning();
//bool a = syringe.isRunning();
if(millis() > last_time + 500) {
//ESPUI.updateSlider(slider, syringe_filled.current_position());
last_time = millis();
//on_off();
if (syringe_filled.is_running())
syringe_pump_on();
else
syringe_pump_off();
}