76 lines
1.6 KiB
C++
76 lines
1.6 KiB
C++
#include "main.hpp"
|
|
#include "autom.cpp"
|
|
#include <thread>
|
|
#include <atomic>
|
|
|
|
int marche_precedent = 0;
|
|
int marche_frontmontant = 0;
|
|
|
|
int arret_precedent = 1;
|
|
int arret_frontdescedant = 0;
|
|
|
|
int bouton_precedent[8];
|
|
int bouton_frontmontant[8];
|
|
int bouton_frontdescendant[8];
|
|
|
|
int cycle = 0;
|
|
long unsigned tempo = 0;
|
|
int compteur = 0;
|
|
int sens = 1;
|
|
|
|
int ci = 0;
|
|
int mode_auto = 0;
|
|
int mode_manu = 0;
|
|
int etape = 0;
|
|
int etape_2 = 0;
|
|
|
|
int c7_frontdescendant = 0;
|
|
int c7_precedent = 0;
|
|
|
|
int main()
|
|
{
|
|
mqtt_open(&client);
|
|
|
|
std::atomic<bool> running{true};
|
|
|
|
while (running)
|
|
{
|
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
|
}
|
|
|
|
mqtt_close();
|
|
return 0;
|
|
}
|
|
|
|
void process() {
|
|
|
|
// 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;
|
|
for(int i = 0; i < 8 ; i++) {
|
|
bouton_frontmontant[i] = bouton[i] > bouton_precedent[i];
|
|
bouton_frontdescendant[i] = bouton[i] < bouton_precedent[i];
|
|
}
|
|
|
|
/* ****************************************************************
|
|
|
|
**************************************************************** */
|
|
|
|
m0 = i0;
|
|
m1 = i1;
|
|
m2 = i2;
|
|
m3 = i3;
|
|
|
|
// Prêt pour un nouveau cycle
|
|
// L'état courant devient l'état précédent
|
|
marche_precedent = marche;
|
|
arret_precedent = arret;
|
|
for (int i = 0; i < 8; i++) {
|
|
bouton_precedent[i] = bouton[i];
|
|
}
|
|
c7_precedent = capteur[7];
|
|
}
|