This commit is contained in:
ackimixs
2024-03-27 17:09:52 +01:00
parent a5ecedb5f0
commit 8217fdf396
2 changed files with 8 additions and 12 deletions

View File

@@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD 17)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
pkg_check_modules(TCPSocket REQUIRED TCPSocket) pkg_check_modules(TCPSocket REQUIRED TCPSocket)
find_package(WiringPi REQUIRED) find_package(wiringpi REQUIRED)
add_executable(tirette main.cpp add_executable(tirette main.cpp
MyClient.cpp MyClient.cpp
@@ -14,4 +14,4 @@ add_executable(tirette main.cpp
target_link_libraries(tirette TCPSocket) target_link_libraries(tirette TCPSocket)
target_link_libraries(tirette WiringPi) target_link_libraries(tirette wiringpi)

View File

@@ -17,26 +17,22 @@ int main() {
pinMode(TIRETTE_GPIO, INPUT); pinMode(TIRETTE_GPIO, INPUT);
pullUpDnControl(TIRETTE_GPIO, PUD_UP); pullUpDnControl(TIRETTE_GPIO, PUD_UP);
// bool* tiretteState = new bool(true); bool* tiretteState = new bool(true);
// MyClient client(tiretteState, "127.0.0.1", 8080); MyClient client(tiretteState, "127.0.0.1", 8080);
// client.start(); client.start();
// Boucle principale // Boucle principale
while (true) { while (true) {
// Lecture de l'état du GPIO de la tirette
int etat = digitalRead(TIRETTE_GPIO); int etat = digitalRead(TIRETTE_GPIO);
// Si les aimants ne sont plus en contact, afficher un message
if (etat == LOW) { if (etat == LOW) {
// tiretteState = new bool(false); std::cout << "Les aimants sont en contact." << std::endl;
std::cout << "Les aimants ne sont plus en contact." << std::endl; client.sendMessage("tirette;start;set tirette_state;1");
// client.sendMessage("tirette;start;set tirette_state;1");
// Vous pouvez exécuter d'autres actions ici
} else } else
{ {
std::cout << "Les aimants sont en contact." << std::endl; std::cout << "Les aimants ne sont pas en contact." << std::endl;
} }
// Attendre un court délai avant de vérifier à nouveau // Attendre un court délai avant de vérifier à nouveau