From ef5cbd231ffd5c103814060d91c1e7b23edb3b4a Mon Sep 17 00:00:00 2001 From: ackimixs Date: Mon, 27 May 2024 16:48:53 +0200 Subject: [PATCH] new speed --- TCPServer.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/TCPServer.cpp b/TCPServer.cpp index 526794a..a3a986d 100644 --- a/TCPServer.cpp +++ b/TCPServer.cpp @@ -172,7 +172,15 @@ void TCPServer::handleMessage(const std::string& message, int clientSocket) } if (args[0] == "0") { if (!handleEmergecnyFlag) { - int angle = static_cast(Modelec::mapValue(value, -32767.0, 32768.0, -PI / 2, PI / 2)); + + int angle; + if (value < 0) { + angle = static_cast(Modelec::mapValue(value, -32767.0, -2000.0, -PI / 2, 0.0)); + } + else { + angle = static_cast(Modelec::mapValue(value, 2000.0, 32768.0, 0.0, PI / 2)); + } + this->broadcastMessage("strat;arduino;angle;" + std::to_string(angle) + "\n"); } }