mirror of
https://github.com/modelec/tirette.git
synced 2026-01-18 16:57:24 +01:00
update
This commit is contained in:
@@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD 17)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(TCPSocket REQUIRED TCPSocket)
|
||||
|
||||
find_package(WiringPi REQUIRED)
|
||||
find_package(wiringpi REQUIRED)
|
||||
|
||||
add_executable(tirette main.cpp
|
||||
MyClient.cpp
|
||||
@@ -14,4 +14,4 @@ add_executable(tirette main.cpp
|
||||
|
||||
target_link_libraries(tirette TCPSocket)
|
||||
|
||||
target_link_libraries(tirette WiringPi)
|
||||
target_link_libraries(tirette wiringpi)
|
||||
16
main.cpp
16
main.cpp
@@ -17,26 +17,22 @@ int main() {
|
||||
pinMode(TIRETTE_GPIO, INPUT);
|
||||
|
||||
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
|
||||
while (true) {
|
||||
// Lecture de l'état du GPIO de la tirette
|
||||
int etat = digitalRead(TIRETTE_GPIO);
|
||||
|
||||
// Si les aimants ne sont plus en contact, afficher un message
|
||||
if (etat == LOW) {
|
||||
// tiretteState = new bool(false);
|
||||
std::cout << "Les aimants ne sont plus en contact." << std::endl;
|
||||
// client.sendMessage("tirette;start;set tirette_state;1");
|
||||
// Vous pouvez exécuter d'autres actions ici
|
||||
std::cout << "Les aimants sont en contact." << std::endl;
|
||||
client.sendMessage("tirette;start;set tirette_state;1");
|
||||
} 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
|
||||
|
||||
Reference in New Issue
Block a user