From c8840741d2f4d78d35459d548277bce3f05af6ea Mon Sep 17 00:00:00 2001 From: "yorick.geoffre" Date: Fri, 21 Apr 2023 22:33:17 +0200 Subject: [PATCH] added simple main test app --- app/caaarController.hpp | 14 -------------- app/main.cpp | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 app/main.cpp diff --git a/app/caaarController.hpp b/app/caaarController.hpp index 255c54c..5981069 100644 --- a/app/caaarController.hpp +++ b/app/caaarController.hpp @@ -30,20 +30,6 @@ public: return std::nullopt; } - - for (const auto& port : possiblePorts) { - serialPort.Open(port); - if (serialPort.good()) { - if (detect()) { - return true; - } - serialPort.Close(); - } - } - - return false; - } - bool detect() { sendCommand("$"); std::string response = readResponse(); diff --git a/app/main.cpp b/app/main.cpp new file mode 100644 index 0000000..a0587fa --- /dev/null +++ b/app/main.cpp @@ -0,0 +1,19 @@ +#include "./caaarController.hpp" + +int main() { + CaaarController controller; + + if (auto detectedPort = controller.autoDetect()) { + std::cout << "CaaarController detected on port " << *detectedPort << "!" << std::endl; + + // Example usage of the CaaarController class + controller.setLEDMode(1); + controller.setLEDColor(0, 255, 255, 255); + controller.setServoDutyCycle(0, 128); + + } else { + std::cout << "CaaarController not detected." << std::endl; + } + + return 0; +} \ No newline at end of file