Newer
Older
void web_setup ()
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
//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 tab2 = ESPUI.addControl(ControlType::Tab, "Mise en marche", "Mise en marche");
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_label_id1 = 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_label_id1, switch_status_callback1, (void*)19);
ESPUI.setPanelStyle(status_label_id1, couleurs[2]);
ESPUI.setElementStyle(status_label_id1, 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_bouton_ctrl = ESPUI.addControl(ControlType::Button, "Nouveau Bouton", "Let magic happen", ControlColor::None, tab5, nv_bouton_ctrl_callback);
ESPUI.setPanelStyle(nv_bouton_ctrl, couleurs[0]);
ESPUI.setElementStyle(nv_bouton_ctrl, couleurs[1]);
nv_bouton = ESPUI.addControl(ControlType::Button, "Abra", "Cadabra", ControlColor::None, tab5, nv_bouton_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_label_id1, "En marche");
break;
case B_UP:
Serial.println("Status: Stop");
ESPUI.print(status_label_id1, "A l'arrêt");
void button_status_callback2(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_label_id2, "En marche");
break;
case B_UP:
Serial.println("Status: Stop");
ESPUI.print(status_label_id2, "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)
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
{
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 switch_status_callback2(Control* sender, int value, void* param)
{
Serial.println(String("param: ") + String(long(param)));
switch (value)
{
case S_ACTIVE:
Serial.print("Active:");
ESPUI.print(status_label_id2, "En marche");
break;
case S_INACTIVE:
Serial.print("Inactive");
ESPUI.print(status_label_id2, "A l'arrêt");
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_bouton_ctrl_callback(Control *sender, int type) {
if(type == B_UP) {
test = !test;
ESPUI.updateVisibility(nv_bouton, test);
void nv_bouton_callback(Control *sender, int type) {
ESPUI.setPanelStyle(nv_bouton, couleurs[2]);
ESPUI.setElementStyle(nv_bouton, couleurs[3]);
void position_choice (Control *sender, int type) {
Serial.printf("val=%s\n", sender->value.c_str());
Malaurie Bernard
committed
syringe_filled.set_exchange_volume_mL(atof(sender->value.c_str()));
void go_to_zero (Control *sender, int type) {
syringe_filled.show_configuration();
Serial.printf("Go to zero");
Malaurie Bernard
committed
syringe_filled.go_to_zero();
ESPUI.print(status_label_id1, "En marche");
ESPUI.setPanelStyle(status_label_id1, couleurs[0]);
ESPUI.setElementStyle(status_label_id1, couleurs[1]);
}
}
void switch_status_callback1(Control* sender, int value, void* param)
{
Serial.println(String("param: ") + String(long(param)));
switch (value)
case S_ACTIVE:
Serial.print("Active:");
ESPUI.print(status_label_id1, "En marche");
ESPUI.setPanelStyle(status_label_id1, couleurs[0]);
ESPUI.setElementStyle(status_label_id1, couleurs[1]);
Malaurie Bernard
committed
syringe_filled.exchange();
break;
case S_INACTIVE:
Serial.print("Inactive");
ESPUI.print(status_label_id1, "A l'arrêt");
ESPUI.setPanelStyle(status_label_id1, couleurs[2]);
ESPUI.setElementStyle(status_label_id1, couleurs[3]);
Malaurie Bernard
committed
syringe_filled.stop();
Serial.print(" ");
Serial.println(sender->id);
}
{
//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");