add clear message and change angle to radian

This commit is contained in:
ackimixs
2024-04-10 15:03:20 +02:00
parent 31f1125a3a
commit 244edc11a2

View File

@@ -51,8 +51,11 @@ void MyTCPClient::handleMessage(const std::string &message) {
return;
}
int servo = std::stoi(args[0]);
int angle = std::stoi(args[1]);
this->pwm_setServoPosition(servo, angle);
double angleRad = std::stof(args[1]) / 100;
int angleDeg = static_cast<int>(angleRad * 180 / 3.14159);
this->pwm_setServoPosition(servo, angleDeg);
} else if (token[2] == "clear") {
this->pwm_clear();
}
}
}