Skip to content
Snippets Groups Projects
Commit 01135270 authored by Malaurie Bernard's avatar Malaurie Bernard
Browse files

Code editting to use snake case convention in web.cpp.

parent a2ab48fb
No related branches found
No related tags found
1 merge request!17Malaurie's work on UI + CLI interface + AccelStepper interface
......@@ -11,27 +11,27 @@
#include <EEPROM.h>
int lengthSyringePump = 50; //Length of syringe pump in mm
#define syringe_pump_length_mm 50
int statusLabelId1;
int statusLabelId2;
int graphId;
int millisLabelId;
int testSwitchId;
int status_label_id1;
int status_label_id2;
int graph_id;
int millis_label_id;
int test_switch_id;
uint16_t status;
uint16_t activation;
uint16_t EtatButtonSeringue;
uint16_t etat_button_seringue;
uint16_t bouton1, bouton2, bouton3, bouton4, bouton5, bouton6, bouton7, bouton8, bouton9, bouton10, bouton11, bouton12, bouton13, bouton14, bouton15, bouton16, bouton17, bouton18, bouton19, bouton20, bouton21, bouton22, bouton23, bouton24, bouton25, bouton26, bouton27, bouton28, bouton29, bouton30, bouton31, bouton32, bouton33, bouton34, bouton35, bouton36, bouton37, bouton38, bouton39, bouton40, bouton41, bouton42, bouton43, bouton44, bouton45, bouton46, bouton47, bouton48, bouton49, bouton50, bouton51, bouton52, bouton53, bouton54, bouton55, bouton56, bouton57, bouton58, bouton59, bouton60, bouton61, bouton62, bouton63, bouton64, bouton65, bouton66, bouton67, bouton68, bouton69, bouton70, bouton71, bouton72, bouton73, bouton74, bouton75, bouton76, bouton77, bouton78, bouton79, bouton80, bouton81, bouton82, bouton83, bouton84, bouton85, bouton86, bouton87, bouton88, bouton89, bouton90, bouton91, bouton92, bouton93, bouton94, bouton95, bouton96, bouton97, bouton98;
uint16_t zero;
uint16_t styleButton, styleLabel, styleSwitcher, styleSlider, styleButton2, styleLabel2, styleSlider2;
uint16_t style_button, style_label, style_switcher, style_slider, style_button2, style_label2, style_slider2;
uint16_t nvBoutonCtrl, nvBouton;
uint16_t nv_bouton_ctrl, nv_bouton;
uint16_t slider;
......@@ -39,7 +39,7 @@ char couleur1[30], couleur2[30], couleur3[30], couleur4[30], couleur5[30], coule
bool test = true;
long unsigned lastTime = 0;
long unsigned last_time = 0;
// Couleurs à utiliser
const char* couleurs[] = {
......@@ -57,28 +57,28 @@ const char* couleurs[] = {
uint8_t mock_read_uart(void);
void numberCallBack(Control* sender, int type);
void textCallBack(Control* sender, int type);
void sliderCallBack(Control* sender, int type);
void buttonStatusCallBack1(Control* sender, int type, void* param);
void buttonStatusCallBack2(Control* sender, int type, void* param);
void buttonCallback(Control* sender, int type);
void padCallBack(Control* sender, int value);
void switchStatusCallBack1(Control* sender, int value, void* param);
void switchStatusCallBack2(Control* sender, int value, void* param);
void selectCallBack(Control* sender, int value);
void otherSwitchCallBack(Control* sender, int value);
void buttonSeringue(Control* sender, int type);
void generalCallback(Control *sender, int type);
void nvBoutonCtrlCallback(Control *sender, int type);
void nvBoutonCallback(Control *sender, int type);
void positionChoice (Control *sender, int type);
void goToZero (Control *sender, int type);
void onOff();
void webSetup ()
void number_callback(Control* sender, int type);
void text_callback(Control* sender, int type);
void slider_callback(Control* sender, int type);
void button_status_callback1(Control* sender, int type, void* param);
void button_status_callback2(Control* sender, int type, void* param);
void button_callback(Control* sender, int type);
void pad_callback(Control* sender, int value);
void switch_status_callback1(Control* sender, int value, void* param);
void switch_status_callback2(Control* sender, int value, void* param);
void select_callback(Control* sender, int value);
void other_switch_callback(Control* sender, int value);
void button_seringue(Control* sender, int type);
void general_callback(Control* sender, int type);
void nv_bouton_ctrl_callback(Control* sender, int type);
void nv_bouton_callback(Control* sender, int type);
void position_choice(Control* sender, int type);
void go_to_zero(Control* sender, int type);
void on_off();
void web_setup ()
{
......@@ -117,32 +117,32 @@ void webSetup ()
//Au dessus des tables
statusLabelId1 = ESPUI.label("Etat du pousse-seringue 1 :", ControlColor::None, "A l'arrêt");
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, statusLabelId1, &switchStatusCallBack1, (void*)19);
activation = ESPUI.addControl(ControlType::Switcher, "Mise en marche", "Arrêt", ControlColor::None, status_label_id1, switch_status_callback1, (void*)19);
//Style
ESPUI.setPanelStyle(statusLabelId1, couleurs[2]);
ESPUI.setElementStyle(statusLabelId1, couleurs[3]);
ESPUI.setPanelStyle(status_label_id1, couleurs[2]);
ESPUI.setElementStyle(status_label_id1, couleurs[3]);
//Deplacement demandé du pousse-seringue
uint16_t mainNumber = ESPUI.number("Positions finale et possitionnement du pousse-seringue", positionChoice, ControlColor::None, 0, 0, 50);
ESPUI.addControl(Min, "", "0", None, mainNumber);
ESPUI.addControl(Max, "", "50", None, mainNumber);
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, mainNumber, sliderCallBack);
slider = ESPUI.addControl(ControlType::Slider, "Distance", "0", ControlColor::None, main_number, slider_callback);
//Style
ESPUI.setPanelStyle(mainNumber, couleurs[4]);
ESPUI.setElementStyle(mainNumber, couleurs[5]);
ESPUI.setPanelStyle(main_number, couleurs[4]);
ESPUI.setElementStyle(main_number, couleurs[5]);
zero = ESPUI.button("Initialisation", goToZero , ControlColor::None, "Allez en butée");
zero = ESPUI.button("Initialisation", go_to_zero , ControlColor::None, "Allez en butée");
ESPUI.setPanelStyle(zero, couleurs[4]);
ESPUI.setElementStyle(zero, couleurs[5]);
......@@ -153,7 +153,7 @@ void webSetup ()
//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, &selectCallBack);
= 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);
......@@ -170,32 +170,31 @@ void webSetup ()
//TAB3 : Nouvelle seringue
ESPUI.addControl(ControlType::Text, "Nom de la seringue :", "", ControlColor::Alizarin, tab3, &textCallBack);
ESPUI.addControl(ControlType::Number, "Diamètre interne de la seringue en mm", "5", ControlColor::Alizarin, tab3, &numberCallBack);
ESPUI.addControl(ControlType::Number, "Volume total de la seringue en µL", "5", ControlColor::Alizarin, tab3, &numberCallBack);
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);
EtatButtonSeringue = ESPUI.addControl(
ControlType::Button, "Ajouter la seringue", "Valider", ControlColor::Peterriver, tab3, &buttonSeringue);
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, &numberCallBack);
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, &otherSwitchCallBack);
ESPUI.addControl(ControlType::Switcher, "Sens de rotation du moteur", "Horaire", ControlColor::None, tab4, other_switch_callback);
//TAB5 : Test de style
nvBoutonCtrl = ESPUI.addControl(ControlType::Button, "Nouveau Bouton", "Let magic happen", ControlColor::None, tab5, nvBoutonCtrlCallback);
ESPUI.setPanelStyle(nvBoutonCtrl, couleurs[0]);
ESPUI.setElementStyle(nvBoutonCtrl, couleurs[1]);
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]);
nvBouton = ESPUI.addControl(ControlType::Button, "Abra", "Cadabra", ControlColor::None, tab5, nvBoutonCallback);
nv_bouton = ESPUI.addControl(ControlType::Button, "Abra", "Cadabra", ControlColor::None, tab5, nv_bouton_callback);
syringe.isRunning();
//Lancement
......@@ -205,13 +204,13 @@ void webSetup ()
/************ Les fonctions callbacks ****************/
void numberCallBack(Control* sender, int type)
void number_callback(Control* sender, int type)
{
Serial.println(sender->value);
}
void textCallBack(Control* sender, int type)
void text_callback(Control* sender, int type)
{
Serial.print("Text: ID: ");
Serial.print(sender->id);
......@@ -219,7 +218,7 @@ void textCallBack(Control* sender, int type)
Serial.println(sender->value);
}
void sliderCallBack(Control* sender, int type)
void slider_callback(Control* sender, int type)
{
Serial.print("Slider: ID: ");
Serial.print(sender->id);
......@@ -231,41 +230,41 @@ void sliderCallBack(Control* sender, int type)
Serial.println(sliderValueWithOffset);
}
void buttonStatusCallBack1(Control* sender, int type, void* param)
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(statusLabelId1, "En marche");
ESPUI.print(status_label_id1, "En marche");
break;
case B_UP:
Serial.println("Status: Stop");
ESPUI.print(statusLabelId1, "A l'arrêt");
ESPUI.print(status_label_id1, "A l'arrêt");
break;
}
}
void buttonStatusCallBack2(Control* sender, int type, void* param)
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(statusLabelId2, "En marche");
ESPUI.print(status_label_id2, "En marche");
break;
case B_UP:
Serial.println("Status: Stop");
ESPUI.print(statusLabelId2, "A l'arrêt");
ESPUI.print(status_label_id2, "A l'arrêt");
break;
}
}
void buttonCallback(Control* sender, int type)
void button_callback(Control* sender, int type)
{
switch (type)
{
......@@ -279,7 +278,7 @@ void buttonCallback(Control* sender, int type)
}
}
void padCallBack(Control* sender, int value)
void pad_callback(Control* sender, int value)
{
switch (value)
{
......@@ -329,7 +328,7 @@ void padCallBack(Control* sender, int value)
}
void switchStatusCallBack2(Control* sender, int value, void* param)
void switch_status_callback2(Control* sender, int value, void* param)
{
Serial.println(String("param: ") + String(long(param)));
......@@ -337,12 +336,12 @@ void switchStatusCallBack2(Control* sender, int value, void* param)
{
case S_ACTIVE:
Serial.print("Active:");
ESPUI.print(statusLabelId2, "En marche");
ESPUI.print(status_label_id2, "En marche");
break;
case S_INACTIVE:
Serial.print("Inactive");
ESPUI.print(statusLabelId2, "A l'arrêt");
ESPUI.print(status_label_id2, "A l'arrêt");
break;
}
......@@ -351,7 +350,7 @@ void switchStatusCallBack2(Control* sender, int value, void* param)
}
void selectCallBack(Control* sender, int value)
void select_callback(Control* sender, int value)
{
Serial.print("Select: ID: ");
Serial.print(sender->id);
......@@ -359,7 +358,7 @@ void selectCallBack(Control* sender, int value)
Serial.println(sender->value);
}
void otherSwitchCallBack(Control* sender, int value)
void other_switch_callback(Control* sender, int value)
{
switch (value)
{
......@@ -377,7 +376,7 @@ void otherSwitchCallBack(Control* sender, int value)
}
void buttonSeringue(Control* sender, int type)
void button_seringue(Control* sender, int type)
{
switch (type)
{
......@@ -393,7 +392,7 @@ void buttonSeringue(Control* sender, int type)
//Most elements in this test UI are assigned this generic callback which prints some
//basic information. Event types are defined in ESPUI.h
void generalCallback(Control *sender, int type) {
void general_callback(Control *sender, int type) {
Serial.print("CB: id(");
Serial.print(sender->id);
Serial.print(") Type(");
......@@ -410,33 +409,33 @@ void nvBoutonCtrlCallback(Control *sender, int type) {
if(type == B_UP) {
test = !test;
ESPUI.updateVisibility(nvBouton, test);
ESPUI.updateVisibility(nv_bouton, test);
}
}
void nvBoutonCallback(Control *sender, int type) {
void nv_bouton_ctrl_callback(Control *sender, int type) {
if(type == B_DOWN) {
ESPUI.setPanelStyle(nvBouton, couleurs[2]);
ESPUI.setElementStyle(nvBouton, couleurs[3]);
ESPUI.setPanelStyle(nv_bouton, couleurs[2]);
ESPUI.setElementStyle(nv_bouton, couleurs[3]);
}
}
void positionChoice (Control *sender, int type) {
void position_choice (Control *sender, int type) {
Serial.printf("val=%s\n", sender->value.c_str());
Syringe::Syringe_configuration_t conf = syringe.configuration();
conf.volume_value = syringe.mmToMm3(atof(sender->value.c_str()));
syringe.configureSyringe(conf);
//Syringe::Syringe_configuration_t conf = syringe.configuration();
//conf.volume_value = syringe.mmToMm3(atof(sender->value.c_str()));
//syringe.configureSyringe(conf);
}
void goToZero (Control *sender, int type) {
void go_to_zero (Control *sender, int type) {
if(type == B_UP) {
syringe.findZero();
ESPUI.print(statusLabelId1, "En marche");
ESPUI.setPanelStyle(statusLabelId1, couleurs[0]);
ESPUI.setElementStyle(statusLabelId1, couleurs[1]);
//syringe.findZero();
ESPUI.print(status_label_id1, "En marche");
ESPUI.setPanelStyle(status_label_id1, couleurs[0]);
ESPUI.setElementStyle(status_label_id1, couleurs[1]);
......@@ -456,18 +455,18 @@ void switchStatusCallBack1(Control* sender, int value, void* param)
{
case S_ACTIVE:
Serial.print("Active:");
ESPUI.print(statusLabelId1, "En marche");
ESPUI.setPanelStyle(statusLabelId1, couleurs[0]);
ESPUI.setElementStyle(statusLabelId1, couleurs[1]);
syringe.fill();
ESPUI.print(status_label_id1, "En marche");
ESPUI.setPanelStyle(status_label_id1, couleurs[0]);
ESPUI.setElementStyle(status_label_id1, couleurs[1]);
//syringe.fill();
break;
case S_INACTIVE:
Serial.print("Inactive");
ESPUI.print(statusLabelId1, "A l'arrêt");
ESPUI.setPanelStyle(statusLabelId1, couleurs[2]);
ESPUI.setElementStyle(statusLabelId1, couleurs[3]);
syringe.stayHere();
ESPUI.print(status_label_id1, "A l'arrêt");
ESPUI.setPanelStyle(status_label_id1, couleurs[2]);
ESPUI.setElementStyle(status_label_id1, couleurs[3]);
//syringe.stayHere();
break;
}
......@@ -480,15 +479,15 @@ void switchStatusCallBack1(Control* sender, int value, void* param)
void webLoop ()
{
//bool switchi = syringe.isRunning();
bool a = syringe.isRunning();
if(millis() > lastTime + 500) {
//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");
//lastTime = millis();
//if (syringe.isRunning())
//ESPUI.updateControlValue(activation, "1");
//else
//ESPUI.updateControlValue(activation, "0");
}
//}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment