diff --git a/misc/camera/a8/remoteControl.h b/misc/camera/a8/remoteControl.h index 6159330..e0d3317 100644 --- a/misc/camera/a8/remoteControl.h +++ b/misc/camera/a8/remoteControl.h @@ -5,6 +5,14 @@ #include #include +struct RectangleProperties +{ + uint16_t width; + uint16_t height; + uint16_t middleX; + uint16_t middleY; +}; + class RemoteControl : public QObject { Q_OBJECT @@ -21,6 +29,7 @@ private slots: void zoomToTarget(QJsonObject &commandObject); void restoreOrientation(void); void restoreZoom(void); + RectangleProperties calculateRectangleProperties(uint16_t top, uint16_t left, uint16_t bottom, uint16_t right); private: void openNamedPipe(void); diff --git a/misc/camera/a8_remote/main.cpp b/misc/camera/a8_remote/main.cpp index b39fe7e..a501f3c 100644 --- a/misc/camera/a8_remote/main.cpp +++ b/misc/camera/a8_remote/main.cpp @@ -6,8 +6,10 @@ int main(int argc, char *argv[]) QCoreApplication a(argc, argv); RemoteControl remoteControl; - remoteControl.createNamedPipe(); - remoteControl.startCommunication(); - +#ifdef FIFO_TEST + remoteControl.startTest(); +#else + remoteControl.sendData(200, 200, 400, 400); +#endif return 0; } diff --git a/misc/camera/a8_remote/remoteControl.cpp b/misc/camera/a8_remote/remoteControl.cpp index 7e97684..d377106 100644 --- a/misc/camera/a8_remote/remoteControl.cpp +++ b/misc/camera/a8_remote/remoteControl.cpp @@ -13,13 +13,18 @@ #include #endif -RemoteControl::RemoteControl() {} +RemoteControl::RemoteControl() +{ + createNamedPipe(); +} RemoteControl::~RemoteControl() { +#ifdef FIFO_TEST if (mFifoFdIn != -1) { close(mFifoFdIn); } +#endif if (mFifoFdOut != -1) { close(mFifoFdOut); } @@ -29,6 +34,7 @@ void RemoteControl::createNamedPipe() { struct stat statBuf; +#ifdef FIFO_TEST // Open incoming pipe (READ ONLY) if (stat(FIFO_FROM_GIMBAL, &statBuf) == 0) { if (S_ISFIFO(statBuf.st_mode)) { @@ -51,6 +57,7 @@ void RemoteControl::createNamedPipe() } else { qInfo().noquote().nospace() << "Opened pipe: " << FIFO_FROM_GIMBAL; } +#endif // Open outgoing pipe (WRITE ONLY) if (stat(FIFO_TO_GIMBAL, &statBuf) == 0) { diff --git a/misc/camera/a8_remote/remoteControl.hpp b/misc/camera/a8_remote/remoteControl.hpp index 581347a..96c5b0f 100644 --- a/misc/camera/a8_remote/remoteControl.hpp +++ b/misc/camera/a8_remote/remoteControl.hpp @@ -12,16 +12,16 @@ class RemoteControl public: RemoteControl(); ~RemoteControl(); - void createNamedPipe(void); void sendData(uint16_t top, uint16_t left, uint16_t bottom, uint16_t right); #ifdef FIFO_TEST void startTest(void); #endif private: + void createNamedPipe(void); #ifdef FIFO_TEST float randomFloatBetween(float min, float max); -#endif int mFifoFdIn; +#endif int mFifoFdOut; };