Newer
Older
void web_setup ()
{
//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);
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);
//Création des différents onglets
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, "Paramètres avancés", "Paramètres avancés");
uint16_t tab5 = ESPUI.addControl(Tab, "", "Styled controls");
//Au dessus des tables
status_syringe_pump = ESPUI.label("Etat du pousse-seringue 1 :", ControlColor::None, "A l'arrêt");
//Mettre en route le pousse-seringue
activation = ESPUI.addControl(ControlType::Switcher, "Mise en marche", "Arrêt", ControlColor::None, status_syringe_pump, on_off_callback, (void*)19);
//Style
ESPUI.setPanelStyle(status_syringe_pump, couleurs[2]);
ESPUI.setElementStyle(status_syringe_pump, couleurs[3]);
//Seringue en place
status_syringe_filled = ESPUI.label("Etat du pousse-seringue 1 :", ControlColor::None, "A l'arrêt");
//Mettre en route le pousse-seringue
activation = ESPUI.addControl(ControlType::Switcher, "Mise en marche", "Arrêt", ControlColor::None, status_syringe_filled, on_off_callback, (void*)19);
ESPUI.setPanelStyle(status_syringe_filled, couleurs[2]);
ESPUI.setElementStyle(status_syringe_filled, couleurs[3]);
//Deplacement demandé du pousse-seringue
uint16_t main_number = ESPUI.number("Positions finale et possitionnement du pousse-seringue", position_choice, ControlColor::None, 0, 0, 50);
ESPUI.addControl(Min, "", "0", None, main_number);
ESPUI.addControl(Max, "", "50", None, main_number);
//Visualisation de l'avancement
slider = ESPUI.addControl(ControlType::Slider, "Distance", "0", ControlColor::None, main_number, slider_callback);
ESPUI.setPanelStyle(main_number, couleurs[4]);
ESPUI.setElementStyle(main_number, couleurs[5]);
zero = ESPUI.button("Initialisation", go_to_zero , ControlColor::None, "Allez en butée");
ESPUI.setPanelStyle(zero, couleurs[4]);
ESPUI.setElementStyle(zero, couleurs[5]);
//TAB1 = Configurations
//Choix de la seringue 1
ESPUI.addControl(ControlType::Separator, "Seringue 1", "", ControlColor::None, tab1);
uint16_t select1
= ESPUI.addControl(ControlType::Select, "Choix de la seringue :", "", ControlColor::None, tab1, select_callback);
ESPUI.addControl(ControlType::Option, "Seringue A", "Opt1", ControlColor::None, select1);
ESPUI.addControl(ControlType::Option, "Seringue B", "Opt2", ControlColor::None, select1);
ESPUI.addControl(ControlType::Option, "Seringue C", "Opt3", ControlColor::None, select1);
ESPUI.setPanelStyle(select1, couleurs[4]);
ESPUI.setElementStyle(select1, couleurs[5]);
uint16_t carac1 = ESPUI.addControl( ControlType::Label, "Caractéristiques de la seringue 1 : ", "D = 4mm, V = 10µL", ControlColor::None, tab1);
ESPUI.setPanelStyle(carac1, couleurs[4]);
ESPUI.setElementStyle(carac1, couleurs[5]);
//TAB2 : Mise en marche
//TAB3 : Nouvelle seringue
ESPUI.addControl(ControlType::Text, "Nom de la seringue :", "", ControlColor::Alizarin, tab3, text_callback);
ESPUI.addControl(ControlType::Number, "Diamètre interne de la seringue en mm", "5", ControlColor::Alizarin, tab3, number_callback);
ESPUI.addControl(ControlType::Number, "Volume total de la seringue en µL", "5", ControlColor::Alizarin, tab3, number_callback);
etat_button_seringue = ESPUI.addControl(
ControlType::Button, "Ajouter la seringue", "Valider", ControlColor::Peterriver, tab3, button_seringue);
//TAB4 : Configurations avancées
//Diamètre de la vis
ESPUI.addControl(ControlType::Number, "Diamètre de la vis sans fin", "5", ControlColor::None, tab4, number_callback);
//Sens de rotation du moteur
ESPUI.addControl(ControlType::Switcher, "Sens de rotation du moteur", "Horaire", ControlColor::None, tab4, other_switch_callback);
//TAB5 : Test de style
nv_button_ctrl = ESPUI.addControl(ControlType::Button, "Nouveau button", "Let magic happen", ControlColor::None, tab5, nv_button_ctrl_callback);
ESPUI.setPanelStyle(nv_button_ctrl, couleurs[0]);
ESPUI.setElementStyle(nv_button_ctrl, couleurs[1]);
nv_button = ESPUI.addControl(ControlType::Button, "Abra", "Cadabra", ControlColor::None, tab5, nv_button_callback);
//Lancement
ESPUI.begin("ESPUI Control");
/************ Les fonctions callbacks ****************/
void number_callback(Control* sender, int type)
{
Serial.println(sender->value);
void text_callback(Control* sender, int type)
{
Serial.print("Text: ID: ");
Serial.print(sender->id);
Serial.print(", Value: ");
Serial.println(sender->value);
void slider_callback(Control* sender, int type)
{
Serial.print("Slider: ID: ");
Serial.print(sender->id);
Serial.print(", Value: ");
Serial.println(sender->value);
// Like all Control Values in ESPUI slider values are Strings. To use them as int simply do this:
int sliderValueWithOffset = sender->value.toInt() + 100;
Serial.print("SliderValue with offset");
Serial.println(sliderValueWithOffset);
}
void button_status_callback1(Control* sender, int type, void* param)
{
Serial.println(String("param: ") + String(long(param)));
switch (type)
{
case B_DOWN:
Serial.println("Status: Start");
ESPUI.print(status_syringe_pump, "En marche");
break;
case B_UP:
Serial.println("Status: Stop");
ESPUI.print(status_syringe_pump, "A l'arrêt");
void button_callback(Control* sender, int type)
{
switch (type)
{
case B_DOWN:
Serial.println("Button DOWN");
break;
case B_UP:
Serial.println("Button UP");
break;
}
void pad_callback(Control* sender, int value)
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
{
switch (value)
{
case P_LEFT_DOWN:
Serial.print("left down");
break;
case P_LEFT_UP:
Serial.print("left up");
break;
case P_RIGHT_DOWN:
Serial.print("right down");
break;
case P_RIGHT_UP:
Serial.print("right up");
break;
case P_FOR_DOWN:
Serial.print("for down");
break;
case P_FOR_UP:
Serial.print("for up");
break;
case P_BACK_DOWN:
Serial.print("back down");
break;
case P_BACK_UP:
Serial.print("back up");
break;
case P_CENTER_DOWN:
Serial.print("center down");
break;
case P_CENTER_UP:
Serial.print("center up");
break;
}
Serial.print(" ");
Serial.println(sender->id);
void select_callback(Control* sender, int value)
Serial.print("Select: ID: ");
Serial.print(sender->id);
Serial.print(", Value: ");
Serial.println(sender->value);
}
void other_switch_callback(Control* sender, int value)
{
switch (value)
{
case S_ACTIVE:
Serial.print("Active:");
break;
case S_INACTIVE:
Serial.print("Inactive");
break;
}
Serial.print(" ");
Serial.println(sender->id);
void button_seringue(Control* sender, int type)
switch (type)
{
case B_DOWN:
Serial.println("Button DOWN");
break;
case B_UP:
Serial.println("Button UP");
break;
}
}
//Most elements in this test UI are assigned this generic callback which prints some
//basic information. Event types are defined in ESPUI.h
void general_callback(Control *sender, int type) {
Serial.print("CB: id(");
Serial.print(sender->id);
Serial.print(") Type(");
Serial.print(type);
Serial.print(") '");
Serial.print(sender->label);
Serial.print("' = ");
Serial.println(sender->value);
}
void nv_button_ctrl_callback(Control *sender, int type) {
if(type == B_UP) {
test = !test;
ESPUI.updateVisibility(nv_button, test);
void nv_button_callback(Control *sender, int type) {
ESPUI.setPanelStyle(nv_button, couleurs[2]);
ESPUI.setElementStyle(nv_button, couleurs[3]);
Malaurie Bernard
committed
//Methods that are really useful
void on_off_callback (Control* sender, int value, void* param)
{
Serial.println(String("param: ") + String(long(param)));
switch (value)
case S_ACTIVE:
Serial.print("Active:");
ESPUI.print(status_syringe_pump, "En marche");
ESPUI.setPanelStyle(status_syringe_pump, couleurs[0]);
ESPUI.setElementStyle(status_syringe_pump, couleurs[1]);
Malaurie Bernard
committed
syringe_filled.exchange();
break;
case S_INACTIVE:
Serial.print("Inactive");
ESPUI.print(status_syringe_pump, "A l'arrêt");
ESPUI.setPanelStyle(status_syringe_pump, couleurs[2]);
ESPUI.setElementStyle(status_syringe_pump, couleurs[3]);
Malaurie Bernard
committed
syringe_filled.stop();
Serial.print(" ");
Serial.println(sender->id);
}
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
void on_off()
{
if (syringe_filled.is_running())
{
ESPUI.updateControlValue(activation, "1");
}
ESPUI.updateControlValue(activation, "0");
}
void go_to_zero (Control *sender, int type) {
if(type == B_UP) {
syringe_filled.show_configuration();
Serial.printf("Go to zero");
syringe_filled.go_to_zero();
ESPUI.print(status_syringe_pump, "En marche");
ESPUI.setPanelStyle(status_syringe_pump, couleurs[0]);
ESPUI.setElementStyle(status_syringe_pump, couleurs[1]);
}
}
void position_choice (Control *sender, int type) {
Serial.printf("val=%s\n", sender->value.c_str());
syringe_filled.set_exchange_volume_mL(atof(sender->value.c_str()));
}
on_off();
//bool switchi = syringe.isRunning();
//bool a = syringe.isRunning();
//if(millis() > last_time + 500) {
//ESPUI.updateSlider(slider, syringe.currentPosition()*100/lengthSyringePump);
//lastTime = millis();
//if (syringe.isRunning())
//ESPUI.updateControlValue(activation, "1");
//else
//ESPUI.updateControlValue(activation, "0");