From 1139293c70428e62fb237e5d2e6a745be1278156 Mon Sep 17 00:00:00 2001 From: nasi Date: Mon, 8 Nov 2021 20:34:48 +0330 Subject: [PATCH] Add code to servoControler class --- Servo/include/ServoController.h | 10 ++-------- Servo/src/ServoController.cpp | 10 +--------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/Servo/include/ServoController.h b/Servo/include/ServoController.h index abdbe90..36573be 100644 --- a/Servo/include/ServoController.h +++ b/Servo/include/ServoController.h @@ -1,13 +1,12 @@ #ifndef SERVOCONTROLLER_H #define SERVOCONTROLLER_H -#include #include "ModbusWrapper.h" #include "ModbusConfig.h" + class ServoController { -public: - ServoController(); + private: ModbusWrapper _modbusWrapper; const int SRV_START_ANGLE_INT_PART_REG = 2000; @@ -27,8 +26,6 @@ private: const quint16 SRV_APPLY_SETTING_VAL = 1000; const quint16 SRV_CALIBRATION_VAL = 13576; - -private: void apply(); void enableDrive(); void setStartStop(bool start); @@ -38,7 +35,6 @@ private: void changeMode(double startAngle, double stopAngle, double speed); ModbusConfig initiateConfig(); - public: void init(); void startMoving(); @@ -53,8 +49,6 @@ public: double getAngleOffset(); void setAngleOffset(double offset); double getAzimuth(); - - }; #endif // SERVOCONTROLLER_H diff --git a/Servo/src/ServoController.cpp b/Servo/src/ServoController.cpp index 38ba19c..cb7627f 100644 --- a/Servo/src/ServoController.cpp +++ b/Servo/src/ServoController.cpp @@ -1,10 +1,5 @@ #include "ServoController.h" -ServoController::ServoController() -{ -} - -/*************************************************************************************************/ ModbusConfig ServoController::initiateConfig() { ModbusConfig _config; @@ -32,10 +27,7 @@ void ServoController::enableDrive() /*************************************************************************************************/ void ServoController::setStartStop(bool start) { - if(start) - _modbusWrapper.setSingleRegister(SRV_START_STOP_REG, 3); - else - _modbusWrapper.setSingleRegister(SRV_START_STOP_REG, 0); + _modbusWrapper.setSingleRegister(SRV_START_STOP_REG, start ? 3 : 0); apply(); }