@SGaist
mon MAIN
#include "mainwindow.h"
#include "lectureTemps.hpp"
#include "gpioPin.hpp"
#include "BB_DS18B20.hpp"
#include "commandes.hpp"
#include "relais.hpp"
#include <QApplication>
BB_DS18B20 * ds18b20;
int main(int argc, char *argv[])
{
// pin Sondes ds18b20
int DS_PIN = 4;
pinMode (DS_PIN, OPENDRAIN_PULLUP);
ds18b20 = new BB_DS18B20 (gpioline[DS_PIN]);
// pins
// soties
pinMode (relaiEteHiver, OUTPUT);
digitalWrite (relaiEteHiver, HIGH);
pinMode (relaiComp, OUTPUT);
digitalWrite (relaiComp, HIGH);
pinMode (relaiV4V, OUTPUT);
digitalWrite (relaiV4V, HIGH);
pinMode (relaiVitesseVentExt, OUTPUT);
digitalWrite (relaiVitesseVentExt, HIGH);
pinMode (relaiPetiteVitesseInt, OUTPUT);
digitalWrite (relaiPetiteVitesseInt, HIGH);
pinMode (relaiGrandeVitesseInt, OUTPUT);
digitalWrite (relaiGrandeVitesseInt, HIGH);
// entrées
pinMode (thermostats, INPUT_PULLUP);
pinMode (capteurFiltre, INPUT_PULLUP);
// le fichier ID sur les ds18b20
loadDSConfig ("DS18B20.conf", ds_ID);
// charge info sur les ds18b20
char ficConf[654] = "DS18B20.conf";
FILE * confHan = fopen(ficConf, "r");
if (NULL == confHan) {
cout << "Le fichier de configuration \n" << ficConf << "\n doit exister\n";
return (111);
}
fclose(confHan);
loadDSConfig("DS18B20.conf", ds_ID); // protégé contre le cas où il est absent
cout << "\n configure\n";
if (ds_ID.size() < 2) {
cout << "\nVous devez avoir au moins un thermomètre\n";
return(112);
}
// créer le vecteur contenant la température des DS18b20
for (uint loop = 0; loop < ds_ID.size(); loop++)
ds_temperature.push_back (
-9999.9); // enregistre une information invalide pour commencer
QApplication a(argc, argv);
QApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
MainWindow w;
return a.exec();
}
mainWindow cpp
#include "mainwindow.h"
#include "gpioPin.hpp"
#include "relais.hpp"
MainWindow::MainWindow()
{
baseWindow =new QWidget;
baseWindow ->setFixedSize(1920,1080);
baseWindow ->hide();
m_start = new Interface(baseWindow);
m_start ->dispInterface();
m_marche = new QPushButton("Démarrage ??",baseWindow);
m_marche ->setGeometry(1080,900,240,95);
m_marche ->setStyleSheet("font-size: 30px;background-color: lime");
m_marche ->hide();
m_appel1 = new QPushButton("Consignes",baseWindow);
m_appel1 ->setGeometry(1340,900,240,95);
m_appel1 ->setStyleSheet("font-size: 30px;");
m_appel1 ->show();
m_stop = new QPushButton("Stop ??",baseWindow);
m_stop ->setGeometry(1600,900,240,95);
m_stop ->setStyleSheet("font-size: 30px;background-color: red");
m_stop ->show();
connect(m_marche,&QPushButton::clicked,m_marche,[this](){reStartGainable();});
connect(m_appel1,&QPushButton::clicked,m_appel1,[this](){m_start ->afficheConsignes();});
connect(m_stop,&QPushButton::clicked,m_stop,[this](){stopGainable();});
baseWindow->show();
}
void MainWindow::reStartGainable()
{
m_start ->m_timer1 ->start();
m_marche ->hide();
}
void MainWindow::stopGainable()
{
m_start ->arretGainable();
desactiveTousRelais();
digitalWrite (relaiEteHiver, HIGH);
m_start ->m_window1 ->setPixmap(QPixmap("/media/ludo/D83C-C33A/file (2) (1).jpg"));
m_start ->m_window1 ->showMaximized();
m_marche ->show();
}
mainwindow H
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtWidgets>
#include "interface.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow();
QWidget *baseWindow;
private:
Interface *m_start;
QPushButton *m_marche;
QPushButton *m_appel1;
QPushButton *m_stop;
void reStartGainable();
void stopGainable();
};
#endif // MAINWINDOW_H