diff --git a/src/BoardI2C.hpp b/src/BoardI2C.hpp index 2c0a428..a9a37ad 100755 --- a/src/BoardI2C.hpp +++ b/src/BoardI2C.hpp @@ -1,6 +1,8 @@ // This is a personal academic project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: https://pvs-studio.com +#pragma once + #define CONFIG_DISABLE_HAL_LOCKS 0 #include "Wire.h" @@ -18,4 +20,4 @@ public: assert(false); } } -}; \ No newline at end of file +}; diff --git a/src/Filters/Kalman2DFilter.hpp b/src/Filters/Kalman2DFilter.hpp index 8f15a74..4cf5b42 100755 --- a/src/Filters/Kalman2DFilter.hpp +++ b/src/Filters/Kalman2DFilter.hpp @@ -1,37 +1,38 @@ // This is a personal academic project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: https://pvs-studio.com +#pragma once #include class Kalman2DFilter { - public: +public: Kalman2DFilter(float dt = 4.f, float accelUncertainty = 10.f, float barometerUncertainty = 100.f) { dt /= 1000.f; - F = { 1, dt, 0, 1 }; - G = { 0.5f * dt * dt, dt }; - H = { 1, 0 }; - I = { 1, 0, 0, 1 }; + F = {1, dt, 0, 1}; + G = {0.5f * dt * dt, dt}; + H = {1, 0}; + I = {1, 0, 0, 1}; Q = G * ~G * accelUncertainty * accelUncertainty; - R = { barometerUncertainty * barometerUncertainty }; - P = { 0, 0, 0, 0 }; - S = { 0, 0 }; + R = {barometerUncertainty * barometerUncertainty}; + P = {0, 0, 0, 0}; + S = {0, 0}; } void filter(const float &AccZInertial, const float &AltitudeBarometer, float &AltitudeKalman, float &VelocityVerticalKalman) { - Acc = { AccZInertial }; + Acc = {AccZInertial}; S = F * S + G * Acc; P = F * P * ~F + Q; L = H * P * ~H + R; K = P * ~H * Inverse(L); - M = { AltitudeBarometer }; + M = {AltitudeBarometer}; S = S + K * (M - H * S); AltitudeKalman = S(0, 0); VelocityVerticalKalman = S(1, 0); P = (I - K * H) * P; } - private: +private: BLA::Matrix<2, 2> F; BLA::Matrix<2, 1> G; BLA::Matrix<2, 2> P; @@ -44,4 +45,4 @@ class Kalman2DFilter { BLA::Matrix<1, 1> R; BLA::Matrix<1, 1> L; BLA::Matrix<1, 1> M; -}; \ No newline at end of file +}; diff --git a/src/Filters/kalman.hpp b/src/Filters/kalman.hpp index 373fe88..3e44018 100755 --- a/src/Filters/kalman.hpp +++ b/src/Filters/kalman.hpp @@ -1,4 +1,5 @@ // упрощённый Калман для одномерного случая +#pragma once #ifndef _GKalman_h #define _GKalman_h diff --git a/src/Filters/median3.hpp b/src/Filters/median3.hpp index 5c59c6b..824ef9c 100755 --- a/src/Filters/median3.hpp +++ b/src/Filters/median3.hpp @@ -1,4 +1,5 @@ // быстрый медианный фильтр 3-го порядка +#pragma once #ifndef _GMedian3_h #define _GMedian3_h diff --git a/src/Filters/runningAverage.hpp b/src/Filters/runningAverage.hpp index fd338a6..fb7bb58 100755 --- a/src/Filters/runningAverage.hpp +++ b/src/Filters/runningAverage.hpp @@ -1,4 +1,5 @@ // экспоненциальное бегущее среднее +#pragma once #ifndef _GFilterRA_h #define _GFilterRA_h diff --git a/src/Logic/FlightController.hpp b/src/Logic/FlightController.hpp index 2ac89bc..6ca59b7 100755 --- a/src/Logic/FlightController.hpp +++ b/src/Logic/FlightController.hpp @@ -1,5 +1,6 @@ // This is a personal academic project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: https://pvs-studio.com +#pragma once #include "PIDController.hpp" #include "Sensors/Sensors.hpp" diff --git a/src/Logic/FlightDispatcher.hpp b/src/Logic/FlightDispatcher.hpp index f9bb86b..a475882 100755 --- a/src/Logic/FlightDispatcher.hpp +++ b/src/Logic/FlightDispatcher.hpp @@ -1,5 +1,6 @@ // This is a personal academic project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: https://pvs-studio.com +#pragma once #include "FlightController.hpp" #include "GSON.h" @@ -43,4 +44,4 @@ private: uint32_t _telemetryTimer = millis(); BluetoothDispatcher *_bluetoothDispatcher; FlightController *_flightController; -}; \ No newline at end of file +}; diff --git a/src/Logic/PIDController.hpp b/src/Logic/PIDController.hpp index 88a3179..3f4d638 100755 --- a/src/Logic/PIDController.hpp +++ b/src/Logic/PIDController.hpp @@ -1,6 +1,8 @@ // This is a personal academic project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: https://pvs-studio.com +#pragma once + #include "Motor/BrushedMotor.hpp" #include "SavedPidRegulator.hpp" #include "esp_log.h" @@ -10,7 +12,7 @@ class PIDController : public SavedPidRegulator { public: PIDController(float p, float i, float d, BrushedMotor *rotor, const char *name = "PID", uint16_t dt = 10, const bool isEnabled = false) - : SavedPidRegulator(p, i, d, name, dt) { + : SavedPidRegulator(p, i, d, name, dt) { assert(rotor != nullptr); _rotor = rotor; _isEnabled = isEnabled; @@ -50,4 +52,4 @@ private: BrushedMotor *_rotor = nullptr; uint32_t _pid_timer = 0; bool _isEnabled = false; -}; \ No newline at end of file +}; diff --git a/src/Logic/SavedPidRegulator.hpp b/src/Logic/SavedPidRegulator.hpp index 9c5179e..8592f70 100755 --- a/src/Logic/SavedPidRegulator.hpp +++ b/src/Logic/SavedPidRegulator.hpp @@ -1,3 +1,4 @@ +#pragma once #include "GyverPID.h" #include "Preferences.h" #include "esp_log.h" diff --git a/src/Motor/BrushedMotor.cpp b/src/Motor/BrushedMotor.cpp index 3775ef6..6e055a1 100755 --- a/src/Motor/BrushedMotor.cpp +++ b/src/Motor/BrushedMotor.cpp @@ -72,6 +72,6 @@ void BrushedMotor::reverse() { _apply_directional(); } -void BrushedMotor::coast() { +void BrushedMotor::coast() const { setDuty(0); } diff --git a/src/Motor/BrushedMotor.hpp b/src/Motor/BrushedMotor.hpp index 95a3f82..b69d23b 100755 --- a/src/Motor/BrushedMotor.hpp +++ b/src/Motor/BrushedMotor.hpp @@ -1,10 +1,10 @@ // This is a personal academic project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: https://pvs-studio.com +#pragma once #include #include "Arduino.h" -#include "string.h" -#include "driver/ledc.h" +#include class BrushedMotor { @@ -25,7 +25,7 @@ public: void reverse(); - void coast(); + void coast() const; void decrement(uint32_t k) const; @@ -40,4 +40,4 @@ private: String _tag_name = "BrushedMotor"; void _apply_directional() const; -}; \ No newline at end of file +}; diff --git a/src/RF/BluetoothDispatcher.hpp b/src/RF/BluetoothDispatcher.hpp index 921f268..934ad45 100755 --- a/src/RF/BluetoothDispatcher.hpp +++ b/src/RF/BluetoothDispatcher.hpp @@ -1,5 +1,6 @@ // This is a personal academic project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: https://pvs-studio.com +#pragma once #define TX_QUEUE_SIZE 512 @@ -58,4 +59,4 @@ private: static constexpr uint16_t _buffer_size = 512; mString<_buffer_size> _buffer; -}; \ No newline at end of file +}; diff --git a/src/Sensors/Barometer.hpp b/src/Sensors/Barometer.hpp index b725914..d378196 100644 --- a/src/Sensors/Barometer.hpp +++ b/src/Sensors/Barometer.hpp @@ -1,5 +1,6 @@ // This is a personal academic project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: https://pvs-studio.com +#pragma once #include "GyverBME280.h" diff --git a/src/Sensors/BarometerBMP280.hpp b/src/Sensors/BarometerBMP280.hpp index 88c7fbb..3696981 100755 --- a/src/Sensors/BarometerBMP280.hpp +++ b/src/Sensors/BarometerBMP280.hpp @@ -1,5 +1,6 @@ // This is a personal academic project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: https://pvs-studio.com +#pragma once #include "GyverBME280.h" diff --git a/src/Sensors/BatteryController.hpp b/src/Sensors/BatteryController.hpp index 2d44b7c..e5ab94c 100755 --- a/src/Sensors/BatteryController.hpp +++ b/src/Sensors/BatteryController.hpp @@ -1,5 +1,6 @@ // This is a personal academic project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: https://pvs-studio.com +#pragma once #include "board_pins.h" @@ -36,4 +37,4 @@ private: static float _map(float x, float in_min, float in_max, float out_min, float out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } -}; \ No newline at end of file +}; diff --git a/src/Sensors/MPU.hpp b/src/Sensors/MPU.hpp index 52869b6..29b8a6e 100755 --- a/src/Sensors/MPU.hpp +++ b/src/Sensors/MPU.hpp @@ -1,5 +1,6 @@ // This is a personal academic project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: https://pvs-studio.com +#pragma once #include "MPU6050_6Axis_MotionApps20.h" #include "Preferences.h" @@ -39,7 +40,7 @@ public: ESP_LOGE(_TAG, "MPU6050 test connection failed!"); return false; } - _mpu->setDLPFMode(MPU6050_DLPF_BW_10); // 10 Hz bandwidth + _mpu->setDLPFMode(MPU6050_DLPF_BW_10); // 10 Hz bandwidth //mpu.setFullScaleGyroRange(MPU6050_GYRO_FS_500); // set sensivity, not recommended //mpu.setFullScaleAccelRange(MPU6050_ACCEL_FS_8); @@ -225,7 +226,7 @@ private: float _axOffset = 0, _ayOffset = 0, _azOffset = 0; float _gxOffset = 0, _gyOffset = 0, _gzOffset = 0; - float _prOffset[2] = {0}; // yaw isn't used + float _prOffset[2] = {0}; // yaw isn't used uint8_t _fifoBuffer[45] = {0}; Preferences _preferences; diff --git a/src/Sensors/RangingSensor.cpp b/src/Sensors/RangingSensor.cpp index e5d2bfb..1e6ecde 100755 --- a/src/Sensors/RangingSensor.cpp +++ b/src/Sensors/RangingSensor.cpp @@ -1,14 +1,13 @@ -// -// Created by gogacoder on 10.03.24. -// - #include "RangingSensor.hpp" #include "esp_log.h" -RangingSensor::RangingSensor() {} +RangingSensor::RangingSensor() { +} -void RangingSensor::startFlight() {} +void RangingSensor::startFlight() { +} -void RangingSensor::tick() {} +void RangingSensor::tick() { +} uint32_t RangingSensor::getDistance() { return 0; } diff --git a/src/Sensors/RangingSensor.hpp b/src/Sensors/RangingSensor.hpp index fcafe12..f2ed41c 100755 --- a/src/Sensors/RangingSensor.hpp +++ b/src/Sensors/RangingSensor.hpp @@ -1,6 +1,6 @@ -// -// Created by gogacoder on 10.03.24. -// +// This is a personal academic project. Dear PVS-Studio, please check it. +// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: https://pvs-studio.com +#pragma once #ifndef HELICOPTER_FIRMWARE_RANGINGSENSOR_H #define HELICOPTER_FIRMWARE_RANGINGSENSOR_H diff --git a/src/Sensors/Sensors.hpp b/src/Sensors/Sensors.hpp index 5de3852..49c4e5b 100755 --- a/src/Sensors/Sensors.hpp +++ b/src/Sensors/Sensors.hpp @@ -1,6 +1,7 @@ // This is a personal academic project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: https://pvs-studio.com +#pragma once #include "Barometer.hpp" #include "BatteryController.hpp" #include "Filters/Kalman2DFilter.hpp" @@ -47,7 +48,7 @@ public: MpuData mpuData(void) const; - int batteryCharge(void) const; // [%] + int batteryCharge(void) const; // [%] bool tick(void); @@ -67,4 +68,4 @@ private: static constexpr const char *_tag = "Sensors"; -}; \ No newline at end of file +}; diff --git a/src/board_pins.h b/src/board_pins.h index 7e8a08e..e974465 100755 --- a/src/board_pins.h +++ b/src/board_pins.h @@ -1,9 +1,10 @@ // This is a personal academic project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: https://pvs-studio.com +#pragma once #define I2C_SDA_PIN 21 #define I2C_SCL_PIN 18 #define MPU6050_INT_PIN 19 #define BATTERY_ADC_CHANNEL ADC2_CHANNEL_0 #define BATTERY_DATA_PIN 4 -#define BATTERY_DATA_SWITCH_PIN 17 \ No newline at end of file +#define BATTERY_DATA_SWITCH_PIN 17