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;
|
|
|
|
|
|
|
|
|
|
int b0_precedent = 0;
|
|
|
|
|
int b0_frontmontant = 0;
|
|
|
|
|
int b1_precedent = 0;
|
|
|
|
|
int b1_frontmontant = 0;
|
|
|
|
|
int b2_precedent = 0;
|
|
|
|
|
int b2_frontmontant = 0;
|
|
|
|
|
int b3_precedent = 0;
|
|
|
|
|
int b3_frontmontant = 0;
|
|
|
|
|
int b4_precedent = 0;
|
|
|
|
|
int b4_frontmontant = 0;
|
|
|
|
|
int b5_precedent = 0;
|
|
|
|
|
int b5_frontmontant = 0;
|
|
|
|
|
int b6_precedent = 0;
|
|
|
|
|
int b6_frontmontant = 0;
|
|
|
|
|
int b7_precedent = 0;
|
|
|
|
|
int b7_frontmontant = 0;
|
2026-01-09 09:25:37 +01:00
|
|
|
|
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;
|
|
|
|
|
int etape = 0;
|
|
|
|
|
|
|
|
|
|
int c5_frontdescendant = 0;
|
|
|
|
|
int c5_precedent = 0;
|
|
|
|
|
|
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() {
|
|
|
|
|
|
|
|
|
|
// Détection du front montant (état courant supérieur à l'état précédent)
|
|
|
|
|
b0_frontmontant = b0 > b0_precedent;
|
|
|
|
|
b1_frontmontant = b1 > b1_precedent;
|
|
|
|
|
b2_frontmontant = b2 > b2_precedent;
|
|
|
|
|
b3_frontmontant = b3 > b3_precedent;
|
|
|
|
|
b4_frontmontant = b4 > b4_precedent;
|
|
|
|
|
b5_frontmontant = b5 > b5_precedent;
|
|
|
|
|
b6_frontmontant = b6 > b6_precedent;
|
|
|
|
|
b7_frontmontant = b7 > b7_precedent;
|
|
|
|
|
|
2026-01-14 07:37:16 +01:00
|
|
|
marche_frontmontant = marche > marche_precedent;
|
|
|
|
|
arret_frontdescedant = arret < arret_precedent;
|
|
|
|
|
c5_frontdescendant = c5 < c5_precedent;
|
2026-01-09 19:45:24 +01:00
|
|
|
|
2026-01-14 07:37:16 +01:00
|
|
|
m0 = i0;
|
|
|
|
|
m1 = i1;
|
2026-01-09 19:45:24 +01:00
|
|
|
|
|
|
|
|
// Prêt pour un nouveau tour
|
|
|
|
|
// L'état courant devient l'état précédent
|
|
|
|
|
b0_precedent = b0;
|
|
|
|
|
b1_precedent = b1;
|
|
|
|
|
b2_precedent = b2;
|
|
|
|
|
b3_precedent = b3;
|
|
|
|
|
b4_precedent = b4;
|
|
|
|
|
b5_precedent = b5;
|
|
|
|
|
b6_precedent = b6;
|
|
|
|
|
b7_precedent = b7;
|
2026-01-14 07:37:16 +01:00
|
|
|
marche_precedent = marche;
|
|
|
|
|
arret_precedent = arret;
|
|
|
|
|
c5_precedent = c5;
|
2026-01-09 19:45:24 +01:00
|
|
|
}
|