2026-01-09 07:46:52 +01:00
|
|
|
#include "main.hpp"
|
2026-01-09 11:24:51 +01:00
|
|
|
#include "autom.cpp"
|
2026-01-09 19:45:24 +01:00
|
|
|
#include <thread>
|
|
|
|
|
#include <atomic>
|
|
|
|
|
|
|
|
|
|
int marche_precedent = 0;
|
|
|
|
|
int marche_frontmontant = 0;
|
|
|
|
|
|
|
|
|
|
int arret_precedent = 1;
|
|
|
|
|
int arret_frontdescedant = 0;
|
|
|
|
|
|
2026-01-14 21:03:56 +01:00
|
|
|
int bouton_precedent[8];
|
|
|
|
|
int bouton_frontmontant[8];
|
|
|
|
|
int bouton_frontdescendant[8];
|
|
|
|
|
|
2026-01-14 07:37:16 +01:00
|
|
|
int cycle = 0;
|
|
|
|
|
long unsigned tempo = 0;
|
|
|
|
|
int compteur = 0;
|
|
|
|
|
int sens = 1;
|
|
|
|
|
|
|
|
|
|
int ci = 0;
|
|
|
|
|
int mode_auto = 0;
|
2026-01-14 21:03:56 +01:00
|
|
|
int mode_manu = 0;
|
2026-01-14 07:37:16 +01:00
|
|
|
int etape = 0;
|
2026-01-14 21:03:56 +01:00
|
|
|
int etape_2 = 0;
|
2026-01-14 07:37:16 +01:00
|
|
|
|
2026-01-14 23:52:06 +01:00
|
|
|
int c7_frontdescendant = 0;
|
|
|
|
|
int c7_precedent = 0;
|
2026-01-14 21:03:56 +01:00
|
|
|
|
2026-01-09 07:46:52 +01:00
|
|
|
int main()
|
|
|
|
|
{
|
2026-01-09 10:14:37 +01:00
|
|
|
mqtt_open(&client);
|
2026-01-09 07:46:52 +01:00
|
|
|
|
2026-01-09 19:45:24 +01:00
|
|
|
std::atomic<bool> running{true};
|
2026-01-09 09:52:51 +01:00
|
|
|
|
2026-01-09 19:45:24 +01:00
|
|
|
while (running)
|
|
|
|
|
{
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
2026-01-09 09:25:37 +01:00
|
|
|
}
|
|
|
|
|
|
2026-01-09 10:10:14 +01:00
|
|
|
mqtt_close();
|
2026-01-09 07:46:52 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
2026-01-09 19:45:24 +01:00
|
|
|
|
|
|
|
|
void process() {
|
|
|
|
|
|
2026-01-14 23:52:06 +01:00
|
|
|
// Détection des fronts
|
|
|
|
|
// front montant (état courant supérieur à l'état précédent)
|
|
|
|
|
// front descendant (état courant inférieur à l'état précédent)
|
|
|
|
|
// ****************************************************************
|
|
|
|
|
marche_frontmontant = marche > marche_precedent;
|
|
|
|
|
arret_frontdescedant = arret < arret_precedent;
|
2026-01-14 21:03:56 +01:00
|
|
|
for(int i = 0; i < 8 ; i++) {
|
|
|
|
|
bouton_frontmontant[i] = bouton[i] > bouton_precedent[i];
|
|
|
|
|
bouton_frontdescendant[i] = bouton[i] < bouton_precedent[i];
|
|
|
|
|
}
|
2026-01-09 19:45:24 +01:00
|
|
|
|
2026-01-14 23:52:06 +01:00
|
|
|
/* ****************************************************************
|
2026-01-09 19:45:24 +01:00
|
|
|
|
2026-01-14 23:52:06 +01:00
|
|
|
**************************************************************** */
|
2026-01-14 21:03:56 +01:00
|
|
|
|
2026-01-16 07:27:11 +01:00
|
|
|
m0 = i0;
|
|
|
|
|
m1 = i1;
|
|
|
|
|
m2 = i2;
|
|
|
|
|
m3 = i3;
|
2026-01-09 19:45:24 +01:00
|
|
|
|
2026-01-14 23:52:06 +01:00
|
|
|
// Prêt pour un nouveau cycle
|
2026-01-09 19:45:24 +01:00
|
|
|
// L'état courant devient l'état précédent
|
2026-01-14 23:52:06 +01:00
|
|
|
marche_precedent = marche;
|
|
|
|
|
arret_precedent = arret;
|
2026-01-14 21:03:56 +01:00
|
|
|
for (int i = 0; i < 8; i++) {
|
|
|
|
|
bouton_precedent[i] = bouton[i];
|
|
|
|
|
}
|
2026-01-14 23:52:06 +01:00
|
|
|
c7_precedent = capteur[7];
|
2026-01-09 19:45:24 +01:00
|
|
|
}
|