Minor improvements

This commit is contained in:
Nffj84
2024-07-03 13:10:27 +03:00
parent 16bb7b2929
commit f2dc975d9f
5 changed files with 22 additions and 11 deletions
+11 -8
View File
@@ -83,14 +83,17 @@ void RemoteControl::sendResponse(void)
{
QJsonDocument responseDocument(mResponseObject);
std::string response = responseDocument.toJson(QJsonDocument::Compact).toStdString();
write(mFifoFdOut, response.c_str(), response.size());
qDebug().noquote().nospace() << "Sent: " << response;
qDebug().noquote().nospace() << "Sending responce: " << response;
write(mFifoFdOut, response.c_str(), response.size());
mIsBusy = false;
}
void RemoteControl::restoreOrientation(void)
{
qDebug().noquote().nospace() << "Restoring orientation";
QByteArray serialCommandAngle = Config::getCommand()->getCommandForInternal(COMMAND_ID::TURN_TO_DEGREES);
int16_t degreesVal = Config::getCurrentYaw() * 10;
@@ -100,7 +103,6 @@ void RemoteControl::restoreOrientation(void)
serialCommandAngle[10] = degreesVal & 0xFF;
serialCommandAngle[11] = degreesVal >> 8;
qDebug().noquote().nospace() << serialCommandAngle;
Config::getSerial()->sendCommand(serialCommandAngle);
QTimer::singleShot(1000, this, [this]() mutable { sendResponse(); });
@@ -108,6 +110,8 @@ void RemoteControl::restoreOrientation(void)
void RemoteControl::restoreZoom(void)
{
qDebug().noquote().nospace() << "Restoring zoom";
QByteArray serialCommandZoom = Config::getCommand()->getCommandForInternal(COMMAND_ID::ZOOM_TO_X);
uint8_t integerPart = static_cast<uint8_t>(Config::getCurrentZoom());
@@ -117,7 +121,6 @@ void RemoteControl::restoreZoom(void)
serialCommandZoom[8] = integerPart;
serialCommandZoom[9] = scaledFractional;
qDebug().noquote().nospace() << serialCommandZoom.toStdString();
Config::getSerial()->sendCommand(serialCommandZoom);
QTimer::singleShot(3000, this, [this]() mutable { restoreOrientation(); });
@@ -125,7 +128,7 @@ void RemoteControl::restoreZoom(void)
void RemoteControl::calculateTargetPosition(QJsonObject &commandObject)
{
qDebug().noquote().nospace() << "Calculating?";
qDebug().noquote().nospace() << "Getting target location";
float latitude = commandObject["latitude"].toDouble();
float longitude = commandObject["longitude"].toDouble();
@@ -147,7 +150,7 @@ void RemoteControl::calculateTargetPosition(QJsonObject &commandObject)
void RemoteControl::turnToTarget(QJsonObject &commandObject)
{
qDebug().noquote().nospace() << "Turning?";
qDebug().noquote().nospace() << "Turning to target";
uint16_t targetX = commandObject["target_x"].toInt();
uint16_t targetY = commandObject["target_y"].toInt();
@@ -173,7 +176,7 @@ void RemoteControl::turnToTarget(QJsonObject &commandObject)
void RemoteControl::zoomToTarget(QJsonObject &commandObject)
{
qDebug().noquote().nospace() << "Zooming?";
qDebug().noquote().nospace() << "Zooming to target";
float fillRatio = 0.5;
float targetPixelWidth = commandObject["target_pixel_width"].toInt();
@@ -229,7 +232,7 @@ void RemoteControl::run()
// Exit with exit message
if (commandObject.contains("extra") == true && commandObject["extra"] == "EXIT") {
return;
exit(EXIT_SUCCESS);
}
mIsBusy = true;