85 lines
1.8 KiB
C++
85 lines
1.8 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[4];
|
|
|
|
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];
|
|
}
|
|
|
|
/* ****************************************************************
|
|
VOTRE PROGRAMME COMMENCE ICI
|
|
**************************************************************** */
|
|
|
|
actionneur[0] = actionneur[2] = actionneur[4] = 1;
|
|
/* ****************************************************************
|
|
VOTRE PROGRAMME S'ARRETE ICI
|
|
**************************************************************** */
|
|
|
|
sortie[10] = etape;
|
|
|
|
// 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];
|
|
}
|