diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 3a27a15..ecc6ca6 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -28,7 +28,6 @@ "${workspaceFolder}/flix/motors.ino", "${workspaceFolder}/flix/rc.ino", "${workspaceFolder}/flix/time.ino", - "${workspaceFolder}/flix/util.ino", "${workspaceFolder}/flix/wifi.ino" ], "compilerPath": "~/.arduino15/packages/esp32/tools/esp-x32/2405/bin/xtensa-esp32-elf-g++", @@ -75,7 +74,6 @@ "${workspaceFolder}/flix/motors.ino", "${workspaceFolder}/flix/rc.ino", "${workspaceFolder}/flix/time.ino", - "${workspaceFolder}/flix/util.ino", "${workspaceFolder}/flix/wifi.ino" ], "compilerPath": "~/Library/Arduino15/packages/esp32/tools/esp-x32/2405/bin/xtensa-esp32-elf-g++", @@ -122,7 +120,6 @@ "${workspaceFolder}/flix/motors.ino", "${workspaceFolder}/flix/rc.ino", "${workspaceFolder}/flix/time.ino", - "${workspaceFolder}/flix/util.ino", "${workspaceFolder}/flix/wifi.ino" ], "compilerPath": "~/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2405/bin/xtensa-esp32-elf-g++.exe", diff --git a/flix/control.ino b/flix/control.ino index 0eb03d8..8b31cbf 100644 --- a/flix/control.ino +++ b/flix/control.ino @@ -7,6 +7,7 @@ #include "quaternion.h" #include "pid.h" #include "lpf.h" +#include "util.h" #define PITCHRATE_P 0.05 #define PITCHRATE_I 0.2 diff --git a/flix/estimate.ino b/flix/estimate.ino index a9adaf4..fa8c306 100644 --- a/flix/estimate.ino +++ b/flix/estimate.ino @@ -6,12 +6,12 @@ #include "quaternion.h" #include "vector.h" #include "lpf.h" +#include "util.h" #define WEIGHT_ACC 0.5f #define RATES_LFP_ALPHA 0.2 // cutoff frequency ~ 40 Hz LowPassFilter ratesFilter(RATES_LFP_ALPHA); -extern const float ONE_G; void estimate() { applyGyro(); diff --git a/flix/flix.ino b/flix/flix.ino index 59ad9ec..9bacfa9 100644 --- a/flix/flix.ino +++ b/flix/flix.ino @@ -5,6 +5,7 @@ #include "vector.h" #include "quaternion.h" +#include "util.h" #define SERIAL_BAUDRATE 115200 diff --git a/flix/imu.ino b/flix/imu.ino index 51747ca..6658573 100644 --- a/flix/imu.ino +++ b/flix/imu.ino @@ -5,6 +5,7 @@ #include #include +#include "util.h" // NOTE: use 'ca' command to calibrate the accelerometer and put the values here Vector accBias(0, 0, 0); @@ -13,8 +14,6 @@ Vector accScale(1, 1, 1); MPU9250 IMU(SPI); Vector gyroBias; -extern const float ONE_G; - void setupIMU() { Serial.println("Setup IMU"); bool status = IMU.begin(); diff --git a/flix/motors.ino b/flix/motors.ino index ee1bf71..babfa51 100644 --- a/flix/motors.ino +++ b/flix/motors.ino @@ -5,6 +5,8 @@ // In case of using ESC, use this version of the code: https://gist.github.com/okalachev/8871d3a94b6b6c0a298f41a4edd34c61. // Motor: 8520 3.7V +#include "util.h" + #define MOTOR_0_PIN 12 // rear left #define MOTOR_1_PIN 13 // rear right #define MOTOR_2_PIN 14 // front right diff --git a/flix/rc.ino b/flix/rc.ino index de849a3..34fd3d4 100644 --- a/flix/rc.ino +++ b/flix/rc.ino @@ -4,6 +4,7 @@ // Work with the RC receiver #include +#include "util.h" // NOTE: use 'cr' command to calibrate the RC and put the values here int channelNeutral[] = {995, 883, 200, 972, 512, 512, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; diff --git a/flix/util.ino b/flix/util.h similarity index 98% rename from flix/util.ino rename to flix/util.h index 04e2595..98d76b3 100644 --- a/flix/util.ino +++ b/flix/util.h @@ -3,6 +3,8 @@ // Utility functions +#pragma once + #include #include #include diff --git a/gazebo/simulator.cpp b/gazebo/simulator.cpp index 9afa038..ea2d353 100644 --- a/gazebo/simulator.cpp +++ b/gazebo/simulator.cpp @@ -17,7 +17,6 @@ #include "Arduino.h" #include "flix.h" -#include "util.ino" #include "rc.ino" #include "time.ino" #include "motors.ino" diff --git a/gazebo/soc/rtc_cntl_reg.h b/gazebo/soc/rtc_cntl_reg.h index f595162..b41211d 100644 --- a/gazebo/soc/rtc_cntl_reg.h +++ b/gazebo/soc/rtc_cntl_reg.h @@ -1 +1 @@ -// Dummy file to make it possible to compile simulator with util.ino +// Dummy file to make it possible to compile simulator with Flix' util.h diff --git a/gazebo/soc/soc.h b/gazebo/soc/soc.h index dcb15c2..f4bdec2 100644 --- a/gazebo/soc/soc.h +++ b/gazebo/soc/soc.h @@ -1,3 +1,3 @@ -// Dummy file to make it possible to compile simulator with util.ino +// Dummy file to make it possible to compile simulator with Flix' util.h #define WRITE_PERI_REG(addr, val) {}