From e40b449d6a2d6813b1e23daba2c56df8c9513295 Mon Sep 17 00:00:00 2001 From: "Ilia O." Date: Sat, 20 Jan 2024 13:59:29 -0800 Subject: [PATCH] Cap classes --- examples/lds_basic_esp32/lds_basic_esp32.ino | 2 +- library.properties | 2 +- src/lds.cpp | 2 +- src/lds_lds02rr.cpp | 2 +- src/lds_lds02rr.h | 2 +- src/lds_ydlidar_x4.cpp | 42 ++++++++++---------- src/lds_ydlidar_x4.h | 6 +-- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/examples/lds_basic_esp32/lds_basic_esp32.ino b/examples/lds_basic_esp32/lds_basic_esp32.ino index b0a654f..e228e51 100644 --- a/examples/lds_basic_esp32/lds_basic_esp32.ino +++ b/examples/lds_basic_esp32/lds_basic_esp32.ino @@ -16,7 +16,7 @@ #error This example runs on ESP32 #endif -#include +#include const uint8_t LDS_MOTOR_EN_PIN = 19; // ESP32 Dev Kit LDS enable pin const uint8_t LDS_MOTOR_PWM_PIN = 15; // LDS motor speed control using PWM diff --git a/library.properties b/library.properties index 3400fe6..a40aef0 100644 --- a/library.properties +++ b/library.properties @@ -1,4 +1,4 @@ -name=lds +name=LDS version=0.1.0 author=Ilia O. maintainer=Ilia O. diff --git a/src/lds.cpp b/src/lds.cpp index 6c7c809..e57b649 100644 --- a/src/lds.cpp +++ b/src/lds.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "lds.h" +#include "LDS.h" LDS::LDS() { scan_point_callback = NULL; diff --git a/src/lds_lds02rr.cpp b/src/lds_lds02rr.cpp index b7b0a6a..b0a5276 100644 --- a/src/lds_lds02rr.cpp +++ b/src/lds_lds02rr.cpp @@ -16,7 +16,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "lds_lds02rr.h" +#include "LDS_LDS02RR.h" LDS_LDSRR02::LDS_LDSRR02() : LDS() { motor_enabled = false; diff --git a/src/lds_lds02rr.h b/src/lds_lds02rr.h index d80714f..55eaa5d 100644 --- a/src/lds_lds02rr.h +++ b/src/lds_lds02rr.h @@ -17,7 +17,7 @@ // limitations under the License. #pragma once -#include "lds.h" +#include "LDS.h" #include "PID_v1_0_0.h" class LDS_LDSRR02 : public LDS { diff --git a/src/lds_ydlidar_x4.cpp b/src/lds_ydlidar_x4.cpp index ceb987f..2c11bbb 100644 --- a/src/lds_ydlidar_x4.cpp +++ b/src/lds_ydlidar_x4.cpp @@ -16,14 +16,14 @@ // Copyright 2015 - 2018 EAI TEAM http://www.eaibot.com // https://github.com/EAIBOT/ydlidar_arduino -#include "lds_ydlidar_x4.h" +#include "LDS_YDLIDAR_X4.h" -LDS_YDLidarX4::LDS_YDLidarX4() : LDS() { +LDS_YDLIDAR_X4::LDS_YDLIDAR_X4() : LDS() { motor_enabled = false; target_scan_freq = sampling_rate = ERROR_UNKNOWN; } -LDS::result_t LDS_YDLidarX4::start() { +LDS::result_t LDS_YDLIDAR_X4::start() { // Initialize enableMotor(false); @@ -93,29 +93,29 @@ LDS::result_t LDS_YDLidarX4::start() { return LDS::RESULT_OK; } -uint32_t LDS_YDLidarX4::getSerialBaudRate() { +uint32_t LDS_YDLIDAR_X4::getSerialBaudRate() { return 128000; } -float LDS_YDLidarX4::getCurrentScanFreqHz() { +float LDS_YDLIDAR_X4::getCurrentScanFreqHz() { return ERROR_NOT_IMPLEMENTED; } -float LDS_YDLidarX4::getTargetScanFreqHz() { +float LDS_YDLIDAR_X4::getTargetScanFreqHz() { return target_scan_freq; } -int LDS_YDLidarX4::getSamplingRateHz() { +int LDS_YDLIDAR_X4::getSamplingRateHz() { return sampling_rate; } -void LDS_YDLidarX4::stop() { +void LDS_YDLIDAR_X4::stop() { if (isActive()) abort(); enableMotor(false); } -void LDS_YDLidarX4::enableMotor(bool enable) { +void LDS_YDLIDAR_X4::enableMotor(bool enable) { motor_enabled = enable; setMotorPin(DIR_INPUT, LDS_MOTOR_PWM_PIN); @@ -125,23 +125,23 @@ void LDS_YDLidarX4::enableMotor(bool enable) { setMotorPin(enable ? VALUE_HIGH : VALUE_LOW, LDS_MOTOR_EN_PIN); } -bool LDS_YDLidarX4::isActive() { +bool LDS_YDLIDAR_X4::isActive() { return motor_enabled; } -LDS::result_t LDS_YDLidarX4::setScanTargetFreqHz(float freq) { +LDS::result_t LDS_YDLIDAR_X4::setScanTargetFreqHz(float freq) { return ERROR_NOT_IMPLEMENTED; } -LDS::result_t LDS_YDLidarX4::setScanPIDSamplePeriodMs(uint32_t sample_period_ms) { +LDS::result_t LDS_YDLIDAR_X4::setScanPIDSamplePeriodMs(uint32_t sample_period_ms) { return ERROR_NOT_IMPLEMENTED; } -LDS::result_t LDS_YDLidarX4::setScanPIDCoeffs(float Kp, float Ki, float Kd) { +LDS::result_t LDS_YDLIDAR_X4::setScanPIDCoeffs(float Kp, float Ki, float Kd) { return ERROR_NOT_IMPLEMENTED; } -LDS::result_t LDS_YDLidarX4::waitScanDot() { +LDS::result_t LDS_YDLIDAR_X4::waitScanDot() { static int recvPos = 0; static uint8_t package_Sample_Num = 0; static int package_recvPos = 0; @@ -399,18 +399,18 @@ LDS::result_t LDS_YDLidarX4::waitScanDot() { return LDS::RESULT_OK; } -void LDS_YDLidarX4::loop() { +void LDS_YDLIDAR_X4::loop() { result_t result = waitScanDot(); if (result < 0) postError(result, "waitScanDot()"); } -LDS::result_t LDS_YDLidarX4::abort() { +LDS::result_t LDS_YDLIDAR_X4::abort() { // stop the scanPoint operation return sendCommand(LIDAR_CMD_FORCE_STOP, NULL, 0); } -LDS::result_t LDS_YDLidarX4::sendCommand(uint8_t cmd, const void * payload, size_t payloadsize) { +LDS::result_t LDS_YDLIDAR_X4::sendCommand(uint8_t cmd, const void * payload, size_t payloadsize) { //send data to serial cmd_packet pkt_header; cmd_packet * header = &pkt_header; @@ -439,7 +439,7 @@ LDS::result_t LDS_YDLidarX4::sendCommand(uint8_t cmd, const void * payload, size return LDS::RESULT_OK; } -LDS::result_t LDS_YDLidarX4::getDeviceInfo(device_info & info, uint32_t timeout) { +LDS::result_t LDS_YDLIDAR_X4::getDeviceInfo(device_info & info, uint32_t timeout) { LDS::result_t ans; uint8_t recvPos = 0; uint32_t currentTs = millis(); @@ -473,7 +473,7 @@ LDS::result_t LDS_YDLidarX4::getDeviceInfo(device_info & info, uint32_t timeout) return ERROR_TIMEOUT; } -LDS::result_t LDS_YDLidarX4::waitResponseHeader(lidar_ans_header * header, uint32_t timeout) { +LDS::result_t LDS_YDLIDAR_X4::waitResponseHeader(lidar_ans_header * header, uint32_t timeout) { // wait response header int recvPos = 0; uint32_t startTs = millis(); @@ -506,7 +506,7 @@ LDS::result_t LDS_YDLidarX4::waitResponseHeader(lidar_ans_header * header, uint3 } // ask the YDLIDAR for its device health -LDS::result_t LDS_YDLidarX4::getHealth(device_health & health, uint32_t timeout) { +LDS::result_t LDS_YDLIDAR_X4::getHealth(device_health & health, uint32_t timeout) { LDS::result_t ans; uint8_t recvPos = 0; uint32_t currentTs = millis(); @@ -540,7 +540,7 @@ LDS::result_t LDS_YDLidarX4::getHealth(device_health & health, uint32_t timeout) return ERROR_TIMEOUT; } -LDS::result_t LDS_YDLidarX4::startScan(bool force, uint32_t timeout ) { +LDS::result_t LDS_YDLIDAR_X4::startScan(bool force, uint32_t timeout ) { // start the scanPoint operation LDS::result_t ans; diff --git a/src/lds_ydlidar_x4.h b/src/lds_ydlidar_x4.h index 914e9c8..1075747 100644 --- a/src/lds_ydlidar_x4.h +++ b/src/lds_ydlidar_x4.h @@ -17,11 +17,11 @@ // https://github.com/EAIBOT/ydlidar_arduino #pragma once -#include "lds.h" +#include "LDS.h" -class LDS_YDLidarX4 : public LDS { +class LDS_YDLIDAR_X4 : public LDS { public: - LDS_YDLidarX4(); + LDS_YDLIDAR_X4(); result_t start(); void stop();